it.unimi.di.mg4j.search
Class AbstractDocumentIterator

java.lang.Object
  extended by it.unimi.di.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 the DocumentIterator.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 when curr is -1 or DocumentIterator.END_OF_LIST. You just need to call ensureOnADocument().


Field Summary
protected  int curr
          The current document of the iterator.
protected  double weight
          The weight of this iterator.
 
Fields inherited from interface it.unimi.di.mg4j.search.DocumentIterator
END_OF_LIST
 
Constructor Summary
AbstractDocumentIterator()
           
 
Method Summary
 int 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.mg4j.search.DocumentIterator
accept, acceptOnTruePaths, dispose, indices, intervalIterator, intervalIterator, intervalIterators, nextDocument, skipTo
 

Field Detail

curr

protected int curr
The current document of the iterator.

See Also:
AbstractDocumentIterator

weight

protected double weight
The weight of this iterator.

Constructor Detail

AbstractDocumentIterator

public AbstractDocumentIterator()
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 interface DocumentIterator
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 interface DocumentIterator
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 interface DocumentIterator
Parameters:
weight - the weight of this index iterator.
Returns:
this document iterator.

ensureOnADocument

protected final void ensureOnADocument()

document

public int document()
Returns the current document.

Specified by:
document in interface DocumentIterator
Returns:
curr.