com.sun.labs.minion.indexer.postings
Class DFOPostings.DFOIterator

java.lang.Object
  extended by com.sun.labs.minion.indexer.postings.DFOPostings.DFOIterator
All Implemented Interfaces:
FieldedPostingsIterator, PosPostingsIterator, PostingsIterator
Enclosing class:
DFOPostings

public class DFOPostings.DFOIterator
extends java.lang.Object
implements PosPostingsIterator, FieldedPostingsIterator


Field Summary
protected  boolean allFields
          Whether we're doing all of the fields.
protected  int cb
          The current block in the skip table where we're processing data.
protected  int curr
          The current ID.
protected  int currOff
          The current offset.
protected  boolean done
          Whether we've finished the entry.
protected  int field
          The ID of a field decoded, if this is the only position in a document.
protected  int[] fields
          The field data for the current ID.
protected  boolean fieldsDecoded
          Whether we've decoded the field information for the current ID.
protected  float[] fieldWeights
          Field weights for the current ID.
protected  int freq
          The frequency for the current ID.
protected  float[] mult
          A set of field multipliers to apply.
protected  int nFields
          The number of fields in the current ID.
protected  boolean positionsDecoded
          Whether we've decoded the position information for the current ID.
protected  int posn
          The position that an ID was found, if this is the only position in a document.
protected  int[][] posns
          The position data.
protected  ReadableBuffer rdfo
          Our postings as a readable buffer.
protected  ReadableBuffer rfnp
           
protected  int[] searchFields
          The fields for which we're supposed to return postings.
protected  WeightingComponents wc
           
protected  WeightingFunction wf
          A weighting function to use for the frequencies.
 
Constructor Summary
DFOPostings.DFOIterator(PostingsIteratorFeatures features)
          Creates a postings iterator for this postings type.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this postings iterator to another one.
 void decodeFields()
          Decodes the field information, leaving the pointer in the buffer at the position information.
 boolean equals(java.lang.Object o)
          Tests the equality of this postings iterator and another one.
 boolean findID(int id)
          Finds the given ID 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[] getFieldFreq()
          Gets the frequencies for the fields for the document at the head of the iterator.
 float[] getFieldWeights()
          Gets the weights for the fields for the document at the head of the iterator.
 int getFreq()
          Gets the frequency associated with the current ID.
 int getID()
          Gets the ID that the iterator is currently pointing at.
 int getN()
          Gets the number of IDs in this postings list.
 int[][] getPositions()
          Returns the positions associated with the current ID.
 float getWeight()
          Gets the weight associated with the current ID, as generated by some weighting function.
 boolean next()
          Moves to the next ID in this entry.
protected  boolean next(int pos, int id, int off)
          Finds the next document in the postings entry.
 void reset()
          Resets the iterator to the beginning of the entry.
protected  boolean satisfies()
          Does the data for the current ID satisfy the requirements of our postings iterator features?
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rdfo

protected ReadableBuffer rdfo
Our postings as a readable buffer.


rfnp

protected ReadableBuffer rfnp

done

protected boolean done
Whether we've finished the entry.


curr

protected int curr
The current ID.


freq

protected int freq
The frequency for the current ID.


field

protected int field
The ID of a field decoded, if this is the only position in a document.


posn

protected int posn
The position that an ID was found, if this is the only position in a document.


currOff

protected int currOff
The current offset.


cb

protected int cb
The current block in the skip table where we're processing data. This will help us speed up find operations.


wf

protected WeightingFunction wf
A weighting function to use for the frequencies.


wc

protected WeightingComponents wc

mult

protected float[] mult
A set of field multipliers to apply.


searchFields

protected int[] searchFields
The fields for which we're supposed to return postings.


allFields

protected boolean allFields
Whether we're doing all of the fields.


posns

protected int[][] posns
The position data.


nFields

protected int nFields
The number of fields in the current ID.


fields

protected int[] fields
The field data for the current ID.


fieldWeights

protected float[] fieldWeights
Field weights for the current ID.


fieldsDecoded

protected boolean fieldsDecoded
Whether we've decoded the field information for the current ID.


positionsDecoded

protected boolean positionsDecoded
Whether we've decoded the position information for the current ID.

Constructor Detail

DFOPostings.DFOIterator

public DFOPostings.DFOIterator(PostingsIteratorFeatures features)
Creates a postings iterator for this postings type.

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 in this postings list.

Specified by:
getN in interface PostingsIterator

next

public boolean next()
Moves to the next ID 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 ID that the iterator is at.

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

next

protected boolean next(int pos,
                       int id,
                       int off)
Finds the next document in the postings entry.

Parameters:
id - The ID to use for that document, if we've skipped to this point. If id is less than 0, we will use the ID as it was decoded.
off - The positions offset to use for the next document, if we've skipped to this point. If this is less than 0, we'll use the offset as decoded.
Returns:
true if there is a next ID, false otherwise.

satisfies

protected boolean satisfies()
Does the data for the current ID satisfy the requirements of our postings iterator features?


findID

public boolean findID(int id)
Finds the given ID in the entry we're iterating through, if it exists. If the ID occurs in this entry, the iterator is left in a state where the data for that ID has been decoded. If the ID does not occur in this entry, the iterator is left in a state where the data for the next-highest ID 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:
PostingsIterator.reset()

decodeFields

public void decodeFields()
Decodes the field information, leaving the pointer in the buffer at the position information.


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 ID that the iterator is currently pointing at.

Specified by:
getID in interface PostingsIterator
Returns:
The ID 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 associated with the current ID, as generated by some weighting function.

Specified by:
getWeight in interface PostingsIterator

getFreq

public int getFreq()
Gets the frequency associated with the current ID.

Specified by:
getFreq in interface PostingsIterator

getPositions

public int[][] getPositions()
Returns the positions associated with the current ID. The positions are divided by field.

Specified by:
getPositions in interface PosPostingsIterator
Returns:
A two-dimensional array of int. The contents of the ith element of the array are the positions for the field whose ID is i. The positions stored at element 0 are those positions that are not in any named field.

compareTo

public int compareTo(java.lang.Object o)
Compares this postings iterator to another one. The comparison is based on the current ID that the iterator is pointing at.

Specified by:
compareTo in interface PostingsIterator
Returns:
less than zero, 0, or greater than 0 if the ID at the head of the given postings iterator is less than, equal to, or greater than the ID at the head of this postings iterator, respectively.

equals

public boolean equals(java.lang.Object o)
Tests the equality of this postings iterator and another one.

Overrides:
equals in class java.lang.Object
Returns:
true if the iterators are pointing at the same ID, false otherwise.

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.

getFieldFreq

public int[] getFieldFreq()
Description copied from interface: FieldedPostingsIterator
Gets the frequencies for the fields for the document at the head of the iterator.

Specified by:
getFieldFreq in interface FieldedPostingsIterator

getFieldWeights

public float[] getFieldWeights()
Description copied from interface: FieldedPostingsIterator
Gets the weights for the fields for the document at the head of the iterator.

Specified by:
getFieldWeights in interface FieldedPostingsIterator