Package nz.org.riskscape.engine.sort
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 TupleReader
s to always return the min value first as per the Comparator
.
Will produce spurious results if the underlying TupleReader
s 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
ConstructorDescriptionMergeSortIterator
(Comparator<nz.org.riskscape.engine.Tuple> comparator, nz.org.riskscape.engine.types.Struct type, List<nz.org.riskscape.engine.io.TupleReader> readers, Runnable onClose) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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 ofTupleReader
s and using the givenComparator
to sort them
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
public nz.org.riskscape.engine.Tuple next() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacenz.org.riskscape.engine.relation.TupleIterator
-