Module org.apache.lucene.sandbox
Class LongAggregationsFacetRecorder
java.lang.Object
org.apache.lucene.sandbox.facet.recorders.LongAggregationsFacetRecorder
- All Implemented Interfaces:
FacetRecorder
FacetRecorder
that computes multiple long aggregations per facet.
TODO: [premature optimization idea] if instead of one array we keep aggregations in two LongVector (one for MAX aggregation and one for SUM) we can benefit from SIMD?
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<IntObjectHashMap<long[]>> private final LongValuesSource[]
private final Reducer[]
private IntObjectHashMap
<long[]> -
Constructor Summary
ConstructorsConstructorDescriptionLongAggregationsFacetRecorder
(LongValuesSource[] longValuesSources, Reducer[] reducers) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(int ordinal) Check if any data was recorded for provided facet ordinal.getLeafRecorder
(LeafReaderContext context) Get leaf recorder.long
getRecordedValue
(int ord, int valuesId) Return aggregated value for facet ordinal and aggregation ID, or zero as default.boolean
isEmpty()
True if there are no recordsReturn next collected ordinal, orOrdinalIterator.NO_MORE_ORDS
void
reduce
(FacetCutter facetCutter) Reduce leaf recorder results into this recorder.private long[]
rollup
(long[] accum, int ord, FacetCutter facetCutter) Rollup all child values of ord to accum, and return accum.
-
Field Details
-
values
-
leafValues
-
longValuesSources
-
reducers
-
-
Constructor Details
-
LongAggregationsFacetRecorder
Constructor.
-
-
Method Details
-
getLeafRecorder
Description copied from interface:FacetRecorder
Get leaf recorder.- Specified by:
getLeafRecorder
in interfaceFacetRecorder
- Throws:
IOException
-
recordedOrds
Description copied from interface:FacetRecorder
Return next collected ordinal, orOrdinalIterator.NO_MORE_ORDS
- Specified by:
recordedOrds
in interfaceFacetRecorder
-
isEmpty
public boolean isEmpty()Description copied from interface:FacetRecorder
True if there are no records- Specified by:
isEmpty
in interfaceFacetRecorder
-
reduce
Description copied from interface:FacetRecorder
Reduce leaf recorder results into this recorder. IfFacetCutter.getOrdinalsToRollup()
result is not null, it also rolls up values.After this method is called, it's illegal to add values to recorder, i.e. calling
FacetRecorder.getLeafRecorder(org.apache.lucene.index.LeafReaderContext)
orLeafFacetRecorder.record(int, int)
on its leaf recorders.- Specified by:
reduce
in interfaceFacetRecorder
- Throws:
IOException
-
contains
public boolean contains(int ordinal) Description copied from interface:FacetRecorder
Check if any data was recorded for provided facet ordinal.- Specified by:
contains
in interfaceFacetRecorder
-
rollup
Rollup all child values of ord to accum, and return accum. Accum param can be null. In this case, if recursive rollup for every child returns null, this method returns null. Otherwise, accum is initialized.- Throws:
IOException
-
getRecordedValue
public long getRecordedValue(int ord, int valuesId) Return aggregated value for facet ordinal and aggregation ID, or zero as default.
-