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 theTypeComparatorclass, specificallyTypeComparator.setReference(Object)andTypeComparator.compareToReference(TypeComparator).
-
-
Constructor Summary
Constructors Constructor Description MergeIterator(List<org.apache.flink.util.MutableObjectIterator<E>> iterators, org.apache.flink.api.common.typeutils.TypeComparator<E> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Enext()Gets the next smallest element, with respect to the definition of order implied by theTypeSerializerprovided to this iterator.Enext(E reuse)Gets the next smallest element, with respect to the definition of order implied by theTypeSerializerprovided to this iterator.
-
-
-
Constructor Detail
-
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 Detail
-
next
public E next(E reuse) throws IOException
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
public E next() throws IOException
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()
-
-