Class MergeIterator<E>
- java.lang.Object
-
- org.apache.flink.runtime.operators.sort.MergeIterator<E>
-
- All Implemented Interfaces:
MutableObjectIterator<E>
public class MergeIterator<E> extends Object implements 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 theTypeComparator
class, specificallyTypeComparator.setReference(Object)
andTypeComparator.compareToReference(TypeComparator)
.
-
-
Constructor Summary
Constructors Constructor Description MergeIterator(List<MutableObjectIterator<E>> iterators, TypeComparator<E> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
next()
Gets the next smallest element, with respect to the definition of order implied by theTypeSerializer
provided to this iterator.E
next(E reuse)
Gets the next smallest element, with respect to the definition of order implied by theTypeSerializer
provided to this iterator.
-
-
-
Constructor Detail
-
MergeIterator
public MergeIterator(List<MutableObjectIterator<E>> iterators, 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 theTypeSerializer
provided to this iterator.- Specified by:
next
in interfaceMutableObjectIterator<E>
- Parameters:
reuse
- Object that may be reused.- Returns:
- The next element if the iterator has another element, null otherwise.
- Throws:
IOException
- Thrown, if a problem occurred in the underlying I/O layer or in the serialization / deserialization logic- 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 theTypeSerializer
provided to this iterator.- Specified by:
next
in interfaceMutableObjectIterator<E>
- Returns:
- The next element if the iterator has another element, null otherwise.
- Throws:
IOException
- Thrown, if a problem occurred in the underlying I/O layer or in the serialization / deserialization logic- See Also:
MutableObjectIterator.next()
-
-