LUCENE-9096:Simplify CompressingTermVectorsWriter#flushOffsets. (#1125)

This commit is contained in:
kkewwei 2020-01-06 16:19:08 +08:00 committed by Adrien Grand
parent f87b4c13bb
commit 2db4c909ca
1 changed files with 3 additions and 11 deletions

View File

@ -564,17 +564,9 @@ public final class CompressingTermVectorsWriter extends TermVectorsWriter {
final int fieldNumOff = Arrays.binarySearch(fieldNums, fd.fieldNum); final int fieldNumOff = Arrays.binarySearch(fieldNums, fd.fieldNum);
int pos = 0; int pos = 0;
for (int i = 0; i < fd.numTerms; ++i) { for (int i = 0; i < fd.numTerms; ++i) {
int previousPos = 0; sumPos[fieldNumOff] += positionsBuf[fd.posStart + fd.freqs[i]-1 + pos];
int previousOff = 0; sumOffsets[fieldNumOff] += startOffsetsBuf[fd.offStart + fd.freqs[i]-1 + pos];
for (int j = 0; j < fd.freqs[i]; ++j) { pos += fd.freqs[i];
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;
}
} }
assert pos == fd.totalPositions; assert pos == fd.totalPositions;
} }