org.terrier.structures.postings
Class BasicPostingImpl

java.lang.Object
  extended by org.terrier.structures.postings.BasicPostingImpl
All Implemented Interfaces:
org.apache.hadoop.io.Writable, Posting, WritablePosting
Direct Known Subclasses:
BasicIterablePosting, BlockPostingImpl, FieldPostingImpl

public class BasicPostingImpl
extends java.lang.Object
implements WritablePosting

Implementation of a Posting that is non-iterable.

Since:
3.0
Author:
Craig Macdonald

Field Summary
protected  int id
          id of the posting
protected  int tf
          frequency of this posting
 
Constructor Summary
BasicPostingImpl()
          Empty constructor - needed for Writable
BasicPostingImpl(int docid, int frequency)
          Constructor that sets both id and frequency
 
Method Summary
 WritablePosting asWritablePosting()
          Copies this posting to one free of an iterator.
 int getDocumentLength()
          Returns 0
 int getFrequency()
          Return the frequency of the term in the current document
 int getId()
          Return the id of the current posting.
 void readFields(java.io.DataInput in)
          Reads the a single posting (not an iterable posting - use BitPostingIndex for that)
 void setId(int _id)
          Set the id of this posting
 java.lang.String toString()
          Makes a human readable form of this posting
 void write(java.io.DataOutput out)
          Writes the current posting (not an iterable posting - use DirectInvertedOutputStream for that).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected int id
id of the posting


tf

protected int tf
frequency of this posting

Constructor Detail

BasicPostingImpl

public BasicPostingImpl()
Empty constructor - needed for Writable


BasicPostingImpl

public BasicPostingImpl(int docid,
                        int frequency)
Constructor that sets both id and frequency

Method Detail

getId

public int getId()
Return the id of the current posting. For the inverted index, this is the docid; for the direct index it corresponds to the term id

Specified by:
getId in interface Posting
Returns:
id of the posting

getFrequency

public int getFrequency()
Return the frequency of the term in the current document

Specified by:
getFrequency in interface Posting
Returns:
frequency of posting, in tokens

readFields

public void readFields(java.io.DataInput in)
                throws java.io.IOException
Reads the a single posting (not an iterable posting - use BitPostingIndex for that)

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Writes the current posting (not an iterable posting - use DirectInvertedOutputStream for that). Compression using this method is not expected to be comparable to bit-level compression.

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

setId

public void setId(int _id)
Set the id of this posting

Specified by:
setId in interface Posting

getDocumentLength

public int getDocumentLength()
Returns 0

Specified by:
getDocumentLength in interface Posting
Returns:
length of the document of the current posting in tokens.

asWritablePosting

public WritablePosting asWritablePosting()
Copies this posting to one free of an iterator. Kind of like a clone.

Specified by:
asWritablePosting in interface Posting
Returns:
an identical posting, but which can be maniulated free of this iterator

toString

public java.lang.String toString()
Makes a human readable form of this posting

Overrides:
toString in class java.lang.Object


Terrier 3.5. Copyright © 2004-2011 University of Glasgow