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

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

public class EmptyAsynchronousIterator<E>
extends EmptyCloseableIterator<E>
implements IAsynchronousIterator<E>

An empty IAsynchronousIterator.

Version:
$Id: EmptyAsynchronousIterator.java 6024 2012-02-13 18:53:58Z thompsonbry $
Author:
Bryan Thompson

Constructor Summary
EmptyAsynchronousIterator()
           
 
Method Summary
 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(long timeout, TimeUnit unit)
          Waits up to the timeout to return the next element.
 
Methods inherited from class com.bigdata.relation.accesspath.EmptyCloseableIterator
close, hasNext, next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bigdata.relation.accesspath.IAsynchronousIterator
close
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

EmptyAsynchronousIterator

public EmptyAsynchronousIterator()
Method Detail

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)
                throws InterruptedException
Description copied from interface: IAsynchronousIterator
Return true 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.

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.
Throws:
InterruptedException - if the current thread is interrupted while waiting another element.

next

public E next(long timeout,
              TimeUnit unit)
       throws InterruptedException
Description copied from interface: IAsynchronousIterator
Waits up to the timeout to return the next element. When the generic type of the elements in the buffer is an array type and there is more than one element available within the specified time, then multiple elements in the buffer MAY be combined into a single element and that element returned to the caller.

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).

Throws:
InterruptedException - if the current thread is interrupted while waiting for another element.


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