com.sun.labs.minion.indexer.entry
Class SinglePostingsEntry

java.lang.Object
  extended by com.sun.labs.minion.indexer.entry.BaseEntry
      extended by com.sun.labs.minion.indexer.entry.SinglePostingsEntry
All Implemented Interfaces:
Entry, IndexEntry, QueryEntry, java.lang.Comparable
Direct Known Subclasses:
DFOEntry, DocKeyEntry, FeatureEntry, IDEntry, IDFreqEntry, IDWEntry

public abstract class SinglePostingsEntry
extends BaseEntry

An abstract base class for those entries that only define a single postings type. This is a convenience class that implements most of the behaviour needed for an entry that can be used at indexing or query time.


Field Summary
protected static java.lang.String logTag
          A tag for the log.
protected  int n
          The number of postings associated with this entry.
protected  long offset
          The offset of the postings in a postings file.
protected  Postings p
          The postings associated with this entry.
protected  int size
          The size of the postings, in bytes.
static long tsize
           
 
Fields inherited from class com.sun.labs.minion.indexer.entry.BaseEntry
dict, id, name, postIn
 
Constructor Summary
SinglePostingsEntry()
          Creates an entry.
SinglePostingsEntry(java.lang.Object name)
          Creates an entry.
 
Method Summary
 void add(Occurrence o)
          Adds an occurrence at indexing time.
 void append(QueryEntry qe, int start, int[] idMap)
          Appends the postings from another entry onto this one.
protected  void copyData(SinglePostingsEntry e)
          Copies the data from another entry of this type into this entry.
 void decodePostingsInfo(ReadableBuffer b, int pos)
          Decodes the postings information associated with this entry.
 void encodePostingsInfo(WriteableBuffer b)
          Encodes any information associated with the postings onto the given buffer.
 Entry getEntry()
          Gets a new entry that contains a copy of the data in this entry.
 int getMaxFDT()
          Gets the maximum frequency in the postings associated with this entry.
 int getN()
          Gets the number of postings associated with this entry.
 int getNumChannels()
          Returns the number of channels needed to store the postings for this entry type.
protected abstract  Postings getPostings()
          Gets the appropriate postings type for the class.
protected abstract  Postings getPostings(ReadableBuffer input)
          Reads the postings for this class, returning a set of postings useful at query time.
 long getTotalOccurrences()
          Gets the total number of occurrences associated with this entry.
 boolean hasFieldInformation()
          Indicates whether the postings associated with this entry have field information.
 boolean hasPositionInformation()
          Indicates whether the postings associated with this entry have position information.
 PostingsIterator iterator(PostingsIteratorFeatures features)
          Gets an iterator that will iterate through the postings associated with this entry.
 void readPostings()
          Reads the postings data for this entry.
 boolean writePostings(PostingsOutput[] out, int[] idMap)
          Writes the postings associated with this entry to some or all of the given channels.
 
Methods inherited from class com.sun.labs.minion.indexer.entry.BaseEntry
compareTo, getID, getName, getPartition, setDictionary, setID, setName, setPostingsInput, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sun.labs.minion.indexer.entry.Entry
getEntry
 

Field Detail

p

protected Postings p
The postings associated with this entry.


n

protected int n
The number of postings associated with this entry.


size

protected int size
The size of the postings, in bytes.


offset

protected long offset
The offset of the postings in a postings file.


tsize

public static long tsize

logTag

protected static java.lang.String logTag
A tag for the log.

Constructor Detail

SinglePostingsEntry

public SinglePostingsEntry()
Creates an entry.


SinglePostingsEntry

public SinglePostingsEntry(java.lang.Object name)
Creates an entry.

Method Detail

getPostings

protected abstract Postings getPostings()
Gets the appropriate postings type for the class. These postings should be useable for indexing.

Returns:
Postings suitable for use when indexing.

getPostings

protected abstract Postings getPostings(ReadableBuffer input)
Reads the postings for this class, returning a set of postings useful at query time.

Parameters:
input - The buffer containing the postings read from the postings file.
Returns:
The postings for this entry.

getEntry

public Entry getEntry()
Gets a new entry that contains a copy of the data in this entry.

Returns:
a new entry containing a copy of hte data in this entry.
Throws:
java.lang.ClassCastException - if the provided entry is not of type SinglePostingsEntry

copyData

protected void copyData(SinglePostingsEntry e)
Copies the data from another entry of this type into this entry. A convenience method for subclasses.


add

public void add(Occurrence o)
Adds an occurrence at indexing time.

Parameters:
o - The occurrence to add.

getNumChannels

public int getNumChannels()
Returns the number of channels needed to store the postings for this entry type.


writePostings

public boolean writePostings(PostingsOutput[] out,
                             int[] idMap)
                      throws java.io.IOException
Writes the postings associated with this entry to some or all of the given channels.

Parameters:
out - The outputs to which we will write the postings.
idMap - A map from the IDs currently used in the postings to the IDs that should be used when the postings are written to disk. This may be null, in which case no remapping will occur.
Returns:
true if postings were written, false otherwise
Throws:
java.io.IOException - if there is any error writing the postings.

encodePostingsInfo

public void encodePostingsInfo(WriteableBuffer b)
Encodes any information associated with the postings onto the given buffer.

Parameters:
b - The buffer onto which the postings information should be encoded. The buffer will be positioned to the correct spot for the encoding.

append

public void append(QueryEntry qe,
                   int start,
                   int[] idMap)
Appends the postings from another entry onto this one.

Parameters:
qe - The entry that we want to append onto this one.
start - The new starting ID for the partition that the entry was drawn from.
idMap - A map from old IDs in the given postings to new IDs with gaps removed for deleted data. If this is null, then there are no deleted documents.

decodePostingsInfo

public void decodePostingsInfo(ReadableBuffer b,
                               int pos)
Decodes the postings information associated with this entry.

Parameters:
b - The buffer containing the encoded postings information.
pos - The position in b where the postings information can be found.

readPostings

public void readPostings()
                  throws java.io.IOException
Reads the postings data for this entry. This method must load all available postings information, since this will be used at dictionary merge time to append postings from one entry onto another.

Throws:
java.io.IOException - if there is any error reading the postings.

getN

public int getN()
Gets the number of postings associated with this entry. This is used to sort entries by their frequency during query operations.

Returns:
The number of postings associated with this entry.

getTotalOccurrences

public long getTotalOccurrences()
Gets the total number of occurrences associated with this entry. For this base class, this is the same as n.

Returns:
The total number of occurrences associated with this entry.

getMaxFDT

public int getMaxFDT()
Gets the maximum frequency in the postings associated with this entry. For this base class, this is always 1.


hasPositionInformation

public boolean hasPositionInformation()
Description copied from interface: QueryEntry
Indicates whether the postings associated with this entry have position information.


hasFieldInformation

public boolean hasFieldInformation()
Description copied from interface: QueryEntry
Indicates whether the postings associated with this entry have field information.


iterator

public PostingsIterator iterator(PostingsIteratorFeatures features)
Gets an iterator that will iterate through the postings associated with this entry.

Parameters:
features - A set of features that the iterator must support.
Returns:
An iterator for the postings. Returns null if there are no postings.