liming30 commented on code in PR #833: URL: https://github.com/apache/incubator-paimon/pull/833#discussion_r1167012611
########## paimon-core/src/main/java/org/apache/paimon/mergetree/compact/SortMergeReader.java: ########## @@ -40,166 +38,90 @@ */ public class SortMergeReader<T> implements RecordReader<T> { - private final List<RecordReader<KeyValue>> nextBatchReaders; private final Comparator<InternalRow> userKeyComparator; private final MergeFunctionWrapper<T> mergeFunctionWrapper; - - private final PriorityQueue<Element> minHeap; - private final List<Element> polled; + private final LoserTree<KeyValue> loserTree; public SortMergeReader( List<RecordReader<KeyValue>> readers, Comparator<InternalRow> userKeyComparator, MergeFunctionWrapper<T> mergeFunctionWrapper) { - this.nextBatchReaders = new ArrayList<>(readers); this.userKeyComparator = userKeyComparator; this.mergeFunctionWrapper = mergeFunctionWrapper; - this.minHeap = - new PriorityQueue<>( + this.loserTree = + new LoserTree<>( + readers, + (e1, e2) -> { + if (e1 == null) { Review Comment: I moved this logic to the constructor of `LoserTree`, which is still used to build a new `Comparator`, to simplify the code implementation for comparison. -- 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...@paimon.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org