Jackie-Jiang commented on code in PR #11200:
URL: https://github.com/apache/pinot/pull/11200#discussion_r1281199310


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/docidsets/AndDocIdSet.java:
##########
@@ -75,13 +77,21 @@ public BlockDocIdIterator iterator() {
     List<BitmapBasedDocIdIterator> bitmapBasedDocIdIterators = new 
ArrayList<>();
     List<ScanBasedDocIdIterator> scanBasedDocIdIterators = new ArrayList<>();
     List<BlockDocIdIterator> remainingDocIdIterators = new ArrayList<>();
-    for (int i = 0; i < numDocIdSets; i++) {
-      BlockDocIdIterator docIdIterator = _docIdSets.get(i).iterator();
+
+    Iterator<BlockDocIdSet> iterator = _docIdSets.iterator();
+    for (int i = 0; iterator.hasNext(); i++) {
+      BlockDocIdSet blockDocIdSet = iterator.next();
+      BlockDocIdIterator docIdIterator = blockDocIdSet.iterator();
       allDocIdIterators[i] = docIdIterator;
       if (docIdIterator instanceof SortedDocIdIterator) {
         sortedDocIdIterators.add((SortedDocIdIterator) docIdIterator);
+        // do not keep holding on to the _docIdRanges since they will occupy 
heap space during the query execution
+        iterator.remove();
       } else if (docIdIterator instanceof BitmapBasedDocIdIterator) {
         bitmapBasedDocIdIterators.add((BitmapBasedDocIdIterator) 
docIdIterator);
+        // do not keep holding on to the bitmaps since they will occupy heap 
space during the query execution
+        _numEntriesScannedInFilter += 
blockDocIdSet.getNumEntriesScannedInFilter();

Review Comment:
   As mentioned above, collecting `numEntriesScannedInFilter` when creating the 
iterator itself is wrong. Since we know these iterators can be applied before 
any scan happens, we can remove this step. Some comment explaining this would 
be good



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to