Module org.apache.lucene.sandbox
Class LongValueFacetCutter
java.lang.Object
org.apache.lucene.sandbox.facet.cutters.LongValueFacetCutter
- All Implemented Interfaces:
FacetCutter,OrdToLabel
FacetCutter and OrdToLabel for distinct long values.
TODO: This class is quite inefficient. Will optimise later.
TODO: add support for other value sources e.g: LongValues
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classLongIntHashMapwith threadsafe computeIfAbsent method -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final AtomicIntegerprivate IntLongHashMapprivate final LongValueFacetCutter.LongIntHashMapSyncCompute -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcreateLeafCutter(LeafReaderContext context) Get cutter for the leaf.getLabel(int ordinal) get label of one ord TODO: what do we return when ordinal is not valid? null?getLabels(int[] ordinals) get labels for multiple ordslonggetValue(int ordinal) Get value by ordinal.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.sandbox.facet.cutters.FacetCutter
getChildrenOrds, getOrdinalsToRollup
-
Field Details
-
field
-
valueToOrdMap
-
ordToValueMap
-
maxOrdinal
-
-
Constructor Details
-
LongValueFacetCutter
Constructor.- Parameters:
field- field name to read long values from.
-
-
Method Details
-
createLeafCutter
Description copied from interface:FacetCutterGet cutter for the leaf.- Specified by:
createLeafCutterin interfaceFacetCutter- Throws:
IOException
-
getLabel
Description copied from interface:OrdToLabelget label of one ord TODO: what do we return when ordinal is not valid? null?- Specified by:
getLabelin interfaceOrdToLabel
-
getValue
public long getValue(int ordinal) Get value by ordinal. Should only be called after collection phase.TODO: we need it to tie break sort by value. Alternatively we can sort by label (then we don't need this method), but we would have to convert FacetLabel to "long" to have the same order... Overall, it is probably not important to tie break by value, and we can tie break by ord same as for other facets; but for now we don't want to change results order just in case.
- Parameters:
ordinal- facet ordinal.- Returns:
- long value
-
buildOrdToValueMap
private void buildOrdToValueMap() -
getLabels
Description copied from interface:OrdToLabelget labels for multiple ords- Specified by:
getLabelsin interfaceOrdToLabel- Throws:
IOException
-