micpalmia 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_r392569092
 
 

 ##########
 File path: 
lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java
 ##########
 @@ -156,42 +135,38 @@ public float floatVal(int doc) {
   @Override
   public boolean exists(int doc) {
     try {
-      if (doc < lastDocRequested) {
-        if (noMatches) return false;
+      if (noMatches) return false;
+      if (scorer == null) {
         scorer = weight.scorer(readerContext);
-        scorerDoc = -1;
-        if (scorer==null) {
+        if (scorer == null) {
           noMatches = true;
           return false;
         }
-        it = scorer.iterator();
+        tpi = scorer.twoPhaseIterator();
+        disi = tpi==null ? scorer.iterator() : tpi.approximation();
+        thisDocMatches = false;
       }
+      assert doc >= lastDocRequested : "values requested out of order; last=" 
+ lastDocRequested + ", requested=" + doc;
 
 Review comment:
   I also didn't think so until your last review, but I found the following on 
the docstring for `ValueSource.getValues`:
   
   > The values must be consumed in a forward docID manner, and you must call 
this method again to iterate through the values again.

----------------------------------------------------------------
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