lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charlie <charlie...@gmail.com>
Subject when was the document number initially written into .frq file?
Date Sun, 07 May 2006 01:21:20 GMT
Hello,

Would any developer please give me a hint of when the document number was
initially written into .frq file?

From: //it is not really write the doc# in writePostings()

final class DocumentWriter
  private final void writePostings(Posting[] postings, String segment)
        int postingFreq = posting.freq;
        if (postingFreq == 1)                             // optimize freq=1
          freq.writeVInt(1);                      // set low bit of doc num.
        else { 
          freq.writeVInt(0);                      // the document number
          freq.writeVInt(postingFreq);                    // frequency in doc
        }

//it is write the doc# in appendPostings()

final class SegmentMerger
  private final int appendPostings(SegmentMergeInfo[] smis, int n)

        int docCode = (doc - lastDoc) << 1;       // use low bit to flag freq=1
        lastDoc = doc;

        int freq = postings.freq();
        if (freq == 1) {
          freqOutput.writeVInt(docCode | 1);      // write doc & freq=1
        } else {
          freqOutput.writeVInt(docCode);          // write doc
          freqOutput.writeVInt(freq);             // write frequency in doc
        }

//but then I am further confused that in order to call
int doc = postings.doc(); in appendPostings(),
the doc# should already been written.

Chicken-egg-chicken-egg ...

Should there be another place for the initial writing of the doc# ?

-- 
Thanks for your advice,
 Charlie


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message