michaeljmarshall commented on code in PR #16146:
URL: https://github.com/apache/lucene/pull/16146#discussion_r4138521657


##########
lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java:
##########
@@ -262,13 +264,57 @@ assert assertItersOnSameDoc()
       return doNext(lead.advance(target));
     }
 
+    @Override
+    public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws 
IOException {
+      assert offset <= docID() : "offset=" + offset + " docID()=" + docID() + 
" upTo=" + upTo;
+      int doc = docID();
+      if (doc >= upTo) {
+        return;
+      }
+
+      // Bulk masking has fixed per-window cost; sparse leads are cheaper to 
advance per doc.
+      if (lead.cost() < bitSet.length()) {
+        super.intoBitSet(upTo, bitSet, offset);
+        return;
+      }
+
+      int bulkUpTo = Math.min(upTo, minLength);
+      long destinationEnd = (long) offset + bitSet.length();
+      if (destinationEnd < bulkUpTo) {
+        bulkUpTo = (int) destinationEnd;
+      }
+
+      if (doc < bulkUpTo) {
+        if (scratch == null || scratch.length() != bitSet.length()) {
+          scratch = new FixedBitSet(bitSet.length());
+        } else {
+          scratch.clear();
+        }
+
+        lead.intoBitSet(bulkUpTo, scratch, offset);
+        for (BitSet bitSetMask : bitSets) {
+          bitSetMask.applyMask(scratch, offset);
+        }
+        bitSet.or(scratch);
+
+        doNext(lead.docID());
+      }
+
+      if (docID() < upTo) {
+        super.intoBitSet(upTo, bitSet, offset);
+      }
+    }
+
     private int doNext(int doc) throws IOException {
       advanceLead:
       for (; ; doc = lead.nextDoc()) {
         if (doc >= minLength) {
           if (doc != NO_MORE_DOCS) {
             lead.advance(NO_MORE_DOCS);
           }
+          for (BitSetIterator iterator : bitSetIterators) {
+            iterator.setDocId(NO_MORE_DOCS);
+          }

Review Comment:
   IIUC, this is a bug fix. Without this, the sub-iterators could be in a state 
where they were not all on the same doc at the same time for `NO_MORE_DOCS`.



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

Reply via email to