Avoid reset BlockDocsEnum#freqBuffer when indexHasFreq is false (#12997)

This commit is contained in:
Zhang Chao 2024-01-11 22:37:52 +08:00 committed by GitHub
parent 4b1180372e
commit 75e1a0b96c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -199,6 +199,8 @@ Optimizations
* GITHUB#12841: Move group-varint encoding/decoding logic to DataOutput/DataInput. (Adrien Grand, Zhang Chao, Uwe Schindler) * GITHUB#12841: Move group-varint encoding/decoding logic to DataOutput/DataInput. (Adrien Grand, Zhang Chao, Uwe Schindler)
* GITHUB#:12997 Avoid reset BlockDocsEnum#freqBuffer when indexHasFreq is false. (Zhang Chao, Adrien Grand)
Bug Fixes Bug Fixes
--------------------- ---------------------
* GITHUB#12866: Prevent extra similarity computation for single-level HNSW graphs. (Kaival Parikh) * GITHUB#12866: Prevent extra similarity computation for single-level HNSW graphs. (Kaival Parikh)

View File

@ -400,9 +400,9 @@ public final class Lucene99PostingsReader extends PostingsReaderBase {
this.needsFreq = PostingsEnum.featureRequested(flags, PostingsEnum.FREQS); this.needsFreq = PostingsEnum.featureRequested(flags, PostingsEnum.FREQS);
this.isFreqsRead = true; this.isFreqsRead = true;
if (indexHasFreq == false || needsFreq == false) { if (indexHasFreq == false || needsFreq == false) {
for (int i = 0; i < ForUtil.BLOCK_SIZE; ++i) { // Filling this buffer may not be cheap when doing primary key lookups, so we make sure to
freqBuffer[i] = 1; // not fill more than `docFreq` entries.
} Arrays.fill(freqBuffer, 0, Math.min(ForUtil.BLOCK_SIZE, docFreq), 1);
} }
accum = 0; accum = 0;
blockUpto = 0; blockUpto = 0;