|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.relation.accesspath.BlockingBuffer.BlockingIterator
protected class BlockingBuffer.BlockingIterator
An inner class that reads from the buffer. This is not thread-safe - it
makes no attempt to be atomic in its operations in hasNext() or
next().
| Method Summary | |
|---|---|
void |
close()
Notes that the iterator is closed and hence may no longer be read. |
boolean |
hasNext()
Return true iff there is at least one element that can
be visited (blocking). |
boolean |
hasNext(long timeout,
TimeUnit unit)
Return true iff there is at least one element that can be
visited. |
boolean |
isExhausted()
Return true iff this iterator will not visit any more
elements (non-blocking). |
E |
next()
Return the next element. |
E |
next(long timeout,
TimeUnit unit)
Waits up to the timeout to return the next element. |
void |
remove()
The operation is not supported. |
String |
toString()
Safe non-blocking representation of the iterator state. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public String toString()
toString in class Objectpublic void close()
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.
close in interface IAsynchronousIterator<E>close in interface ICloseableIterator<E>BlockingBuffer.iterator()public boolean isExhausted()
IAsynchronousIteratortrue iff this iterator will not visit any more
elements (non-blocking).
isExhausted in interface IAsynchronousIterator<E>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.public boolean hasNext()
true iff there is at least one element that can
be visited (blocking). If the buffer is empty then this will block
until: (a) an element appears in the buffer; or (b) the buffer is
BlockingBuffer.close()ed.
hasNext in interface Iterator<E>
public boolean hasNext(long timeout,
TimeUnit unit)
throws InterruptedException
IAsynchronousIteratortrue iff there is at least one element that can be
visited. If the buffer is empty then this will block until: (a) an
element appears in the buffer; (b) the buffer is
BlockingBuffer.close()ed; or (c) the timeout expires.
Note that a false return DOES NOT signify that the iterator
is exhausted. However, if you specify an infinite timeout using
Long.MAX_VALUE TimeUnit.SECONDS then you MAY safely
interpret a false return as an indication that the iterator
is exhausted.
hasNext in interface IAsynchronousIterator<E>timeout - The length of time that the method may block awaiting an
element to appear.unit - The units in which the timeout is expressed.
true iff there is an element available.
InterruptedException - if the current thread is interrupted while waiting another
element.
public E next(long timeout,
TimeUnit unit)
throws InterruptedException
IAsynchronousIterator
next in interface IAsynchronousIterator<E>timeout - The timeout (overrides the chunkTimeout specified to
the BlockingBuffer ctor).unit - The unit in which the timeout is expressed.
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).
InterruptedException - if the current thread is interrupted while waiting for
another element.public E next()
next in interface Iterator<E>public void remove()
remove in interface Iterator<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||