com.bigdata.relation.accesspath
Class ThickAsynchronousIterator<E>

java.lang.Object
  extended by com.bigdata.relation.accesspath.ThickAsynchronousIterator<E>
All Implemented Interfaces:
IAsynchronousIterator<E>, ICloseableIterator<E>, Serializable, Iterator<E>

public class ThickAsynchronousIterator<E>
extends Object
implements IAsynchronousIterator<E>, Serializable

An IAsynchronousIterator that may be serialized and sent to a remote JVM for consumption. Since all data to be visited is supplied to the ctor, the client will be able consume the data without waiting.

Version:
$Id: ThickAsynchronousIterator.java 5786 2011-12-15 21:46:59Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Constructor Summary
ThickAsynchronousIterator(E[] a)
          Create a thick iterator.
 
Method Summary
 void close()
          Notes that the iterator is closed and hence may no longer be read.
 boolean hasNext()
           
 boolean hasNext(long timeout, TimeUnit unit)
          Delegates to hasNext() since all data are local and timeouts can not occur.
 boolean isExhausted()
          Return true iff this iterator will not visit any more elements (non-blocking).
 E next()
           
 E next(long timeout, TimeUnit unit)
          Delegates to next() since all data are local and timeouts can not occur.
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThickAsynchronousIterator

public ThickAsynchronousIterator(E[] a)
Create a thick iterator.

Parameters:
a - The array of elements to be visited by the iterator (may be empty, but may not be null).
Throws:
IllegalArgumentException - if a is null.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>

next

public E next()
Specified by:
next in interface Iterator<E>

remove

public void remove()
Specified by:
remove in interface Iterator<E>

close

public void close()
Description copied from interface: IAsynchronousIterator
Notes that the iterator is closed and hence may no longer be read. It is safe to invoke this method even if the iterator is closed. However, if the producer is still running then it will be canceled (interrupted) in order to prevent the IBlockingBuffer from filling up and deadlocking. For this reason, IAsynchronousIterator.close() has consequences NOT entailed by ICloseableIterator.

Note: Depending on the semantics of the producer, it MAY choose to treat an interrupt() as normal (but eager) termination. For example, rule execution treats an interrupt() as normal (but eager) termination with the consequence that queries may be safely interrupted once some limit has been satisfied. However, the preferred way to treat LIMIT is using IRule with an IQueryOptions that specifies a LIMIT.

Specified by:
close in interface IAsynchronousIterator<E>
Specified by:
close in interface ICloseableIterator<E>

isExhausted

public boolean isExhausted()
Description copied from interface: IAsynchronousIterator
Return true iff this iterator will not visit any more elements (non-blocking).

Specified by:
isExhausted in interface IAsynchronousIterator<E>
Returns:
true iff the iterator is known to be exhausted without blocking. A false return does NOT imply that the iterator will visit more elements, only that it MIGHT visit more elements.

hasNext

public boolean hasNext(long timeout,
                       TimeUnit unit)
Delegates to hasNext() since all data are local and timeouts can not occur.

Specified by:
hasNext in interface IAsynchronousIterator<E>
Parameters:
timeout - The length of time that the method may block awaiting an element to appear.
unit - The units in which the timeout is expressed.
Returns:
true iff there is an element available.

next

public E next(long timeout,
              TimeUnit unit)
Delegates to next() since all data are local and timeouts can not occur.

Specified by:
next in interface IAsynchronousIterator<E>
Parameters:
timeout - The timeout (overrides the chunkTimeout specified to the BlockingBuffer ctor).
unit - The unit in which the timeout is expressed.
Returns:
The element -or- null iff the timeout was exceeded before IAsynchronousIterator.hasNext(long, TimeUnit) returned true.

In order to have a definitive indication that the iterator is exhausted you need to invoke Iterator.hasNext() without a timeout (blocking) or IAsynchronousIterator.isExhausted() (non-blocking).



Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.