Package org.terrier.realtime.multi
Class MultiDirectIterablePosting
- java.lang.Object
-
- org.terrier.realtime.multi.MultiDirectIterablePosting
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,IterablePosting
,Posting
- Direct Known Subclasses:
BlockMultiDirectIterablePosting
public class MultiDirectIterablePosting extends java.lang.Object implements IterablePosting
This acts as a wrapper class that surrounds an IterablePosting object. It is designed for use with the MultiDirect structure, to allow fast termid lookups. The motivation is that when iterating over a direct index, the termids that come out are index shard local. To fix this, we add on the number of terms in each preceding lexicon to turn local termids into global ones. The MultiLexicon is then responsible for converting the global termid into its local termid and index shard components, which can be used to do the termid lookup.- Since:
- 4.0
- Author:
- Richard McCreadie
-
-
Field Summary
-
Fields inherited from interface org.terrier.structures.postings.IterablePosting
END_OF_LIST, EOL
-
-
Constructor Summary
Constructors Constructor Description MultiDirectIterablePosting(IterablePosting posting, MultiLexicon lex, int shard)
-
Method Summary
All Methods Static 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.int
next(int targetId)
Move this iterator to the posting with specified id, or next posting after that if a posting with the specified id does not exist.static MultiDirectIterablePosting
of(IterablePosting ip, MultiLexicon lex, int shard, boolean blocks, boolean fields)
-
-
-
Constructor Detail
-
MultiDirectIterablePosting
public MultiDirectIterablePosting(IterablePosting posting, MultiLexicon lex, int shard)
-
-
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.
-
getFrequency
public int getFrequency()
Description copied from interface:Posting
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.
-
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.- Specified by:
getDocumentLength
in interfacePosting
- Returns:
- length of the document of the current posting in tokens.
-
asWritablePosting
public WritablePosting asWritablePosting()
Description copied from interface:Posting
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
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
next
public int next() throws java.io.IOException
Description copied from interface:IterablePosting
Move this iterator to the next posting.- Specified by:
next
in interfaceIterablePosting
- Returns:
- id of next posting, or EOL if end of posting list.
- Throws:
java.io.IOException
-
next
public int next(int targetId) throws java.io.IOException
Description copied from interface:IterablePosting
Move this iterator to the posting with specified id, or next posting after that if a posting with the specified id does not exist. This is usually implemented internally byIterablePosting.next()
, but more efficient implementations can override this behaviour.- Specified by:
next
in interfaceIterablePosting
- 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
-
endOfPostings
public boolean endOfPostings()
Description copied from interface:IterablePosting
Status method to see if this posting list iterator has been finished.- Specified by:
endOfPostings
in interfaceIterablePosting
- Returns:
- true if
IterablePosting.next()
orIterablePosting.next(int)
would return EOL or have returned EOL.
-
of
public static MultiDirectIterablePosting of(IterablePosting ip, MultiLexicon lex, int shard, boolean blocks, boolean fields)
-
-