E
- The generic type of the elements visited by the source iterator.F
- The generic type of the elements visited by this iterator (the
resolved elements).S
- The generic type of the application state object.public abstract class AbstractChunkedResolverator<E,F,S> extends Object implements ICloseableIterator<F>
IChunkedIterator
and asynchronously resolves chunks.Modifier and Type | Field and Description |
---|---|
protected S |
state
Application specified state object.
|
Constructor and Description |
---|
AbstractChunkedResolverator(S state,
IChunkedOrderedIterator<E> src,
BlockingBuffer<F[]> buffer) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the iterator, releasing any associated resources.
|
boolean |
hasNext() |
F |
next() |
void |
remove() |
protected abstract F[] |
resolveChunk(E[] chunk)
Resolves the elements in a source chunk, returning a chunk of resolved
elements.
|
AbstractChunkedResolverator<E,F,S> |
start(ExecutorService service)
Creates and runs a task that will consume chunks from the source
iterator, resolve the elements in each chunk, and place the resolved
chunks onto the
BlockingBuffer . |
protected final S state
public AbstractChunkedResolverator(S state, IChunkedOrderedIterator<E> src, BlockingBuffer<F[]> buffer)
state
- Application specified state (optional).src
- The source iterator (will be closed or exhausted when this
iterator is closed).buffer
- The BlockingBuffer
on which the resolved chunks will
be written by the ChunkConsumerTask
and from which
this iterator will read those chunks.public AbstractChunkedResolverator<E,F,S> start(ExecutorService service)
BlockingBuffer
.
You MUST invoke this before consuming results from the iterator.
Implementations SHOULD strengthen the return type.
service
- The service on which the task will be executed.protected abstract F[] resolveChunk(E[] chunk)
Note: This method is invoked by the ChunkConsumerTask
which runs
asynchronously.
chunk
- The next chunk from the source iterator.public boolean hasNext()
hasNext
in interface Iterator<F>
IllegalStateException
- unless start(ExecutorService)
has been invoked.public void remove()
remove
in interface Iterator<F>
UnsupportedOperationException
public void close()
ICloseableIterator
ICloseableIterator.close()
if Iterator.hasNext()
method returns false
to ensure that the iterator is closed
(and its resources release) as soon as it is exhausted.
Note: Implementations that support Iterator.remove()
MUST NOT
eagerly close the iterator when it is exhausted since that would make it
impossible to remove the last visited statement. Instead they MUST wait
for an explicit ICloseableIterator.close()
by the application.
close
in interface ICloseable
close
in interface ICloseableIterator<F>
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.