Class AbstractScorer
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.score.AbstractScorer
-
- All Implemented Interfaces:
Scorer
,FlyweightPrototype<Scorer>
- Direct Known Subclasses:
AbstractWeightedScorer
,ConstantScorer
,DecreasingDocumentRankScorer
,DocumentRankScorer
public abstract class AbstractScorer extends Object implements Scorer
An abstract implementation ofScorer
. It provides internal caching of the underlying document iterator during wrapping, and anextDocument()
method that delegates to the underlying document iterator (implementing subclasses that do not alter this behaviour should implementDelegatingScorer
). ThesetWeights(Reference2DoubleMap)
method simply returns false.
-
-
Field Summary
Fields Modifier and Type Field Description protected DocumentIterator
documentIterator
The current document iterator.protected IndexIterator[]
indexIterator
In case the current iterator is just made of one or more index iterators.
-
Constructor Summary
Constructors Constructor Description AbstractScorer()
-
Method Summary
Modifier and Type Method Description Reference2DoubleMap<Index>
getWeights()
Returns an empty map.long
nextDocument()
Returns the next document provided by this scorer, or -1 if no more documents are available.boolean
setWeights(Reference2DoubleMap<Index> index2Weight)
Returns false.void
wrap(DocumentIterator documentIterator)
Wraps the given document 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.score.Scorer
copy, score, score, usesIntervals
-
-
-
-
Field Detail
-
documentIterator
protected DocumentIterator documentIterator
The current document iterator.
-
indexIterator
protected IndexIterator[] indexIterator
In case the current iterator is just made of one or more index iterators. This field can be used by implementing subclasses to perform optimized evaluations that do not rely on visitors).
-
-
Method Detail
-
wrap
public void wrap(DocumentIterator documentIterator) throws IOException
Wraps the given document iterator.This method records internally the provided iterator.
- Specified by:
wrap
in interfaceScorer
- Parameters:
documentIterator
- the document iterator that will be used in subsequent calls toScorer.score()
andScorer.score(Index)
.- Throws:
IOException
-
setWeights
public boolean setWeights(Reference2DoubleMap<Index> index2Weight)
Returns false.- Specified by:
setWeights
in interfaceScorer
- Parameters:
index2Weight
- a map from indices to weights.- Returns:
- true if this scorer supports weights.
-
getWeights
public Reference2DoubleMap<Index> getWeights()
Returns an empty map.- Specified by:
getWeights
in interfaceScorer
- Returns:
- a copy of the weight map of this scorer.
-
nextDocument
public long nextDocument() throws IOException
Description copied from interface:Scorer
Returns the next document provided by this scorer, or -1 if no more documents are available.- Specified by:
nextDocument
in interfaceScorer
- Returns:
- the next document, or -1 if no more documents are available.
- Throws:
IOException
-
-