Class DocumentalMergedClusterIndexIterator
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.AbstractDocumentIterator
-
- it.unimi.di.big.mg4j.index.cluster.DocumentalMergedClusterDocumentIterator
-
- it.unimi.di.big.mg4j.index.cluster.DocumentalMergedClusterIndexIterator
-
- All Implemented Interfaces:
IndexIterator
,DocumentIterator
public class DocumentalMergedClusterIndexIterator extends DocumentalMergedClusterDocumentIterator implements IndexIterator
An index iterator merging iterators from local indices.- Author:
- Alessandro Arrabito, Sebastiano Vigna
-
-
Field Summary
Fields Modifier and Type Field Description protected long
frequency
The precomputed frequency.protected int
id
The id associated with this index iterator.protected DocumentalMergedCluster
index
The reference index.protected IndexIterator[]
indexIterator
A cached copy of the iterators, to avoid type casts.protected String
term
The term associated with this index iterator.-
Fields inherited from class it.unimi.di.big.mg4j.index.cluster.DocumentalMergedClusterDocumentIterator
currentIterator, documentIterator, globalDocumentPointer, indices, n, queue, strategy, usedIndex
-
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
-
Fields inherited from interface it.unimi.di.big.mg4j.index.IndexIterator
END_OF_POSITIONS
-
-
Constructor Summary
Constructors Constructor Description DocumentalMergedClusterIndexIterator(DocumentalClusterIndexReader indexReader, IndexIterator[] indexIterator, int[] usedIndex)
-
Method Summary
Modifier and Type Method Description <T> T
accept(DocumentIteratorVisitor<T> visitor)
Accepts a visitor.<T> T
acceptOnTruePaths(DocumentIteratorVisitor<T> visitor)
Accepts a visitor after a call toDocumentIterator.nextDocument()
, limiting recursion to true paths.int
count()
Returns the count, that is, the number of occurrences of the term in the current document.long
frequency()
Returns the frequency, that is, the number of documents that will be returned by this iterator.int
id()
Returns the id of this index iterator.DocumentalMergedClusterIndexIterator
id(int id)
Sets the id of this index iterator.Index
index()
Returns the index over which this iterator is built.int
nextPosition()
Returns the next position at which the term appears in the current document.Payload
payload()
Returns the payload, if any, associated with the current document.String
term()
Returns the term whose inverted list is returned by this index iterator.DocumentalMergedClusterIndexIterator
term(CharSequence term)
Sets the term whose inverted list is returned by this index iterator.long
termNumber()
Returns the number of the term whose inverted list is returned by this index iterator.IndexIterator
weight(double weight)
Sets the weight of this index iterator.-
Methods inherited from class it.unimi.di.big.mg4j.index.cluster.DocumentalMergedClusterDocumentIterator
dispose, indices, intervalIterator, intervalIterator, intervalIterators, nextDocument, skipTo
-
Methods inherited from class it.unimi.di.big.mg4j.search.AbstractDocumentIterator
document, ensureOnADocument, mayHaveNext, weight
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.search.DocumentIterator
dispose, document, indices, intervalIterator, intervalIterator, intervalIterators, mayHaveNext, nextDocument, skipTo, weight
-
-
-
-
Field Detail
-
indexIterator
protected final IndexIterator[] indexIterator
A cached copy of the iterators, to avoid type casts.
-
frequency
protected final long frequency
The precomputed frequency.
-
index
protected final DocumentalMergedCluster index
The reference index.
-
term
protected String term
The term associated with this index iterator.
-
id
protected int id
The id associated with this index iterator.
-
-
Constructor Detail
-
DocumentalMergedClusterIndexIterator
public DocumentalMergedClusterIndexIterator(DocumentalClusterIndexReader indexReader, IndexIterator[] indexIterator, int[] usedIndex) throws IOException
- Throws:
IOException
-
-
Method Detail
-
term
public DocumentalMergedClusterIndexIterator term(CharSequence term)
Description copied from interface:IndexIterator
Sets the term whose inverted list is returned by this index iterator.Usually, the term is automatically set by
Index.documents(CharSequence)
or byIndexReader.documents(CharSequence)
, but you can use this method to ensure thatIndexIterator.term()
doesn't throw an exception.- Specified by:
term
in interfaceIndexIterator
- Parameters:
term
- a character sequence (that will be defensively copied) that will be assumed to be the term whose inverted list is returned by this index iterator.- Returns:
- this index iterator.
-
term
public String term()
Description copied from interface:IndexIterator
Returns the term whose inverted list is returned by this index iterator.Usually, the term is automatically set by
IndexReader.documents(CharSequence)
orIndexReader.documents(long)
, but you can supply your own term withIndexIterator.term(CharSequence)
.- Specified by:
term
in interfaceIndexIterator
- Returns:
- the term over which this iterator is built, as a compact mutable string.
- See Also:
IndexIterator.termNumber()
-
id
public DocumentalMergedClusterIndexIterator id(int id)
Description copied from interface:IndexIterator
Sets the id of this index iterator.The id is an integer associated with each index iterator. It has no specific semantics, and can be used differently in different contexts. A typical usage pattern, for instance, is using it to assign a unique number to the index iterators contained in a composite document iterator (say, numbering consecutively the leaves of the composite).
- Specified by:
id
in interfaceIndexIterator
- Parameters:
id
- the new id for this index iterator.- Returns:
- this index iterator.
-
id
public int id()
Description copied from interface:IndexIterator
Returns the id of this index iterator.- Specified by:
id
in interfaceIndexIterator
- Returns:
- the id of this index iterator.
- See Also:
IndexIterator.id(int)
-
index
public Index index()
Description copied from interface:IndexIterator
Returns the index over which this iterator is built.- Specified by:
index
in interfaceIndexIterator
- Returns:
- the index over which this iterator is built.
-
frequency
public long frequency()
Description copied from interface:IndexIterator
Returns the frequency, that is, the number of documents that will be returned by this iterator.- Specified by:
frequency
in interfaceIndexIterator
- Returns:
- the number of documents that will be returned by this iterator.
-
payload
public Payload payload() throws IOException
Description copied from interface:IndexIterator
Returns the payload, if any, associated with the current document.- Specified by:
payload
in interfaceIndexIterator
- Returns:
- the payload associated with the current document.
- Throws:
IOException
-
count
public int count() throws IOException
Description copied from interface:IndexIterator
Returns the count, that is, the number of occurrences of the term in the current document.- Specified by:
count
in interfaceIndexIterator
- Returns:
- the count (number of occurrences) of the term in the current document.
- Throws:
IOException
-
nextPosition
public int nextPosition() throws IOException
Description copied from interface:IndexIterator
Returns the next position at which the term appears in the current document.- Specified by:
nextPosition
in interfaceIndexIterator
- Returns:
- the next position of the current document in which the current term appears,
or
IndexIterator.END_OF_POSITIONS
if there are no more positions. - Throws:
IOException
-
accept
public <T> T accept(DocumentIteratorVisitor<T> visitor) throws IOException
Description copied from interface:DocumentIterator
Accepts a visitor.A document iterator is usually structured as composite, with operators as internal nodes and
IndexIterator
s as leaves. This method implements the visitor pattern.- Specified by:
accept
in interfaceDocumentIterator
- Overrides:
accept
in classDocumentalMergedClusterDocumentIterator
- Parameters:
visitor
- the visitor.- Returns:
- an object resulting from the visit, or
null
if the visit was interrupted. - Throws:
IOException
-
acceptOnTruePaths
public <T> T acceptOnTruePaths(DocumentIteratorVisitor<T> visitor) throws IOException
Description copied from interface:DocumentIterator
Accepts 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
OrDocumentIterator
s 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:
acceptOnTruePaths
in interfaceDocumentIterator
- Overrides:
acceptOnTruePaths
in classDocumentalMergedClusterDocumentIterator
- Parameters:
visitor
- the visitor.- Returns:
- an object resulting from the visit, or
null
if the visit was interrupted. - Throws:
IOException
- See Also:
DocumentIterator.accept(DocumentIteratorVisitor)
,CounterCollectionVisitor
-
termNumber
public long termNumber()
Description copied from interface:IndexIterator
Returns the number of the term whose inverted list is returned by this index iterator.Usually, the term number is automatically set by
IndexReader.documents(CharSequence)
orIndexReader.documents(long)
.- Specified by:
termNumber
in interfaceIndexIterator
- Returns:
- the number of the term over which this iterator is built.
- See Also:
IndexIterator.term()
-
weight
public IndexIterator weight(double weight)
Description copied from interface:DocumentIterator
Sets the weight of this index iterator.- Specified by:
weight
in interfaceDocumentIterator
- Specified by:
weight
in interfaceIndexIterator
- Overrides:
weight
in classAbstractDocumentIterator
- Parameters:
weight
- the weight of this index iterator.- Returns:
- this document iterator.
- See Also:
DocumentIterator.weight(double)
-
-