Package org.terrier.realtime.memory
Class MemoryIterablePosting
- java.lang.Object
-
- org.terrier.structures.postings.IterablePostingImpl
-
- org.terrier.realtime.memory.MemoryIterablePosting
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,IterablePosting
,Posting
- Direct Known Subclasses:
MemoryFieldsIterablePosting
public class MemoryIterablePosting extends IterablePostingImpl
A postings list implementation held fully in memory.- Since:
- 4.0
- Author:
- Richard McCreadie, Stuart Mackie
-
-
Field Summary
Fields Modifier and Type Field Description protected DocumentIndex
doi
protected int
id
protected int
index
protected gnu.trove.TIntArrayList
pl_doc
-
Fields inherited from interface org.terrier.structures.postings.IterablePosting
END_OF_LIST, EOL
-
-
Constructor Summary
Constructors Constructor Description MemoryIterablePosting(DocumentIndex doi, gnu.trove.TIntArrayList pl_doc, gnu.trove.TIntArrayList pl_freq)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WritablePosting
asWritablePosting()
Copy this posting to one free of an iterator.void
close()
boolean
endOfPostings()
Status method to see if this posting list iterator has been finished.int
getDocumentLength()
Return the length of the document of the current posting in tokens.int
getFrequency()
Return the frequency of the term in the current document, in tokens.int
getId()
Return the id of the current posting.int
next()
Move this iterator to the next posting.-
Methods inherited from class org.terrier.structures.postings.IterablePostingImpl
next
-
-
-
-
Field Detail
-
index
protected int index
-
id
protected int id
-
doi
protected DocumentIndex doi
-
pl_doc
protected gnu.trove.TIntArrayList pl_doc
-
-
Constructor Detail
-
MemoryIterablePosting
public MemoryIterablePosting(DocumentIndex doi, gnu.trove.TIntArrayList pl_doc, gnu.trove.TIntArrayList pl_freq)
Constructor.
-
-
Method Detail
-
getFrequency
public int getFrequency()
Return the frequency of the term in the current document, in tokens.- Returns:
- frequency of the term in the current document, in tokens.
-
getDocumentLength
public int getDocumentLength()
Return the length of the document of the current posting in tokens. Usually uses the DocumentIndex, may do otherwise if document length statistics are in posting list.- Returns:
- length of the document of the current posting in tokens.
-
getId
public 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.- Returns:
- id of the posting.
-
next
public int next() throws java.io.IOException
Move this iterator to the next posting.- Returns:
- id of next posting, or EOL if end of posting list.
- Throws:
java.io.IOException
-
endOfPostings
public boolean endOfPostings()
Status method to see if this posting list iterator has been finished.- Returns:
- true if
IterablePosting.next()
orIterablePosting.next(int)
would return EOL or have returned EOL.
-
close
public void close() throws java.io.IOException
- Throws:
java.io.IOException
-
asWritablePosting
public WritablePosting asWritablePosting()
Copy this posting to one free of an iterator. Kind of like a clone.- Returns:
- an identical posting, but which can be manipulated free of this iterator
-
-