public abstract class AbstractCompositeDocumentIterator extends AbstractIntervalDocumentIterator implements DocumentIterator
The AbstractCompositeDocumentIterator(Index, Object, DocumentIterator...) caches
into documentIterator the component iterators, and sets up a number of protected
fields that can be useful to implementors. It also provide abstract member classes that make it
easier to implement interval iterators.
Note that this class implements both accept(DocumentIteratorVisitor)
and acceptOnTruePaths(DocumentIteratorVisitor) with a series of recursive
calls on all component iterator. If you desire a different behaviour
for acceptOnTruePaths(DocumentIteratorVisitor) (see, e.g.,
AbstractUnionDocumentIterator, please override it.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractCompositeDocumentIterator.AbstractCompositeIndexIntervalIterator
An abstract
IndexIterator-based interval iterator. |
protected static class |
AbstractCompositeDocumentIterator.AbstractCompositeIntervalIterator
An abstract interval iterator.
|
| Modifier and Type | Field and Description |
|---|---|
DocumentIterator[] |
documentIterator
The component document iterators.
|
IndexIterator[] |
indexIterator
A cached copy of
documentIterator, if all
underlying iterators are index iterators; null, otherwise. |
protected int |
indexIteratorsWithoutPositions
If
indexIterator is not null, the number of index iterators without positions. |
int |
n
The number of component iterators.
|
currentIterators, indices, intervalIterators, soleIndex, soleIntervalIterator, unmodifiableCurrentIteratorscurr, weightEND_OF_LIST| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCompositeDocumentIterator(DocumentIterator... documentIterator)
Creates a new composite document iterator using a given list of component document iterators.
|
protected |
AbstractCompositeDocumentIterator(Index index,
Object arg,
DocumentIterator... documentIterator)
Creates a new composite document iterator using a given list of component document iterators and
a specified index.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
accept(DocumentIteratorVisitor<T> visitor)
Accepts a visitor.
|
<T> T |
acceptOnTruePaths(DocumentIteratorVisitor<T> visitor)
Accepts a visitor after a call to
DocumentIterator.nextDocument(),
limiting recursion to true paths. |
void |
dispose()
Disposes this document iterator, releasing all resources.
|
String |
toString() |
allIndexIterators, getIntervalIterator, indices, indicesdocument, ensureOnADocument, mayHaveNext, weight, weightclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdocument, indices, intervalIterator, intervalIterator, intervalIterators, mayHaveNext, nextDocument, skipTo, weight, weightpublic final int n
public final DocumentIterator[] documentIterator
public final IndexIterator[] indexIterator
documentIterator, if all
underlying iterators are index iterators; null, otherwise.protected int indexIteratorsWithoutPositions
indexIterator is not null, the number of index iterators without positions.protected AbstractCompositeDocumentIterator(Index index, Object arg, DocumentIterator... documentIterator)
index - an index that will constitute the only index for which this iterator will return intervals,
or null to require the computation of the set of indices as the union of the indices
of all component iterators.arg - an argument that will be passed to AbstractIntervalDocumentIterator.getIntervalIterator(Index, int, boolean, Object).documentIterator - the component iterators.protected AbstractCompositeDocumentIterator(DocumentIterator... documentIterator)
documentIterator - the component iterators.public <T> T accept(DocumentIteratorVisitor<T> visitor) throws IOException
DocumentIteratorA document iterator is usually structured as composite,
with operators as internal nodes and IndexIterators
as leaves. This method implements the visitor pattern.
accept in interface DocumentIteratorvisitor - the visitor.null if the visit was interrupted.IOExceptionpublic <T> T acceptOnTruePaths(DocumentIteratorVisitor<T> visitor) throws IOException
DocumentIteratorDocumentIterator.nextDocument(),
limiting recursion to true paths.
After a call to DocumentIterator.nextDocument(), a document iterator
is positioned over a document. This call is equivalent to DocumentIterator.accept(DocumentIteratorVisitor),
but visits only along true paths.
We define a true path as a path from the root of the composite that passes only through
nodes whose associated subtree is positioned on the same document of the root. Note that OrDocumentIterators
detach exhausted iterators from the composite tree, so true paths define the subtree that is causing
the current document to satisfy the query represented by this document iterator.
For more elaboration, and the main application of this method, see CounterCollectionVisitor.
acceptOnTruePaths in interface DocumentIteratorvisitor - the visitor.null if the visit was interrupted.IOExceptionDocumentIterator.accept(DocumentIteratorVisitor),
CounterCollectionVisitorpublic void dispose()
throws IOException
DocumentIteratorThis method should propagate down to the underlying index iterators, where it should release resources such as open files and network connections. If you're doing your own resource tracking and pooling, then you do not need to call this method.
dispose in interface DocumentIteratorIOException