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

    Constructors
    Constructor
    Description
    MergeIterator(List<org.apache.flink.util.MutableObjectIterator<E>> iterators, org.apache.flink.api.common.typeutils.TypeComparator<E> comparator)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the next smallest element, with respect to the definition of order implied by the TypeSerializer provided to this iterator.
    next(E reuse)
    Gets the next smallest element, with respect to the definition of order implied by the TypeSerializer provided to this iterator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      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()