it.unimi.dsi.mg4j.search.score
Class AbstractScorer

java.lang.Object
  extended by it.unimi.dsi.fastutil.ints.AbstractIntIterator
      extended by it.unimi.dsi.mg4j.search.score.AbstractScorer
All Implemented Interfaces:
IntIterator, FlyweightPrototype<Scorer>, Scorer, Iterator<Integer>
Direct Known Subclasses:
AbstractIndexScorer, ConstantScorer, DecreasingDocumentRankScorer, DocumentRankScorer

public abstract class AbstractScorer
extends AbstractIntIterator
implements Scorer

An abstract implementation of Scorer. It provides internal caching of the underlying document iterator during wrapping, and a complete implementation of the IntIterator methods by delegation to the underlying document iterator (implementing subclasses that do not alter this behaviour should implement DelegatingScorer). The setWeights(Reference2DoubleMap) method simply returns false.


Field Summary
protected  DocumentIterator documentIterator
          The current document iterator.
 
Constructor Summary
AbstractScorer()
           
 
Method Summary
 Reference2DoubleMap<Index> getWeights()
          Returns an empty map.
 boolean hasNext()
           
 int nextDocument()
          Returns the next document provided by this scorer, or -1 if no more documents are available.
 int nextInt()
          Deprecated. 
 boolean setWeights(Reference2DoubleMap<Index> index2Weight)
          Returns false.
 int skip(int n)
           
 void wrap(DocumentIterator documentIterator)
          Wraps the given document iterator.
 
Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntIterator
next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.mg4j.search.score.Scorer
copy, score, score, usesIntervals
 
Methods inherited from interface java.util.Iterator
next, remove
 

Field Detail

documentIterator

protected DocumentIterator documentIterator
The current document iterator.

Constructor Detail

AbstractScorer

public AbstractScorer()
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 interface Scorer
Parameters:
documentIterator - the document iterator that will be used in subsequent calls to Scorer.score() and Scorer.score(Index).
Throws:
IOException

setWeights

public boolean setWeights(Reference2DoubleMap<Index> index2Weight)
Returns false.

Specified by:
setWeights in interface Scorer
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 interface Scorer
Returns:
a copy of the weight map of this scorer.

nextInt

@Deprecated
public int nextInt()
Deprecated. 

Description copied from interface: Scorer
Returns the next document.

Specified by:
nextInt in interface IntIterator
Specified by:
nextInt in interface Scorer
Overrides:
nextInt in class AbstractIntIterator
See Also:
Scorer.nextDocument()

nextDocument

public int 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 interface Scorer
Returns:
the next document, or -1 if no more documents are available.
Throws:
IOException

skip

public int skip(int n)
Specified by:
skip in interface IntIterator
Overrides:
skip in class AbstractIntIterator

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Integer>