public interface PostingsList extends Writable
Interface representing a postings list, which contains a list of individual postings. The ordering of the postings depends on the concrete implementation. Postings lists may or may not store positional information.
Note that there are subtle but important differences between:
size()
, which returns the number of postings that have been
added to this list (i.e., intermediate state).getNumberOfPostings()
and setNumberOfPostings(int)
,
which return and set the number of postings that will ultimately be added to
this list (i.e., final state). For many encoding schemes, this is required to
be known in advance (i.e., before any postings are added to the list).getDf()
, which returns the document frequency of the term
associated with this postings list. In a large collection with many document
partition, this returns the global document frequency (whereas the previous
two methods deal with this specific partition). In a collection with
only a single partition, this is exactly the same value as
getNumberOfPostings()
Modifier and Type | Method and Description |
---|---|
void |
add(int docno,
short score,
TermPositions pos)
Adds a posting to this postings list.
|
void |
clear()
Clears this postings list.
|
long |
getCf()
Returns the collection frequency of the term associated with this
postings list.
|
int |
getCollectionDocumentCount()
Returns the number of documents in this collection.
|
int |
getDf()
Returns the document frequency of the term associated with this postings
list.
|
int |
getNumberOfPostings()
Returns the number of postings that will be added to this list.
|
PostingsReader |
getPostingsReader()
Returns the
PostingsReader associated with this postings list. |
byte[] |
getRawBytes()
Returns the raw byte array representation of this postings list.
|
byte[] |
serialize() |
void |
setCf(long cf) |
void |
setCollectionDocumentCount(int docs)
Sets the number of documents in this collection.
|
void |
setDf(int df) |
void |
setNumberOfPostings(int n)
Sets the number of postings that will be added to this list.
|
int |
size()
Returns the number of postings that have been added to this postings
list.
|
readFields, write
void add(int docno, short score, TermPositions pos)
docno
- docno of the postingscore
- score of the postingpos
- positional information (optional)void clear()
long getCf()
int getCollectionDocumentCount()
int getDf()
getNumberOfPostings()
because of document partitioning for large collections. In these cases,
this method should return the global document frequency, whereas
getNumberOfPostings()
should return the document frequency in
this partition. In a collection with only a single partition, this
is exactly the same value as getNumberOfPostings()
. This method
is not meaningful for impact-sorted indexes.int getNumberOfPostings()
setNumberOfPostings(int)
.
Note that under most circumstances this method will return a different
value than size()
, which returns the number of postings that
have already been added.PostingsReader getPostingsReader()
PostingsReader
associated with this postings list.byte[] getRawBytes()
byte[] serialize() throws IOException
IOException
void setCf(long cf)
void setCollectionDocumentCount(int docs)
void setDf(int df)
void setNumberOfPostings(int n)
int size()
getNumberOfPostings()
, which returns the
number of postings that will eventually be added (required for certain
encoding schemes).