lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jian chen" <chenjian1...@gmail.com>
Subject Re: when was the document number initially written into .frq file?
Date Mon, 08 May 2006 20:27:55 GMT
It is in DocumentWriter.java class.

Look at writePostings(...) method.

Here are the lines:

    // add an entry to the freq file
    int f = posting.freq;
    if (f == 1)                  // optimize freq=1
      freq.writeVInt(1);              // set low bit of doc num.
    else {
      freq.writeVInt(0);              // the document number
      freq.writeVInt(f);              // frequency in doc
    }

Any other question?

Jian

On 5/6/06, Charlie <charliecmo@gmail.com> wrote:
>
> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message