org.eigenbase.runtime
Class CompoundParallelTupleIter
java.lang.Object
org.eigenbase.runtime.AbstractTupleIter
org.eigenbase.runtime.CompoundParallelTupleIter
- All Implemented Interfaces:
- TupleIter, ClosableAllocation
public class CompoundParallelTupleIter
- extends AbstractTupleIter
CompoundParallelTupleIter
creates one TupleIter out of several.
Unlike its serial counterpart CompoundTupleIter
, it runs all its
inputs in parallel, in separate threads that it spawns. It outputs the next
element available from any of its inputs. Note that the order of output rows
is indeterminate, since it is unpredictable which input will arrive next.
The compound TupleIter is finished when all of its inputs are finished.
The set of input iterators is fixed at construction.
This variant is needed when an input is infinite, since CompoundTupleIter
would hang. Extending this class to preserve order is problematic, given its
low level:
- items Are now synthetic
Object
s.
- Items would have to become things that expose a
Comparable
key value.
- Even if one input lags behind the other provding a
Iterator.next()
value, that missing value might sort before its available
counterparts from the other inputs. There is no basis to decide to wait for
it or not.
- Version:
- $Id: //open/dev/farrago/src/org/eigenbase/runtime/CompoundParallelTupleIter.java#8 $
- Author:
- Marc Berkowitz
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
in
private final TupleIter[] in
endOfData
private final boolean[] endOfData
i
private int i
CompoundParallelTupleIter
public CompoundParallelTupleIter(TupleIter[] tupleIters)
fetchNext
public Object fetchNext()
- Description copied from interface:
TupleIter
- Returns the next element in the iteration. If there is no next value, it
returns a value from the
TupleIter.NoDataReason
enumeration indicating why
no data was returned.
If this method returns TupleIter.NoDataReason.END_OF_DATA
, no further
data will be returned by this iterator unless TupleIter.restart()
is called.
If this method returns TupleIter.NoDataReason.UNDERFLOW
, no data is
currently available, but may be come available in the future. It is
possible for consecutive calls to return UNDERFLOW and then END_OF_DATA.
The object returned by this method may be re-used for each subsequent
call to fetchNext()
. In other words, callers must either
make certain that the returned value is no longer needed or is copied
before any subsequent calls to fetchNext()
.
- Returns:
- the next element in the iteration, or an instance of
TupleIter.NoDataReason
.
restart
public void restart()
- Description copied from interface:
TupleIter
- Restarts this iterator, so that a subsequent call to
TupleIter.fetchNext()
returns the first element in the collection being
iterated.
- Specified by:
restart
in interface TupleIter
- Overrides:
restart
in class AbstractTupleIter
closeAllocation
public void closeAllocation()
- Description copied from interface:
ClosableAllocation
- Closes this object.