Package org.terrier.structures.postings
Class BasicPostingImpl
- java.lang.Object
-
- org.terrier.structures.postings.BasicPostingImpl
-
- All Implemented Interfaces:
java.io.Serializable,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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BasicPostingImpl()Empty constructor - needed for WritableBasicPostingImpl(int docid, int frequency)Constructor that sets both id and frequency
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WritablePostingasWritablePosting()Copy this posting to one free of an iterator.intgetDocumentLength()Returns 0intgetFrequency()Return the frequency of the term in the current document, in tokens.intgetId()Return the id of the current posting.voidreadFields(java.io.DataInput in)Reads the a single posting (not an iterable posting - use BitPostingIndex for that)voidsetDocumentLength(int l)Set the length of the document of the current posting in tokens.voidsetId(int _id)Set the id of this postingvoidsetTf(int tf)Set the term frequency in the documentjava.lang.StringtoString()Makes a human readable form of this postingvoidwrite(java.io.DataOutput out)Writes the current posting (not an iterable posting - use DirectInvertedOutputStream for that).
-
-
-
Method Detail
-
getId
public final int getId()
Return the id of the current posting. For the inverted index, this is the current docid; for the direct index it corresponds to the current term id.
-
getFrequency
public final int getFrequency()
Return the frequency of the term in the current document, in tokens.- Specified by:
getFrequencyin interfacePosting- Returns:
- frequency of the term in the current document, in tokens.
-
readFields
public void readFields(java.io.DataInput in) throws java.io.IOExceptionReads the a single posting (not an iterable posting - use BitPostingIndex for that)- Specified by:
readFieldsin interfaceorg.apache.hadoop.io.Writable- Throws:
java.io.IOException
-
write
public void write(java.io.DataOutput out) throws java.io.IOExceptionWrites 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:
writein interfaceorg.apache.hadoop.io.Writable- Throws:
java.io.IOException
-
setId
public void setId(int _id)
Set the id of this posting- Specified by:
setIdin interfacePosting- Specified by:
setIdin interfaceWritablePosting
-
getDocumentLength
public int getDocumentLength()
Returns 0- Specified by:
getDocumentLengthin interfacePosting- Returns:
- length of the document of the current posting in tokens.
-
asWritablePosting
public WritablePosting asWritablePosting()
Copy this posting to one free of an iterator. Kind of like a clone.- Specified by:
asWritablePostingin interfacePosting- Returns:
- an identical posting, but which can be manipulated free of this iterator
-
toString
public java.lang.String toString()
Makes a human readable form of this posting- Overrides:
toStringin classjava.lang.Object
-
setDocumentLength
public void setDocumentLength(int l)
Description copied from interface:WritablePostingSet the length of the document of the current posting in tokens.- Specified by:
setDocumentLengthin interfaceWritablePosting- Parameters:
l- length of the document of the current posting in tokens.
-
setTf
public void setTf(int tf)
Set the term frequency in the document- Parameters:
tf-
-
-