Package org.terrier.structures.postings
Class ArrayOfIdsIterablePosting
- java.lang.Object
-
- org.terrier.structures.postings.IterablePostingImpl
-
- org.terrier.structures.postings.ArrayOfIdsIterablePosting
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Cloneable
,IterablePosting
,Posting
- Direct Known Subclasses:
ArrayOfBasicIterablePosting
public class ArrayOfIdsIterablePosting extends IterablePostingImpl implements java.lang.Cloneable
An instance of IterablePostings that works with a passed array of ids- Author:
- Craig Macdonald
-
-
Field Summary
Fields Modifier and Type Field Description protected int
id
protected int[]
ids
ids of each of the entries in this posting listprotected int
indice
where we are in the current posting list-
Fields inherited from interface org.terrier.structures.postings.IterablePosting
END_OF_LIST, EOL
-
-
Constructor Summary
Constructors Constructor Description ArrayOfIdsIterablePosting(int[] _ids)
Make a new IterablePosting using these ids
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WritablePosting
asWritablePosting()
Copy this posting to one free of an iterator.ArrayOfIdsIterablePosting
clone()
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.void
reset()
-
Methods inherited from class org.terrier.structures.postings.IterablePostingImpl
next
-
-
-
-
Method Detail
-
next
public int next() throws java.io.IOException
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
-
endOfPostings
public boolean endOfPostings()
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.
-
asWritablePosting
public WritablePosting asWritablePosting()
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
-
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.
-
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 0.- Specified by:
getDocumentLength
in interfacePosting
- 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.- Specified by:
getFrequency
in interfacePosting
- Returns:
- frequency of the term in the current document, in tokens.
-
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
-
reset
public void reset()
-
clone
public ArrayOfIdsIterablePosting clone()
- Overrides:
clone
in classjava.lang.Object
-
-