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 WritablePosting
asWritablePosting()
Copy this posting to one free of an iterator.int
getDocumentLength()
Returns 0int
getFrequency()
Return the frequency of the term in the current document, in tokens.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
setDocumentLength(int l)
Set the length of the document of the current posting in tokens.void
setId(int _id)
Set the id of this postingvoid
setTf(int tf)
Set the term frequency in the documentjava.lang.String
toString()
Makes a human readable form of this postingvoid
write(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:
getFrequency
in interfacePosting
- Returns:
- frequency of the term in the current document, 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 interfaceorg.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 interfaceorg.apache.hadoop.io.Writable
- Throws:
java.io.IOException
-
setId
public void setId(int _id)
Set the id of this posting- Specified by:
setId
in interfacePosting
- Specified by:
setId
in interfaceWritablePosting
-
getDocumentLength
public int getDocumentLength()
Returns 0- Specified by:
getDocumentLength
in 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:
asWritablePosting
in 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:
toString
in classjava.lang.Object
-
setDocumentLength
public void setDocumentLength(int l)
Description copied from interface:WritablePosting
Set the length of the document of the current posting in tokens.- Specified by:
setDocumentLength
in 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
-
-
-