Example #1
0
// always pack from *.0 files (it must be pre-merged!)
void IndexWriter::packPSTBlk() {
  cout << "# packing postings..." << endl;
  ofstream pack_trm, pack_doc, pack_tmap;
  ifstream merge_trm, merge_doc;
  string prefix = path+"/"+POSTINGS_FILE, m1, m2;
  m1 = prefix+".trm";
  m2 = prefix+".doc";

  pack_trm.open(m1.c_str());
  pack_doc.open(m2.c_str(), ios::binary);
  pack_tmap.open((path+"/"+TERM_MAP_FILE).c_str(), ios::binary);

  merge_trm.open((m1+".0").c_str());
  merge_doc.open((m2+".0").c_str(), ios::binary);

  if (!merge_trm || !merge_doc) {
    error("Writer::fail opening %s, etc", (m1+".0").c_str());
  }
  int num_term = 0;
  TermAttr attr;
  while (attr.load(merge_trm)>=0) {
    int num_docs = 0, size;
    fread(merge_doc, &num_docs, sizeof(num_docs));
    fread(merge_doc, didbuf, sizeof(didbuf[0])*num_docs);
    fread(merge_doc, frqbuf, sizeof(frqbuf[0])*num_docs);

    pack_trm  << num_term << " " << ftellp(pack_doc) << "\n";
    assert(num_docs < PST_BUF);

    dgap(didbuf, num_docs);
    encode_vb(didbuf, num_docs, buf, size);
    assert(size < PST_BUF*10);
    fwrite(pack_doc, &size, sizeof(size));
    fwrite(pack_doc, buf, sizeof(buf[0])*size);

    encode_vb(frqbuf, num_docs, buf, size);
    assert(size < PST_BUF*10);
    fwrite(pack_doc, &size, sizeof(size));
    fwrite(pack_doc, buf, sizeof(buf[0])*size);

    attr.flush(pack_tmap);
    num_term++;
  }
  cout << "# num_term = " << num_term << endl;

  merge_trm.close();
  merge_doc.close();

  pack_trm.close();
  pack_doc.close();
  pack_tmap.close();

  remove((m1+".0").c_str());
  remove((m2+".0").c_str());
}
Example #2
0
Real
GapHeatTransfer::dgapLength( Real normalComponent ) const
{
  const Real gap_L = gapLength();

  Real dgap(0);

  if ( _min_gap <= gap_L && gap_L <= _max_gap)
  {
    dgap = normalComponent;
  }

  return dgap;
}