Package org.terrier.structures.postings
Class ANDIterablePosting
- java.lang.Object
-
- org.terrier.structures.postings.IterablePostingImpl
-
- org.terrier.structures.postings.ANDIterablePosting
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,IterablePosting
,Posting
- Direct Known Subclasses:
PhraseIterablePosting
,ProximityIterablePosting
public class ANDIterablePosting extends IterablePostingImpl
An instance of IterablePostings that works with passed arrays of ids and frequencies. The document must contain all of the terms in the query to be matched (AND)- Author:
- Richard McCreadie
-
-
Field Summary
Fields Modifier and Type Field Description protected int
currentId
protected int
frequency
protected IterablePosting[]
ips
protected int
termCount
-
Fields inherited from interface org.terrier.structures.postings.IterablePosting
END_OF_LIST, EOL
-
-
Constructor Summary
Constructors Constructor Description ANDIterablePosting(IterablePosting[] _ips, EntryStatistics[] _p)
ANDIterablePosting(IterablePosting[] _ips, Pointer[] _p)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WritablePosting
asWritablePosting()
Copy this posting to one free of an iterator.protected boolean
calculateFrequency()
returns true if the document matchesvoid
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.int
next(int targetID)
This implementation of next(int) which uses next()
-
-
-
Field Detail
-
currentId
protected int currentId
-
ips
protected IterablePosting[] ips
-
termCount
protected final int termCount
-
frequency
protected int frequency
-
-
Constructor Detail
-
ANDIterablePosting
public ANDIterablePosting(IterablePosting[] _ips, EntryStatistics[] _p) throws java.io.IOException
- Throws:
java.io.IOException
-
ANDIterablePosting
public ANDIterablePosting(IterablePosting[] _ips, Pointer[] _p) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getId
public int getId()
Description copied from interface:Posting
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.
-
getFrequency
public int getFrequency()
Description copied from interface:Posting
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()
Description copied from interface:Posting
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.
-
next
public int next(int targetID) throws java.io.IOException
Description copied from class:IterablePostingImpl
This implementation of next(int) which uses next()- Specified by:
next
in interfaceIterablePosting
- Overrides:
next
in classIterablePostingImpl
- Parameters:
targetID
- 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
-
next
public int next() throws java.io.IOException
Description copied from interface:IterablePosting
Move this iterator to the next posting.- Returns:
- id of next posting, or EOL if end of posting list.
- Throws:
java.io.IOException
-
calculateFrequency
protected boolean calculateFrequency()
returns true if the document matches
-
endOfPostings
public boolean endOfPostings()
Description copied from interface:IterablePosting
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()
Description copied from interface:Posting
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
-
-