abiesps commented on code in PR #15376:
URL: https://github.com/apache/lucene/pull/15376#discussion_r2585700702
##########
lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java:
##########
@@ -1076,4 +1137,123 @@ public long cost() {
return length;
}
}
+
+ /**
+ * We can recurse the {@link BKDPointTree} using {@link
TwoPhaseIntersectVisitor}. This visitor
+ * travere {@link BKDPointTree} in two phases. In the first phase, it
recurses over the {@link
+ * BKDPointTree} optionally triggering IO for some of the blocks and caching
them. In the second
+ * phase, once the recursion is over it visits the cached blocks one by one.
+ *
+ * @lucene.experimental
+ */
+ public interface TwoPhaseIntersectVisitor extends IntersectVisitor {
+ /** return the last deferred block ordinal during recursion. */
+ public int lastDeferredBlockOrdinal();
+
+ /** set last deferred block ordinal */
+ public void setLastDeferredBlockOrdinal(int leafNodeOrdinal);
+
+ /** Defer this block for processing in the second phase. */
+ public void deferBlock(long leafFp);
+
+ /** Returns a snapshot of the currently deferred blocks. */
+ public List<Long> deferredBlocks();
+
+ /** Mark the given block as processed and remove it from the deferred set.
*/
+ public void onProcessingDeferredBlock(long leafFp);
+ }
+
+ /**
+ * Base implementation of {@link TwoPhaseIntersectVisitor} that maintains a
list of deferred
+ * blocks from first phase of traversal and visits them in the second phase.
+ *
+ * @lucene.experimental
+ */
+ public abstract static class BaseTwoPhaseIntersectVisitor implements
TwoPhaseIntersectVisitor {
+
+ int lastDeferredBlockOrdinal = -1;
+ List<Long> deferredBlocks = new ArrayList<>();
Review Comment:
Actually list can grow upto total number of leaf nodes in worst case. Num of
leaves /2 +1 is the maximum number of prefetch calls in worst case.
--
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]