vsop-479 commented on code in PR #13253:
URL: https://github.com/apache/lucene/pull/13253#discussion_r1613089056
##########
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:
> One case you can roll back entCount temporarily, because you know the
target term is before the current term?
Yes.
> but you do know the target term is in this current block? But then why are
we even rewinding?
We get `lastFrame` from `stack[0]` firstly, and compare `target` to last
seek'd `term` to update `lastFrame` to reuse seek state, and assign it to
`currentFrame`. This `currentFrame` only got by `target` and last seek'd `term`
's common prefix, we still need to continue walking the index to seek `target`
term's block.
I think we need rewinding to set frame's state (`nextEnt`, `entCount`, etc.)
to prepare for seeking. Unlike `rewind`, `rewindWithoutReload` can keep loaded
block's data (same `FP`).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]