Package org.terrier.structures.postings
Class ORIterablePosting
- java.lang.Object
-
- org.terrier.structures.postings.IterablePostingImpl
-
- org.terrier.structures.postings.ORIterablePosting
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,IterablePosting,Posting
- Direct Known Subclasses:
BlockORIterablePosting,FieldORIterablePosting
public class ORIterablePosting extends IterablePostingImpl
An IterablePosting that combines more than one IterablePosting into a single IterablePosting. By doing so, multiple term's posting lists can appear as a singe posting list.- Since:
- 3.5
- Author:
- Craig Macdonald
- See Also:
FieldORIterablePosting,BlockORIterablePosting,BlockFieldORIterablePosting
-
-
Field Summary
-
Fields inherited from interface org.terrier.structures.postings.IterablePosting
END_OF_LIST, EOL
-
-
Constructor Summary
Constructors Constructor Description ORIterablePosting(IterablePosting[] ips)Create a Basic ORIterablePosting from the specified postings
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddPosting(Posting p)WritablePostingasWritablePosting()Copy this posting to one free of an iterator.voidclose()booleanendOfPostings()Status method to see if this posting list iterator has been finished.protected voidfirstPosting(Posting p)intgetDocumentLength()Return the length of the document of the current posting in tokens.intgetFrequency()Return the frequency of the term in the current document, in tokens.intgetId()Return the id of the current posting.static ORIterablePostingmergePostings(IterablePosting[] ips)Factory method to create an appropriate ORIterablePosting from the specified IterablePostings.intnext()Move this iterator to the next posting.intnext(int target)This implementation of next(int) which uses next()
-
-
-
Constructor Detail
-
ORIterablePosting
public ORIterablePosting(IterablePosting[] ips) throws java.io.IOException
Create a Basic ORIterablePosting from the specified postings- Throws:
java.io.IOException
-
-
Method Detail
-
mergePostings
public static ORIterablePosting mergePostings(IterablePosting[] ips) throws java.io.IOException
Factory method to create an appropriate ORIterablePosting from the specified IterablePostings. Four types of ORIterablePosting maybe returned, based on the lowest common denominator type of the specified IterablePosting classes:- BlockFieldORIterablePosting - if the all posting lists are both a BlockPosting and FieldPosting
- BlockORIterablePosting - if the all posting lists are a BlockPosting but not all a FieldPosting
- FieldORIterablePosting - if the all posting lists are a FieldPosting but not all a BlockPosing
- ORIterablePosting - otherwise
- 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.
-
firstPosting
protected void firstPosting(Posting p)
-
addPosting
protected void addPosting(Posting p)
-
next
public int next() throws java.io.IOExceptionMove this iterator to the next posting.- Returns:
- id of next posting, or EOL if end of posting list.
- Throws:
java.io.IOException
-
next
public int next(int target) throws java.io.IOExceptionDescription copied from class:IterablePostingImplThis implementation of next(int) which uses next()- Specified by:
nextin interfaceIterablePosting- Overrides:
nextin classIterablePostingImpl- Parameters:
target- id of the posting to find in this posting list.- Returns:
- id of the posting found, or EOL if end of posting list is reached.
- 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
-
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.
-
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.
-
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.
-
close
public void close() throws java.io.IOException- Throws:
java.io.IOException
-
-