Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1612

expose lastDocId in the posting from the TermEnum API

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 2.4
    • Fix Version/s: None
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      We currently have on the TermEnum api: docFreq() which gives the number docs in the posting.
      It would be good to also have the max docid in the posting. That information is useful when construction a custom DocIdSet, .e.g determine sparseness of the doc list to decide whether or not to use a BitSet.

      I have written a patch to do this, the problem with it is the TermInfosWriter encodes values in VInt/VLong, there is very little flexibility to add in lastDocId while making the index backward compatible. (If simple int is used for say, docFreq, a bit can be used to flag reading of a new piece of information)

      output.writeVInt(ti.docFreq); // write doc freq
      output.writeVLong(ti.freqPointer - lastTi.freqPointer); // write pointers
      output.writeVLong(ti.proxPointer - lastTi.proxPointer);

      Anyway, patch is attached with:TestSegmentTermEnum modified to test this. TestBackwardsCompatibility fails due to reasons described above.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              john.wang@gmail.com John Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: