Class AbstractCompositeDocumentIterator
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.AbstractDocumentIterator
-
- it.unimi.di.big.mg4j.search.AbstractIntervalDocumentIterator
-
- it.unimi.di.big.mg4j.search.AbstractCompositeDocumentIterator
-
- All Implemented Interfaces:
DocumentIterator
- Direct Known Subclasses:
AbstractIntersectionDocumentIterator,AbstractUnionDocumentIterator
public abstract class AbstractCompositeDocumentIterator extends AbstractIntervalDocumentIterator implements DocumentIterator
An abstract iterator on documents based on a list of component iterators.The AbstractCompositeDocumentIterator(Index, Object, DocumentIterator...) caches into
documentIteratorthe 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)andacceptOnTruePaths(DocumentIteratorVisitor)with a series of recursive calls on all component iterator. If you desire a different behaviour foracceptOnTruePaths(DocumentIteratorVisitor)(see, e.g.,AbstractUnionDocumentIterator, please override it.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractCompositeDocumentIterator.AbstractCompositeIndexIntervalIteratorAn abstractIndexIterator-based interval iterator.protected static classAbstractCompositeDocumentIterator.AbstractCompositeIntervalIteratorAn abstract interval iterator.
-
Field Summary
Fields Modifier and Type Field Description DocumentIterator[]documentIteratorThe component document iterators.IndexIterator[]indexIteratorA cached copy ofdocumentIterator, if all underlying iterators are index iterators;null, otherwise.protected intindexIteratorsWithoutPositionsIfindexIteratoris notnull, the number of index iterators without positions.intnThe number of component iterators.-
Fields inherited from class it.unimi.di.big.mg4j.search.AbstractIntervalDocumentIterator
currentIterators, indices, intervalIterators, soleIndex, soleIntervalIterator, unmodifiableCurrentIterators
-
Fields inherited from class it.unimi.di.big.mg4j.search.AbstractDocumentIterator
curr, weight
-
Fields inherited from interface it.unimi.di.big.mg4j.search.DocumentIterator
END_OF_LIST
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCompositeDocumentIterator(Index index, Object arg, DocumentIterator... documentIterator)Creates a new composite document iterator using a given list of component document iterators and a specified index.protectedAbstractCompositeDocumentIterator(DocumentIterator... documentIterator)Creates a new composite document iterator using a given list of component document iterators.
-
Method Summary
Modifier and Type Method Description <T> Taccept(DocumentIteratorVisitor<T> visitor)Accepts a visitor.<T> TacceptOnTruePaths(DocumentIteratorVisitor<T> visitor)Accepts a visitor after a call toDocumentIterator.nextDocument(), limiting recursion to true paths.voiddispose()Disposes this document iterator, releasing all resources.StringtoString()-
Methods inherited from class it.unimi.di.big.mg4j.search.AbstractIntervalDocumentIterator
allIndexIterators, getIntervalIterator, indices, indices
-
Methods inherited from class it.unimi.di.big.mg4j.search.AbstractDocumentIterator
document, ensureOnADocument, mayHaveNext, weight, weight
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.search.DocumentIterator
document, indices, intervalIterator, intervalIterator, intervalIterators, mayHaveNext, nextDocument, skipTo, weight, weight
-
-
-
-
Field Detail
-
n
public final int n
The number of component iterators.
-
documentIterator
public final DocumentIterator[] documentIterator
The component document iterators.
-
indexIterator
public final IndexIterator[] indexIterator
A cached copy ofdocumentIterator, if all underlying iterators are index iterators;null, otherwise.
-
indexIteratorsWithoutPositions
protected int indexIteratorsWithoutPositions
IfindexIteratoris notnull, the number of index iterators without positions.
-
-
Constructor Detail
-
AbstractCompositeDocumentIterator
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.- Parameters:
index- an index that will constitute the only index for which this iterator will return intervals, ornullto 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 toAbstractIntervalDocumentIterator.getIntervalIterator(Index, int, boolean, Object).documentIterator- the component iterators.
-
AbstractCompositeDocumentIterator
protected AbstractCompositeDocumentIterator(DocumentIterator... documentIterator)
Creates a new composite document iterator using a given list of component document iterators.- Parameters:
documentIterator- the component iterators.
-
-
Method Detail
-
accept
public <T> T accept(DocumentIteratorVisitor<T> visitor) throws IOException
Description copied from interface:DocumentIteratorAccepts a visitor.A document iterator is usually structured as composite, with operators as internal nodes and
IndexIterators as leaves. This method implements the visitor pattern.- Specified by:
acceptin interfaceDocumentIterator- Parameters:
visitor- the visitor.- Returns:
- an object resulting from the visit, or
nullif the visit was interrupted. - Throws:
IOException
-
acceptOnTruePaths
public <T> T acceptOnTruePaths(DocumentIteratorVisitor<T> visitor) throws IOException
Description copied from interface:DocumentIteratorAccepts a visitor after a call toDocumentIterator.nextDocument(), limiting recursion to true paths.After a call to
DocumentIterator.nextDocument(), a document iterator is positioned over a document. This call is equivalent toDocumentIterator.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.- Specified by:
acceptOnTruePathsin interfaceDocumentIterator- Parameters:
visitor- the visitor.- Returns:
- an object resulting from the visit, or
nullif the visit was interrupted. - Throws:
IOException- See Also:
DocumentIterator.accept(DocumentIteratorVisitor),CounterCollectionVisitor
-
dispose
public void dispose() throws IOExceptionDescription copied from interface:DocumentIteratorDisposes this document iterator, releasing all resources.This 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.
- Specified by:
disposein interfaceDocumentIterator- Throws:
IOException
-
-