public class PayloadIntDecodingIterator extends Object implements CategoryListIterator
IndexReader and Term in which the payload resides.
The iterator then consumes the payload information of each document and
decodes it into categories. A typical use case of this class is:
IndexReader reader = [open your reader];
Term t = new Term("field", "where-payload-exists");
CategoryListIterator cli = new PayloadIntDecodingIterator(reader, t);
if (!cli.init()) {
// it means there are no payloads / documents associated with that term.
// Usually a sanity check. However, init() must be called.
}
DocIdSetIterator disi = [you usually iterate on something else, such as a Scorer];
int doc;
while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
cli.setdoc(doc);
long category;
while ((category = cli.nextCategory()) < Integer.MAX_VALUE) {
}
}
| Constructor and Description |
|---|
PayloadIntDecodingIterator(IndexReader indexReader,
Term term,
IntDecoder decoder) |
PayloadIntDecodingIterator(IndexReader indexReader,
Term term,
IntDecoder decoder,
byte[] buffer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
int |
hashCode() |
boolean |
init()
Initializes the iterator.
|
long |
nextCategory()
Returns the next category for the current document that is set through
CategoryListIterator.skipTo(int), or a number higher than Integer.MAX_VALUE. |
boolean |
skipTo(int docId)
Skips forward to document docId.
|
public PayloadIntDecodingIterator(IndexReader indexReader, Term term, IntDecoder decoder) throws IOException
IOExceptionpublic PayloadIntDecodingIterator(IndexReader indexReader, Term term, IntDecoder decoder, byte[] buffer) throws IOException
IOExceptionpublic boolean init()
throws IOException
CategoryListIteratorCategoryListIterator.skipTo(int), and its return value indicates whether there are
any relevant documents for this iterator. If it returns false, any call
to CategoryListIterator.skipTo(int) will return false as well.init in interface CategoryListIteratorIOExceptionpublic long nextCategory()
throws IOException
CategoryListIteratorCategoryListIterator.skipTo(int), or a number higher than Integer.MAX_VALUE.
No assumptions can be made on the order of the categories.nextCategory in interface CategoryListIteratorIOExceptionpublic boolean skipTo(int docId)
throws IOException
CategoryListIteratorCategoryListIterator.nextCategory() for a particular document.skipTo in interface CategoryListIteratorIOException