mayya-sharipova commented on a change in pull request #1952:
URL: https://github.com/apache/lucene-solr/pull/1952#discussion_r500604093



##########
File path: lucene/core/src/java/org/apache/lucene/search/Weight.java
##########
@@ -266,4 +274,45 @@ static void scoreAll(LeafCollector collector, 
DocIdSetIterator iterator, TwoPhas
     }
   }
 
+  /**
+   * Wraps an internal docIdSetIterator for it to start with docID = -1
+   */
+  protected static class RangeDISIWrapper extends DocIdSetIterator {
+    private final DocIdSetIterator in;
+    private final int min;
+    private final int max;
+    private int docID = -1;
+
+    public RangeDISIWrapper(DocIdSetIterator in, int max) {
+      this.in = in;
+      this.min = in.docID();
+      this.max = max;
+    }
+
+    @Override
+    public int docID() {
+      return docID;
+    }
+
+    @Override
+    public int nextDoc() throws IOException {
+      return advance(docID + 1);
+    }
+
+    @Override
+    public int advance(int target) throws IOException {
+      target = Math.max(min, target);
+      if (target >= max) {
+        return docID = NO_MORE_DOCS;
+      }
+      return docID = in.advance(target);

Review comment:
       Indeed the [recent 
failures](https://elasticsearch-ci.elastic.co/job/apache+lucene-solr+master/5689/console)
 on Lucene are because of this. `ReqExclBulkScorer` calls`score` method several 
times and sometimes with the minimum bound that is <= scorer.docID().
   
   
   
   I am thinking the logic is becoming more difficult. I am thinking to go back 
to the [initial 
commit](https://github.com/apache/lucene-solr/pull/1952/commits/574245c96db19291138b2eb7253451b567c69d89)
 and advance collectorIterator to the same doc as `scorerIterator`. At the 
beginning a  `collectorIterator` matches all docs, so it should precisely 
advance to the `scorerIterator.docID()).
   




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



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

Reply via email to