romseygeek commented on code in PR #15511:
URL: https://github.com/apache/lucene/pull/15511#discussion_r2635455663
##########
lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java:
##########
@@ -599,4 +624,42 @@ private void init(int minOrd, int maxOrd) throws
IOException {
disjunction.addAll(postings);
}
}
+
+ private class SkipperBasedCompetitiveState extends CompetitiveState {
+ private final DocValuesSkipper skipper;
+ private final TwoPhaseIterator innerTwoPhase;
+ private int minOrd;
+ private int maxOrd;
+
+ SkipperBasedCompetitiveState(LeafReaderContext context, DocValuesSkipper
skipper)
+ throws IOException {
+ super(context);
+ this.skipper = skipper;
+ this.iterator.update(DocIdSetIterator.all(context.reader().maxDoc()));
+ final SortedDocValues docValues = getSortedDocValues(context, field);
+ this.innerTwoPhase =
+ new TwoPhaseIterator(docValues) {
+ @Override
+ public boolean matches() throws IOException {
+ final int cur = docValues.ordValue();
+ return cur >= minOrd && cur <= maxOrd;
+ }
+
+ @Override
+ public float matchCost() {
+ return 2;
+ }
+ };
+ }
+
+ @Override
+ public void update(int minOrd, int maxOrd) throws IOException {
+ this.minOrd = minOrd;
+ this.maxOrd = maxOrd;
+
+ final TwoPhaseIterator twoPhaseIterator =
+ new DocValuesRangeIterator(innerTwoPhase, skipper, minOrd, maxOrd,
false);
Review Comment:
One thing that I've been meaning to test with numeric comparators but
haven't got round to yet: I wonder if its worth replacing this usage of
`DocValuesRangeIterator` with something that only advances to skip-block
boundaries? My reasoning being that if the parent query is reasonably sparse,
then calling `advance()` on this competitive iterator might end up doing a
bunch of work to find the precise first matching value within a block that is
then immediately thrown away when we leapfrog back and call advance() on the
parent iterator. Whereas if we just advance to the first competitive block
then we can let the parent query do the work.
--
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]