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 Term
ASSOCIATION_POSTING_TERM
Default Term for associationsstatic long
NO_ASSOCIATION
The long-special-value returned for ordinals which have no associated int value.
-
Constructor Summary
Constructors Constructor Description AssociationsPayloadIterator(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 boolean
equals(Object obj)
IntIterator
getAssociatedOrdinals()
Get an iterator over the ordinals which has an association for the document set bysetNextDoc(int)
.long
getAssociation(int ordinal)
Get int association value for the given ordinal.int
hashCode()
boolean
setNextDoc(int docId)
Skipping to the next document, fetching its associations & populating the map.
-
-
-
Field Detail
-
ASSOCIATION_POSTING_TERM
public static final 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(IndexReader reader, String field) throws IOException
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- 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 IOException
Skipping 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_ASSOCIATION
which 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_ASSOCIATION
otherwise
-
getAssociatedOrdinals
public IntIterator getAssociatedOrdinals()
Get an iterator over the ordinals which has an association for the document set bysetNextDoc(int)
.
-
-