Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Optimizations

* GITHUB#14333: Introduce a specialized trie for block tree index, instead of FST. (Guo Feng)

* GITHUB#14447: Compute the doc range more efficiently when flushing doc block. (Pan Guixin)

Bug Fixes
---------------------
(No changes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,13 @@ private void flushDocBlock(boolean finishTerm) throws IOException {
// storage-efficient than the next number of bits per value (which effectively slightly biases
// towards the bit set approach).
int bitsPerValue = forDeltaUtil.bitsRequired(docDeltaBuffer);
int sum = Math.toIntExact(Arrays.stream(docDeltaBuffer).sum());
int numBitSetLongs = FixedBitSet.bits2words(sum);
int docRange = lastDocID - level0LastDocID;
assert docRange == Arrays.stream(docDeltaBuffer).sum();
int numBitSetLongs = FixedBitSet.bits2words(docRange);
int numBitsNextBitsPerValue = Math.min(Integer.SIZE, bitsPerValue + 1) * BLOCK_SIZE;
if (sum == BLOCK_SIZE) {
if (docRange == BLOCK_SIZE) {
level0Output.writeByte((byte) 0);
} else if (numBitsNextBitsPerValue <= sum) {
} else if (numBitsNextBitsPerValue <= docRange) {
level0Output.writeByte((byte) bitsPerValue);
forDeltaUtil.encodeDeltas(bitsPerValue, docDeltaBuffer, level0Output);
} else {
Expand Down