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

Implementation of CompressingTermVectorsWriter.flushOffsets can be simpler

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 8.2
    • 8.5
    • core/codecs
    • None
    • New

    Description

      In CompressingTermVectorsWriter.flushOffsets,  we count 

      sumPos and sumOffsets by the way

      for (int i = 0; i < fd.numTerms; ++i) { 
        int previousPos = 0;
        int previousOff = 0;
        for (int j = 0; j < fd.freqs[i]; ++j) { 
          final int position = positionsBuf[fd.posStart + pos];
          final int startOffset = startOffsetsBuf[fd.offStart + pos];
          sumPos[fieldNumOff] += position - previousPos; 
          sumOffsets[fieldNumOff] += startOffset - previousOff; 
          previousPos = position;
          previousOff = startOffset;
          ++pos;
        }
      }
      

      we always use the position - previousPos,  it can be summarized like this: 

      (position5-position4)+(position4-position3)+(position3-position2)+(position2-position1)

      If we should simplify it: position5-position1

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kkewwei kkewwei
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m