Jackie-Jiang commented on code in PR #15139: URL: https://github.com/apache/pinot/pull/15139#discussion_r2008120713
########## pinot-core/src/main/java/org/apache/pinot/core/common/BlockDocIdIterator.java: ########## @@ -47,4 +47,11 @@ public interface BlockDocIdIterator { * @see {https://github.com/RoaringBitmap/RoaringBitmap/pull/243#issuecomment-381278304} */ int OPTIMAL_ITERATOR_BATCH_SIZE = 256; + + /** + * Close resources if applicable. + */ + default void close() { Review Comment: Suggest making it extending `AutoCloseable` ########## pinot-core/src/main/java/org/apache/pinot/core/common/DataFetcher.java: ########## @@ -587,11 +585,20 @@ public void readNumValuesMV(int[] docIds, int length, int[] numValuesBuffer) { } @Override - public void close() - throws IOException { + public void close() { if (_readerContext != null) { _readerContext.close(); } } } + + /** + * Close the DataFetcher and release all resources (specifically, the ForwardIndexReaderContext off-heap buffers). + */ + @Override + public void close() { + for (ColumnValueReader columnValueReader : _columnValueReaderMap.values()) { + columnValueReader.close(); Review Comment: Fix the indentation ########## pinot-core/src/main/java/org/apache/pinot/core/operator/dociditerators/OrDocIdIterator.java: ########## @@ -117,6 +117,11 @@ private void removeExhaustedIterators() { int i = 0; while (i < _numNotExhaustedIterators) { if (_nextDocIds[i] == Constants.EOF) { + // Close the exhausted iterator + if (_docIdIterators[i] instanceof ScanBasedDocIdIterator) { Review Comment: No need for the check ########## pinot-core/src/main/java/org/apache/pinot/core/operator/dociditerators/AndDocIdIterator.java: ########## @@ -71,4 +72,12 @@ public int advance(int targetDocId) { _nextDocId = targetDocId; return next(); } + + private void closeIterators() { + for (BlockDocIdIterator it : _docIdIterators) { + if (it instanceof ScanBasedDocIdIterator) { + ((ScanBasedDocIdIterator) it).close(); + } Review Comment: No need to do instanceof check ########## pinot-core/src/main/java/org/apache/pinot/core/operator/dociditerators/MVScanDocIdIterator.java: ########## @@ -251,4 +251,11 @@ public boolean doesValueMatch(int docId) { return _predicateEvaluator.applyMV(_buffer, length); } } + + @Override + public void close() { + if (_readerContext != null) { + _readerContext.close(); Review Comment: Does it work if it is closed multiple times? -- 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