S
- The generic type of the elements visited by the [S]ource iterator.E
- The generic type of the [E]lements visited by this iterator.public abstract class ChunkedResolvingIterator<E,S> extends Object implements IChunkedOrderedIterator<E>
resolve(Object)
.
Note: This class correctly passes ICloseableIterator.close()
through
to the source iterator.
DEFAULT_CHUNK_SIZE
Constructor and Description |
---|
ChunkedResolvingIterator(IChunkedOrderedIterator<S> src)
Ctor variant when resolving changes the sort order such that the resolved
elements would need to be sorted to put them into a known order.
|
ChunkedResolvingIterator(IChunkedOrderedIterator<S> src,
IKeyOrder<E> keyOrder)
Ctor variant when (a) you KNOW the sort order for the source iterator and
(b) the source elements and the resolved elements have the same natural
sort order (so the sort order is naturally preserved when the elements
are resolved).
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the iterator, releasing any associated resources.
|
IKeyOrder<E> |
getKeyOrder()
The natural order in which elements are being visited.
|
boolean |
hasNext() |
E |
next()
The next element available from the iterator.
|
E[] |
nextChunk()
Return the next "chunk" from the iterator.
|
E[] |
nextChunk(IKeyOrder<E> keyOrder)
Return the next "chunk" of elements.
|
void |
remove()
Removes the last element visited by
IChunkedIterator.next() (optional operation). |
protected abstract E |
resolve(S e)
Resolve an element visited by the source iterator into an element of the
type visitable by this iterator.
|
public ChunkedResolvingIterator(IChunkedOrderedIterator<S> src)
src
- The source iterator.public ChunkedResolvingIterator(IChunkedOrderedIterator<S> src, IKeyOrder<E> keyOrder)
src
- The source iterator.keyOrder
- The sort order for the resolved elements.public IKeyOrder<E> getKeyOrder()
IChunkedOrderedIterator
getKeyOrder
in interface IChunkedOrderedIterator<E>
null
if not known.public E next()
IChunkedIterator
public E[] nextChunk()
IChunkedIterator
nextChunk
in interface IChunkedIterator<E>
public E[] nextChunk(IKeyOrder<E> keyOrder)
IChunkedOrderedIterator
IChunkedOrderedIterator.getKeyOrder()
would return non-null
and the request order corresponds to the value that would be returned by
IChunkedOrderedIterator.getKeyOrder()
then the elements in the next chunk are NOT
sorted. Otherwise the elements in the next chunk are sorted before they
are returned. The size of the chunk is up to the implementation.nextChunk
in interface IChunkedOrderedIterator<E>
keyOrder
- The natural order for the elements in the chunk.public void remove()
IChunkedIterator
IChunkedIterator.next()
(optional operation).
Note: This method is not readily suited for use with IChunkedIterator.nextChunk()
since the latter has already visited everything in the chunk and
IChunkedIterator.remove()
would only remove the last item in the chunk. Normally
you will want to accumulate items to be removed in a buffer and then
submit the buffer to some batch api operation when it overflows.
Alternatively, the IRangeQuery.REMOVEALL
flag may be used with
the source iterator to remove elements from the index as they are
visited.
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<E>
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.