org.eigenbase.runtime
Class TimeoutQueueTupleIterTest.TickIterator

java.lang.Object
  extended by org.eigenbase.runtime.AbstractTupleIter
      extended by org.eigenbase.runtime.TimeoutQueueTupleIterTest.TickIterator
All Implemented Interfaces:
TupleIter, ClosableAllocation
Enclosing class:
TimeoutQueueTupleIterTest

private static class TimeoutQueueTupleIterTest.TickIterator
extends AbstractTupleIter

Iterator which returns an element from an array on a regular basis.

Every clock tick until the array is exhausted, Iterator.hasNext() returns true, then the following clock tick, Iterator.next() returns an object. If you call a method too early, the method waits until the appropriate time.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eigenbase.runtime.TupleIter
TupleIter.NoDataReason, TupleIter.TimeoutException
 
Field Summary
private  int current
           
private  long startTime
           
private  Object[] values
           
private  boolean verbose
           
 
Fields inherited from interface org.eigenbase.runtime.TupleIter
EMPTY_ITERATOR
 
Constructor Summary
TimeoutQueueTupleIterTest.TickIterator(Object[] values, boolean verbose, long startTime)
           
 
Method Summary
 void closeAllocation()
          Closes this object.
static void demo()
           
 Object fetchNext()
          Returns the next element in the iteration.
 void restart()
          Restarts this iterator, so that a subsequent call to TupleIter.fetchNext() returns the first element in the collection being iterated.
private  void waitUntil(int tick)
           
 
Methods inherited from class org.eigenbase.runtime.AbstractTupleIter
setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verbose

private final boolean verbose

startTime

private final long startTime

current

private int current

values

private final Object[] values
Constructor Detail

TimeoutQueueTupleIterTest.TickIterator

TimeoutQueueTupleIterTest.TickIterator(Object[] values,
                                       boolean verbose,
                                       long startTime)
Method Detail

waitUntil

private void waitUntil(int tick)

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.


demo

public static void demo()