com.sun.labs.minion.indexer.postings
Interface PostingsIterator

All Known Subinterfaces:
PosPostingsIterator
All Known Implementing Classes:
DFOPostings.DFOIterator, FeaturePostings.Featurator, FieldedTermCacheElement.FTCEIterator, IDFreqPostings.IDFreqIterator, IDPostings.IDIterator, IDWPostings.IDWIterator, TermCacheElement.TCEIterator

public interface PostingsIterator

An interface for an iterator that can be used to step through the a postings file entry. Each class that implements Entry will have to be able to generate an iterator that implements this interface.


Method Summary
 int compareTo(java.lang.Object o)
          Compares this postings iterator to another one.
 boolean findID(int id)
          Finds the given document in the entry we're iterating through, if it exists.
 int get(int[] ids)
          Reads a number of IDs into the provided array.
 int get(int[] ids, float[] weights)
          Reads a number of IDs and the associated weights into the provided arrays.
 int get(int[] ids, int[] freq)
          Reads a number of IDs and frequencies into the provided arrays.
 PostingsIteratorFeatures getFeatures()
          Gets the features that were used to create this iterator.
 int getFreq()
          Gets the frequency of the term in the current document.
 int getID()
          Gets the document sequence number that the iterator is currently pointing at.
 int getN()
          Gets the number of IDs that this iterator will produce.
 float getWeight()
          Gets the weight of the term in the current document, as generated by some weighting function.
 boolean next()
          Moves to the next document in this entry.
 void reset()
          Resets the iterator to the beginning of the entry.
 

Method Detail

getN

int getN()
Gets the number of IDs that this iterator will produce.


get

int get(int[] ids)
Reads a number of IDs into the provided array.


get

int get(int[] ids,
        int[] freq)
Reads a number of IDs and frequencies into the provided arrays.

Parameters:
ids - an array into which IDs will be placed. If possible, the array will be filled.
freq - an array into which frequencies will be placed. If possible, the array will be filled.
Returns:
the number of ids and frequencies read into the array, which may be smaller than the size of the array.

get

int get(int[] ids,
        float[] weights)
Reads a number of IDs and the associated weights into the provided arrays.

Parameters:
ids - an array into which IDs will be placed. If possible, the array will be filled.
weights - an array into which weights will be placed. If possible, the array will be filled.
Returns:
the number of ids and frequencies read into the array, which may be smaller than the size of the array.

next

boolean next()
Moves to the next document in this entry. This method is different than the java.util.Iterator.next() method in that it does not return an object. This would require too much object creation overhead during retrieval, and saves the whole hasNext()/next() function call overhead. You should use the accessor functions for the iterator to find out the actual document, position, etc. that the iterator is at.

Returns:
true if there is a next value, false otherwise.

findID

boolean findID(int id)
Finds the given document in the entry we're iterating through, if it exists. If the document occurs in this entry, the iterator is left in a state where the data for that document has been decoded. If the document does not occur in this entry, the iterator is left in a state where the data for the next-highest document sequence number in this entry has been decoded.

Parameters:
id - The ID that we want to find.
Returns:
true if the ID occurs in this entry, false otherwise.
See Also:
reset()

reset

void reset()
Resets the iterator to the beginning of the entry. Data will not be decoded until the next method is called.


getID

int getID()
Gets the document sequence number that the iterator is currently pointing at.

Returns:
The document sequence number that the iterator is pointing at, or 0 if the iterator has not been advanced yet, or has been exhausted.

getWeight

float getWeight()
Gets the weight of the term in the current document, as generated by some weighting function.


getFreq

int getFreq()
Gets the frequency of the term in the current document.


compareTo

int compareTo(java.lang.Object o)
Compares this postings iterator to another one. Typically this comparison should be based on the ID at the head of the iterator.


getFeatures

PostingsIteratorFeatures getFeatures()
Gets the features that were used to create this iterator.

Returns:
the features used to create the iterator, or null if no features were used.