org.apache.lucene.facet.enhancements.association
Class AssociationsPayloadIterator

java.lang.Object
  extended by 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
static Term ASSOCIATION_POSTING_TERM
          Default Term for associations
static long NO_ASSOCIATION
          The long-special-value returned for ordinals which have no associated int value.
 
Constructor Summary
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
 boolean equals(Object obj)
           
 IntIterator getAssociatedOrdinals()
          Get an iterator over the ordinals which has an association for the document set by setNextDoc(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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

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 iterated
field - 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 be NO_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 by setNextDoc(int).


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object