jpountz commented on code in PR #13424: URL: https://github.com/apache/lucene/pull/13424#discussion_r1618325471
########## lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsReader.java: ########## @@ -609,6 +622,23 @@ public void skipBytes(long numBytes) throws IOException { } } + @Override + public void prefetch(int docID) throws IOException { + final long blockID = indexReader.getBlockID(docID); + + for (long prefetchedBlockID : prefetchedBlockIDCache) { + if (prefetchedBlockID == blockID) { + return; + } + } + + final long blockStartPointer = indexReader.getBlockStartPointer(blockID); + final long blockLength = indexReader.getBlockLength(blockID); + fieldsStream.prefetch(blockStartPointer, blockLength); + + prefetchedBlockIDCache[prefetchedBlockIDCacheIndex++ & PREFETCH_CACHE_MASK] = blockID; Review Comment: Overflowing is fine in this case since we only look at the lower bits of the value. If `prefetchedBlockIDCacheIndex` reaches Integer.MAX_VALUE = 2^31-1, `prefetchedBlockIDCacheIndex` will then be -2^31 because of the overflow, which has the same lower bits as 2^31. Since we're then only taking the lower 4 bits of the value, it yields the same number. -- 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