File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
core/src/java/org/apache/lucene/codecs/lucene103 Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ Optimizations
3737
3838* GITHUB#14333: Introduce a specialized trie for block tree index, instead of FST. (Guo Feng)
3939
40+ * GITHUB#14447: Compute the doc range more efficiently when flushing doc block. (Pan Guixin)
41+
4042Bug Fixes
4143---------------------
4244(No changes)
Original file line number Diff line number Diff line change @@ -429,12 +429,13 @@ private void flushDocBlock(boolean finishTerm) throws IOException {
429429 // storage-efficient than the next number of bits per value (which effectively slightly biases
430430 // towards the bit set approach).
431431 int bitsPerValue = forDeltaUtil .bitsRequired (docDeltaBuffer );
432- int sum = Math .toIntExact (Arrays .stream (docDeltaBuffer ).sum ());
433- int numBitSetLongs = FixedBitSet .bits2words (sum );
432+ int docRange = lastDocID - level0LastDocID ;
433+ assert docRange == Arrays .stream (docDeltaBuffer ).sum ();
434+ int numBitSetLongs = FixedBitSet .bits2words (docRange );
434435 int numBitsNextBitsPerValue = Math .min (Integer .SIZE , bitsPerValue + 1 ) * BLOCK_SIZE ;
435- if (sum == BLOCK_SIZE ) {
436+ if (docRange == BLOCK_SIZE ) {
436437 level0Output .writeByte ((byte ) 0 );
437- } else if (numBitsNextBitsPerValue <= sum ) {
438+ } else if (numBitsNextBitsPerValue <= docRange ) {
438439 level0Output .writeByte ((byte ) bitsPerValue );
439440 forDeltaUtil .encodeDeltas (bitsPerValue , docDeltaBuffer , level0Output );
440441 } else {
You can’t perform that action at this time.
0 commit comments