vsop-479 commented on code in PR #13253: URL: https://github.com/apache/lucene/pull/13253#discussion_r1613134899
########## lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/SegmentTermsEnum.java: ########## @@ -434,8 +436,29 @@ public boolean seekExact(BytesRef target) throws IOException { // System.out.println(" target is before current (shares prefixLen=" + targetUpto + "); // rewind frame ord=" + lastFrame.ord); // } + + // We got lastFrame by comparing target and term, and target less than last seeked term in + // currentFrame. If lastFrame's fp is same with currentFrame's fp, we can reduce entCount to + // nextEnt. + boolean currentIsLast = currentFrame.fp == lastFrame.fp; currentFrame = lastFrame; - currentFrame.rewind(); + + // Only rewindWithoutReload for non-floor block or first floor block. + // TODO: We need currentFrame's first entry to judge whether we can rewindWithoutReload for + // non-first floor blocks. + if (currentFrame.fp != currentFrame.fpOrig + || currentFrame.entCount == 0 + || currentFrame.nextEnt == -1) { + currentFrame.rewind(); + } else { + // Prepare to reduce entCount. + if (currentIsLast && currentFrame.isLeafBlock) { Review Comment: `rewindWithoutReload` is called when currentFrame's is loaded and `fp` equals `fpOrig`. Doing this can avoid reload a loaded block, when we finally need seek it, and it is still in `stack`. -- 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