Class QueueIteration<E,T extends RuntimeException>
java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E>
org.eclipse.rdf4j.common.iteration.LookAheadIteration<E>
org.eclipse.rdf4j.common.iteration.QueueIteration<E,T>
- All Implemented Interfaces:
AutoCloseable,Iterator<E>,CloseableIteration<E>
- Direct Known Subclasses:
QueueCursor
Makes working with a queue easier by adding the methods
done() and toss(Exception) and after
converting the Exception to the required type using convert(Exception).- Author:
- James Leigh
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedQueueIteration(int capacity) Creates an QueueIteration with the given (fixed) capacity and default access policy.protectedQueueIteration(int capacity, boolean fair) Creates an QueueIteration with the given (fixed) capacity and the specified access policy.protectedQueueIteration(BlockingQueue<E> queue) Creates an QueueIteration with the givenBlockingQueueas its backing queue.
It may not be threadsafe to modify or access the givenBlockingQueuefrom other locations. -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected abstract TConverts an exception from the underlying iteration to an exception of type X.voiddone()Indicates the methodput(Object)will not be called in the queue anymore.Returns the next item in the queue, which may be null, or throws an exception.voidCalled byAbstractCloseableIteration.close()when it is called for the first time.voidAdds another item to the queue, blocking while the queue is full.voidThe next timeLookAheadIteration.next()is called this exception will be thrown.Methods inherited from class org.eclipse.rdf4j.common.iteration.LookAheadIteration
hasNext, next, removeMethods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
streamMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
QueueIteration
protected QueueIteration(int capacity) Creates an QueueIteration with the given (fixed) capacity and default access policy.- Parameters:
capacity- the capacity of this queue
-
QueueIteration
protected QueueIteration(int capacity, boolean fair) Creates an QueueIteration with the given (fixed) capacity and the specified access policy.- Parameters:
capacity- the capacity of this queuefair- if true then queue accesses for threads blocked on insertion or removal, are processed in FIFO order; if false the access order is unspecified.
-
QueueIteration
Creates an QueueIteration with the givenBlockingQueueas its backing queue.
It may not be threadsafe to modify or access the givenBlockingQueuefrom other locations. This method only enables the defaultArrayBlockingQueueto be overridden.- Parameters:
queue- A BlockingQueue that is not used in other locations, but will be used as the backing Queue implementation for this cursor.
-
-
Method Details
-
convert
Converts an exception from the underlying iteration to an exception of type X. -
toss
The next timeLookAheadIteration.next()is called this exception will be thrown. If it is not a QueryEvaluationException or RuntimeException it will be wrapped in a QueryEvaluationException. -
put
Adds another item to the queue, blocking while the queue is full.- Throws:
InterruptedExceptionT extends RuntimeException
-
done
public void done()Indicates the methodput(Object)will not be called in the queue anymore. -
getNextElement
Returns the next item in the queue, which may be null, or throws an exception.- Specified by:
getNextElementin classLookAheadIteration<E>- Returns:
- The next element, or null if no more elements are available.
-
handleClose
public void handleClose()Description copied from class:AbstractCloseableIterationCalled byAbstractCloseableIteration.close()when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.- Specified by:
handleClosein classAbstractCloseableIteration<E>
-
checkException
- Throws:
T extends RuntimeException
-