Class LabelToOrdinal
java.lang.Object
org.apache.lucene.facet.taxonomy.writercache.LabelToOrdinal
Abstract class for storing Label->Ordinal mappings in a taxonomy.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
How many ordinals we've seen.static final int
Returned bygetOrdinal(org.apache.lucene.facet.taxonomy.FacetLabel)
when the label isn't recognized. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
addLabel
(FacetLabel label, int ordinal) Adds a new label if it is not yet in the table.int
return the maximal Ordinal assigned so farint
Returns the next unassigned ordinal.abstract int
getOrdinal
(FacetLabel label) Returns the ordinal assigned to the given label, orINVALID_ORDINAL
if the label cannot be found in this table.
-
Field Details
-
counter
protected int counterHow many ordinals we've seen. -
INVALID_ORDINAL
public static final int INVALID_ORDINALReturned bygetOrdinal(org.apache.lucene.facet.taxonomy.FacetLabel)
when the label isn't recognized.- See Also:
-
-
Constructor Details
-
LabelToOrdinal
public LabelToOrdinal()Default constructor.
-
-
Method Details
-
getMaxOrdinal
public int getMaxOrdinal()return the maximal Ordinal assigned so far -
getNextOrdinal
public int getNextOrdinal()Returns the next unassigned ordinal. The default behavior of this method is to simply increment a counter. -
addLabel
Adds a new label if it is not yet in the table. Throws anIllegalArgumentException
if the same label with a different ordinal was previously added to this table. -
getOrdinal
Returns the ordinal assigned to the given label, orINVALID_ORDINAL
if the label cannot be found in this table.
-