Class MergeSortIterator

java.lang.Object
nz.org.riskscape.engine.sort.MergeSortIterator
All Implemented Interfaces:
AutoCloseable, Iterator<nz.org.riskscape.engine.Tuple>, nz.org.riskscape.engine.relation.TupleIterator

public class MergeSortIterator extends Object implements nz.org.riskscape.engine.relation.TupleIterator

Consolidates a list of TupleReaders to always return the min value first as per the Comparator. Will produce spurious results if the underlying TupleReaders aren't producing sorted results via the same Comparator. This allows us to stream a set of sorted relations as though they were a single relation.

  • Field Summary

    Fields inherited from interface nz.org.riskscape.engine.relation.TupleIterator

    EMPTY
  • Constructor Summary

    Constructors
    Constructor
    Description
    MergeSortIterator(Comparator<nz.org.riskscape.engine.Tuple> comparator, nz.org.riskscape.engine.types.Struct type, List<nz.org.riskscape.engine.io.TupleReader> readers, Runnable onClose)
    Create an Iterator over the given list of TupleReaders and using the given Comparator to sort them
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
     
    nz.org.riskscape.engine.Tuple
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    remove

    Methods inherited from interface nz.org.riskscape.engine.relation.TupleIterator

    collect, forEachRemaining
  • Constructor Details

    • MergeSortIterator

      public MergeSortIterator(Comparator<nz.org.riskscape.engine.Tuple> comparator, nz.org.riskscape.engine.types.Struct type, List<nz.org.riskscape.engine.io.TupleReader> readers, Runnable onClose)

      Create an Iterator over the given list of TupleReaders and using the given Comparator to sort them

  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<nz.org.riskscape.engine.Tuple>
    • next

      public nz.org.riskscape.engine.Tuple next()
      Specified by:
      next in interface Iterator<nz.org.riskscape.engine.Tuple>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface nz.org.riskscape.engine.relation.TupleIterator