jpountz commented on PR #12997: URL: https://github.com/apache/lucene/pull/12997#issuecomment-1881470555
Sorry I might have put you on the wrong track, I didn't know we had such leniency around frequencies/positions/offsets. Out of curiosity, I tried to add checks to AssertingLeafReader to fail when reading freqs/positions/offsets/payloads if they have not been requested in the flags, and there are many test failures. It's not entirely clear to me how intentional that is, @rmuir do you have context by any chance? For the case you're trying to improve, another approach could consist of filling at most `docFreq` entries in the freq buffer: ```patch diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99PostingsReader.java index 80d24917477..362fb34539e 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99PostingsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99PostingsReader.java @@ -400,9 +400,9 @@ public final class Lucene99PostingsReader extends PostingsReaderBase { this.needsFreq = PostingsEnum.featureRequested(flags, PostingsEnum.FREQS); this.isFreqsRead = true; if (indexHasFreq == false || needsFreq == false) { - for (int i = 0; i < ForUtil.BLOCK_SIZE; ++i) { - freqBuffer[i] = 1; - } + // Filling this buffer may not be cheap when doing primary key lookups, so we make sure to + // not fill more than `docFreq` entries. + Arrays.fill(freqBuffer, 0, Math.min(ForUtil.BLOCK_SIZE, docFreq), 1); } accum = 0; blockUpto = 0; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org