Package it.unimi.di.big.mg4j.search
Class AbstractDocumentIterator
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.AbstractDocumentIterator
-
- All Implemented Interfaces:
DocumentIterator
- Direct Known Subclasses:
AbstractIntervalDocumentIterator
,DocumentalConcatenatedClusterDocumentIterator
,DocumentalMergedClusterDocumentIterator
,FalseDocumentIterator
,NotDocumentIterator
,PayloadPredicateDocumentIterator
,TrueDocumentIterator
public abstract class AbstractDocumentIterator extends Object implements DocumentIterator
An abstract iterator on documents that and provides support for theDocumentIterator.weight()
/DocumentIterator.weight(double)
methods.Instances of this class expect implementation to keep track of the current document of the iterator. The special value -1 denotes an iterator that has not still been accessed, and the special value
DocumentIterator.END_OF_LIST
denotes an iterator that has been exhausted.Methods performing actions depending on the last document returned should throw an
IllegalStateException
if called whencurr
is -1 orDocumentIterator.END_OF_LIST
. You just need to callensureOnADocument()
.
-
-
Field Summary
Fields Modifier and Type Field Description protected long
curr
The current document of the iterator.protected double
weight
The weight of this iterator.-
Fields inherited from interface it.unimi.di.big.mg4j.search.DocumentIterator
END_OF_LIST
-
-
Constructor Summary
Constructors Constructor Description AbstractDocumentIterator()
-
Method Summary
Modifier and Type Method Description long
document()
Returns the current document.protected void
ensureOnADocument()
boolean
mayHaveNext()
Returns whether there may be a next document, possibly with false positives.double
weight()
Returns the weight associated with this iterator.DocumentIterator
weight(double weight)
Sets the weight of this index iterator.-
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
accept, acceptOnTruePaths, dispose, indices, intervalIterator, intervalIterator, intervalIterators, nextDocument, skipTo
-
-
-
-
Field Detail
-
curr
protected long curr
The current document of the iterator.- See Also:
AbstractDocumentIterator
-
weight
protected double weight
The weight of this iterator.
-
-
Method Detail
-
mayHaveNext
public boolean mayHaveNext()
Description copied from interface:DocumentIterator
Returns whether there may be a next document, possibly with false positives.- Specified by:
mayHaveNext
in interfaceDocumentIterator
- Returns:
- true there may be a next document; false if certainly there is no next document.
-
weight
public double weight()
Description copied from interface:DocumentIterator
Returns the weight associated with this iterator.The number returned by this method has no fixed semantics: different scorers might choose different interpretations, or even ignore it.
- Specified by:
weight
in interfaceDocumentIterator
- Returns:
- the weight associated with this iterator.
-
weight
public DocumentIterator weight(double weight)
Description copied from interface:DocumentIterator
Sets the weight of this index iterator.- Specified by:
weight
in interfaceDocumentIterator
- Parameters:
weight
- the weight of this index iterator.- Returns:
- this document iterator.
-
ensureOnADocument
protected final void ensureOnADocument()
-
document
public long document()
Returns the current document.- Specified by:
document
in interfaceDocumentIterator
- Returns:
curr
.
-
-