kkewwei created LUCENE-9096: ------------------------------- Summary: Implementation of CompressingTermVectorsWriter.flushOffsets can be simpler Key: LUCENE-9096 URL: https://issues.apache.org/jira/browse/LUCENE-9096 Project: Lucene - Core Issue Type: Improvement Components: core/codecs Affects Versions: 8.2 Reporter: kkewwei
In CompressingTermVectorsWriter.flushOffsets, we count sumPos and sumOffsets by the way {code:java} 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; } } {code} 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 -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org