xiangfu0 commented on code in PR #19589:
URL: https://github.com/apache/pinot/pull/19589#discussion_r4664016090


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/dociditerators/NotDocIdIterator.java:
##########
@@ -29,39 +29,50 @@ public class NotDocIdIterator implements BlockDocIdIterator 
{
   private final int _numDocs;
   private int _nextDocId;
   private int _nextNonMatchingDocId;
+  private boolean _closed;
 
   public NotDocIdIterator(BlockDocIdIterator childDocIdIterator, int numDocs) {
     _childDocIdIterator = childDocIdIterator;
-    _nextDocId = 0;
-
-    int currentDocIdFromChildIterator = childDocIdIterator.next();
-    _nextNonMatchingDocId = currentDocIdFromChildIterator == Constants.EOF ? 
numDocs : currentDocIdFromChildIterator;
     _numDocs = numDocs;
+    _nextNonMatchingDocId = childDocIdIterator.next();

Review Comment:
   **[must-fix] Defer the first child pull until the iterator has an owner.** 
This constructor calls `childDocIdIterator.next()` before `DocIdSetOperator` 
stores the outer iterator. If a compound child opens a reusable expression 
reader in one branch and a later branch fails or observes cancellation during 
that pull, selection cleanup has no iterator to close. Move the first pull into 
`next()` or `advance()` and add a regression that verifies cleanup closes the 
opened reader and preserves the original exception.



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