Class 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

      Constructors 
      Constructor Description
      MergeIterator​(List<org.apache.flink.util.MutableObjectIterator<E>> iterators, org.apache.flink.api.common.typeutils.TypeComparator<E> comparator)  
    • 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 the TypeSerializer provided to this iterator.
        Specified by:
        next in interface org.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 the TypeSerializer provided to this iterator.
        Specified by:
        next in interface org.apache.flink.util.MutableObjectIterator<E>
        Returns:
        The next element if the iterator has another element, null otherwise.
        Throws:
        IOException
        See Also:
        MutableObjectIterator.next()