dsmiley commented on a change in pull request #1343: LUCENE-8103: Use two-phase 
iteration in Query- and DoubleValuesSource
URL: https://github.com/apache/lucene-solr/pull/1343#discussion_r392228458
 
 

 ##########
 File path: 
lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java
 ##########
 @@ -156,42 +136,35 @@ public float floatVal(int doc) {
   @Override
   public boolean exists(int doc) {
     try {
+      if (noMatches) return false;
       if (doc < lastDocRequested) {
-        if (noMatches) return false;
         scorer = weight.scorer(readerContext);
-        scorerDoc = -1;
         if (scorer==null) {
           noMatches = true;
           return false;
         }
-        it = scorer.iterator();
+        tpi = scorer.twoPhaseIterator();
+        it = tpi==null ? scorer.iterator() : tpi.approximation();
+        scorerDoc = -1;
+        thisDocMatches = false;
       }
       lastDocRequested = doc;
 
       if (scorerDoc < doc) {
         scorerDoc = it.advance(doc);
-      }
-
-      if (scorerDoc > doc) {
-        // query doesn't match this document... either because we hit the
-        // end, or because the next doc is after this doc.
-        return false;
+        thisDocMatches = tpi == null || tpi.matches();
 
 Review comment:
   Again, lets not compute thisDocMatches if the scorerDoc doesn't even align.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to