Class MergeIterator<E>
java.lang.Object
org.apache.flink.runtime.operators.sort.MergeIterator<E>
- All Implemented Interfaces:
org.apache.flink.util.MutableObjectIterator<E>
public class MergeIterator<E>
extends Object
implements org.apache.flink.util.MutableObjectIterator<E>
An iterator that returns a sorted merge of the sequences of elements from a set of iterators,
assuming those sequences are ordered themselves. The iterators to be merged are kept internally
as a heap, making each access to the next smallest element logarithmic in complexity, with
respect to the number of streams to be merged. The order among the elements is established using
the methods from the
TypeComparator class, specifically TypeComparator.setReference(Object) and TypeComparator.compareToReference(TypeComparator).-
Constructor Summary
ConstructorsConstructorDescriptionMergeIterator(List<org.apache.flink.util.MutableObjectIterator<E>> iterators, org.apache.flink.api.common.typeutils.TypeComparator<E> comparator) -
Method Summary
Modifier and TypeMethodDescriptionnext()Gets the next smallest element, with respect to the definition of order implied by theTypeSerializerprovided to this iterator.Gets the next smallest element, with respect to the definition of order implied by theTypeSerializerprovided to this iterator.
-
Constructor Details
-
MergeIterator
public MergeIterator(List<org.apache.flink.util.MutableObjectIterator<E>> iterators, org.apache.flink.api.common.typeutils.TypeComparator<E> comparator) throws IOException - Parameters:
iterators-comparator-- Throws:
IOException
-
-
Method Details
-
next
Gets the next smallest element, with respect to the definition of order implied by theTypeSerializerprovided to this iterator.- Specified by:
nextin interfaceorg.apache.flink.util.MutableObjectIterator<E>- Parameters:
reuse- Object that may be reused.- Returns:
- The next element if the iterator has another element, null otherwise.
- Throws:
IOException- See Also:
-
MutableObjectIterator.next(java.lang.Object)
-
next
Gets the next smallest element, with respect to the definition of order implied by theTypeSerializerprovided to this iterator.- Specified by:
nextin interfaceorg.apache.flink.util.MutableObjectIterator<E>- Returns:
- The next element if the iterator has another element, null otherwise.
- Throws:
IOException- See Also:
-
MutableObjectIterator.next()
-