Class AssociationsPayloadIterator
- java.lang.Object
-
- org.apache.lucene.facet.enhancements.association.AssociationsPayloadIterator
-
public class AssociationsPayloadIterator extends Object
Allows easy iteration over the associations payload, decoding and breaking it to (ordinal, value) pairs, stored in a hash.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.lucene.index.TermASSOCIATION_POSTING_TERMDefault Term for associationsstatic longNO_ASSOCIATIONThe long-special-value returned for ordinals which have no associated int value.
-
Constructor Summary
Constructors Constructor Description AssociationsPayloadIterator(org.apache.lucene.index.IndexReader reader, String field)Construct a new association-iterator, initializing the inner payload iterator, with the supplied term and checking whether there are any associations within the given index
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)IntIteratorgetAssociatedOrdinals()Get an iterator over the ordinals which has an association for the document set bysetNextDoc(int).longgetAssociation(int ordinal)Get int association value for the given ordinal.inthashCode()booleansetNextDoc(int docId)Skipping to the next document, fetching its associations & populating the map.
-
-
-
Field Detail
-
ASSOCIATION_POSTING_TERM
public static final org.apache.lucene.index.Term ASSOCIATION_POSTING_TERM
Default Term for associations
-
NO_ASSOCIATION
public static final long NO_ASSOCIATION
The long-special-value returned for ordinals which have no associated int value. It is not in the int range of values making it a valid mark.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AssociationsPayloadIterator
public AssociationsPayloadIterator(org.apache.lucene.index.IndexReader reader, String field) throws IOExceptionConstruct a new association-iterator, initializing the inner payload iterator, with the supplied term and checking whether there are any associations within the given index- Parameters:
reader- a reader containing the postings to be iteratedfield- the field containing the relevant associations list term- Throws:
IOException
-
-
Method Detail
-
setNextDoc
public boolean setNextDoc(int docId) throws IOExceptionSkipping to the next document, fetching its associations & populating the map.- Parameters:
docId- document id to be skipped to- Returns:
- true if the document contains associations and they were fetched correctly. false otherwise.
- Throws:
IOException- on error
-
getAssociation
public long getAssociation(int ordinal)
Get int association value for the given ordinal.
The return is either an int value casted as long if the ordinal has an associated value. Otherwise the returned value would beNO_ASSOCIATIONwhich is 'pure long' value (e.g not in the int range of values)- Parameters:
ordinal- for which the association value is requested- Returns:
- the associated int value (encapsulated in a long) if the ordinal
had an associated value, or
NO_ASSOCIATIONotherwise
-
getAssociatedOrdinals
public IntIterator getAssociatedOrdinals()
Get an iterator over the ordinals which has an association for the document set bysetNextDoc(int).
-
-