jpountz commented on code in PR #14523:
URL: https://github.com/apache/lucene/pull/14523#discussion_r2051658845


##########
lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java:
##########
@@ -524,17 +524,21 @@ public int advance(int target) throws IOException {
 
     @Override
     public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws 
IOException {
+      upTo = Math.min(upTo, maxDoc);
       if (upTo <= doc) {
         return;
       }
       // Optimize the case when intersecting the competitive iterator is 
expensive, which is when it
       // hasn't nailed down a disjunction of competitive terms yet.
       if (disjunction == null) {
         if (docsWithField != null) {
+          // we need to be absolutely sure that the iterator is at least at 
offset
+          if (docsWithField.docID() < offset) {

Review Comment:
   The contract from `DocIdSetIterator#intoBitSet` requires starting from the 
current doc rather than the first doc on or after `offset`, so it would be more 
correct to advance to `doc` here. In practice, it wouldn't make a difference 
today since all call sites first advance iterators to `offset` before calling 
`intoBitSet`, but it may not always be the 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: issues-unsubscr...@lucene.apache.org

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