com.sun.labs.minion.classification
Class FeaturePostings.Featurator

java.lang.Object
  extended by com.sun.labs.minion.classification.FeaturePostings.Featurator
All Implemented Interfaces:
PostingsIterator
Enclosing class:
FeaturePostings

public class FeaturePostings.Featurator
extends java.lang.Object
implements PostingsIterator


Field Summary
protected  int curr
          The current ID.
protected  int off
          The current offset.
 
Constructor Summary
FeaturePostings.Featurator(PostingsIteratorFeatures features)
           
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this postings iterator to another one.
 Feature decode(Feature f)
          Decodes the current feature from the info buffer and returns it.
 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 feature in the postings list.
 void reset()
          Resets the iterator to the beginning of the entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curr

protected int curr
The current ID.


off

protected int off
The current offset.

Constructor Detail

FeaturePostings.Featurator

public FeaturePostings.Featurator(PostingsIteratorFeatures features)
Method Detail

getFeatures

public PostingsIteratorFeatures getFeatures()
Description copied from interface: PostingsIterator
Gets the features that were used to create this iterator.

Specified by:
getFeatures in interface PostingsIterator
Returns:
the features used to create the iterator, or null if no features were used.

getN

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

Specified by:
getN in interface PostingsIterator

next

public boolean next()
Moves to the next feature in the postings list.

Specified by:
next in interface PostingsIterator
Returns:
true if there is a next value, false otherwise.

findID

public 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.

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

reset

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

Specified by:
reset in interface PostingsIterator

getID

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

Specified by:
getID in interface PostingsIterator
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

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

Specified by:
getWeight in interface PostingsIterator

getFreq

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

Specified by:
getFreq in interface PostingsIterator

get

public int get(int[] ids)
Description copied from interface: PostingsIterator
Reads a number of IDs into the provided array.

Specified by:
get in interface PostingsIterator

get

public int get(int[] ids,
               int[] freq)
Description copied from interface: PostingsIterator
Reads a number of IDs and frequencies into the provided arrays.

Specified by:
get in interface PostingsIterator
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

public int get(int[] ids,
               float[] weights)
Description copied from interface: PostingsIterator
Reads a number of IDs and the associated weights into the provided arrays.

Specified by:
get in interface PostingsIterator
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.

compareTo

public 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.

Specified by:
compareTo in interface PostingsIterator

decode

public Feature decode(Feature f)
Decodes the current feature from the info buffer and returns it.

Parameters:
f - the feature into which we'll decode
Returns:
the decoded feature.