Module org.elasticsearch.compute
Class ToPartialGroupingAggregatorFunction
java.lang.Object
org.elasticsearch.compute.aggregation.ToPartialGroupingAggregatorFunction
- All Implemented Interfaces:
Closeable,AutoCloseable,GroupingAggregatorFunction,org.elasticsearch.core.Releasable
public class ToPartialGroupingAggregatorFunction
extends Object
implements GroupingAggregatorFunction
An internal aggregate function that always emits intermediate (or partial) output regardless of the aggregate mode.
The intermediate output should be consumed by
FromPartialGroupingAggregatorFunction, which always receives
the intermediate input. Since an intermediate aggregate output can consist of multiple blocks, we wrap these output
blocks in a single composite block. The FromPartialGroupingAggregatorFunction then unwraps this input block
into multiple primitive blocks and passes them to the delegating GroupingAggregatorFunction.
Both of these commands yield the same result, except the second plan executes aggregates twice:
``` | ... before | af(x) BY g | ... after ``` ``` | ... before | $x = to_partial(af(x)) BY g | from_partial($x, af(_)) BY g | ... after```
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.compute.aggregation.GroupingAggregatorFunction
GroupingAggregatorFunction.AddInput, GroupingAggregatorFunction.PreparedForEvaluation -
Constructor Summary
ConstructorsConstructorDescriptionToPartialGroupingAggregatorFunction(GroupingAggregatorFunction delegate, List<Integer> channels) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIntermediateInput(int positionOffset, IntArrayBlock groupIdVector, Page page) voidaddIntermediateInput(int positionOffset, IntBigArrayBlock groupIdVector, Page page) voidaddIntermediateInput(int positionOffset, IntVector groupIdVector, Page page) voidclose()intThe number of blocks used by intermediate state.static List<IntermediateStateDesc> prepareEvaluateFinal(IntVector selected, GroupingAggregatorEvaluationContext ctx) Prepare to build the final results for this aggregation.Prepare to build the intermediate results for this aggregation.prepareProcessRawInputPage(SeenGroupIds seenGroupIds, Page page) Returnsnullto opt out of the callback loop for this page entirely, e.g.voidselectedMayContainUnseenGroups(SeenGroupIds seenGroupIds) Call this to signal to the aggregation that theselectedparameter that's passed toGroupingAggregatorFunction.prepareEvaluateIntermediate(org.elasticsearch.compute.data.IntVector, org.elasticsearch.compute.aggregation.GroupingAggregatorEvaluationContext)orGroupingAggregatorFunction.prepareEvaluateFinal(org.elasticsearch.compute.data.IntVector, org.elasticsearch.compute.aggregation.GroupingAggregatorEvaluationContext)may reference groups that haven't been seen.toString()
-
Constructor Details
-
ToPartialGroupingAggregatorFunction
public ToPartialGroupingAggregatorFunction(GroupingAggregatorFunction delegate, List<Integer> channels)
-
-
Method Details
-
intermediateStateDesc
-
prepareProcessRawInputPage
public GroupingAggregatorFunction.AddInput prepareProcessRawInputPage(SeenGroupIds seenGroupIds, Page page) Description copied from interface:GroupingAggregatorFunctionReturnsnullto opt out of the callback loop for this page entirely, e.g. when the values block is all-null and contributes nothing to the aggregation.- Specified by:
prepareProcessRawInputPagein interfaceGroupingAggregatorFunction
-
selectedMayContainUnseenGroups
Description copied from interface:GroupingAggregatorFunctionCall this to signal to the aggregation that theselectedparameter that's passed toGroupingAggregatorFunction.prepareEvaluateIntermediate(org.elasticsearch.compute.data.IntVector, org.elasticsearch.compute.aggregation.GroupingAggregatorEvaluationContext)orGroupingAggregatorFunction.prepareEvaluateFinal(org.elasticsearch.compute.data.IntVector, org.elasticsearch.compute.aggregation.GroupingAggregatorEvaluationContext)may reference groups that haven't been seen. This puts the underlying storage into a mode where it'll track which group ids have been seen, even if that increases the overhead.- Specified by:
selectedMayContainUnseenGroupsin interfaceGroupingAggregatorFunction
-
addIntermediateInput
Description copied from interface:GroupingAggregatorFunctionAdd data produced byGroupingAggregatorFunction.prepareEvaluateIntermediate(org.elasticsearch.compute.data.IntVector, org.elasticsearch.compute.aggregation.GroupingAggregatorEvaluationContext).- Specified by:
addIntermediateInputin interfaceGroupingAggregatorFunction
-
addIntermediateInput
Description copied from interface:GroupingAggregatorFunctionAdd data produced byGroupingAggregatorFunction.prepareEvaluateIntermediate(org.elasticsearch.compute.data.IntVector, org.elasticsearch.compute.aggregation.GroupingAggregatorEvaluationContext).- Specified by:
addIntermediateInputin interfaceGroupingAggregatorFunction
-
addIntermediateInput
Description copied from interface:GroupingAggregatorFunctionAdd data produced byGroupingAggregatorFunction.prepareEvaluateIntermediate(org.elasticsearch.compute.data.IntVector, org.elasticsearch.compute.aggregation.GroupingAggregatorEvaluationContext).- Specified by:
addIntermediateInputin interfaceGroupingAggregatorFunction
-
prepareEvaluateIntermediate
public GroupingAggregatorFunction.PreparedForEvaluation prepareEvaluateIntermediate(IntVector selected, GroupingAggregatorEvaluationContext ctx) Description copied from interface:GroupingAggregatorFunctionPrepare to build the intermediate results for this aggregation.- Specified by:
prepareEvaluateIntermediatein interfaceGroupingAggregatorFunction- Parameters:
selected- the groupIds that have been selected to be included in the results. Always ascending.
-
prepareEvaluateFinal
public GroupingAggregatorFunction.PreparedForEvaluation prepareEvaluateFinal(IntVector selected, GroupingAggregatorEvaluationContext ctx) Description copied from interface:GroupingAggregatorFunctionPrepare to build the final results for this aggregation.- Specified by:
prepareEvaluateFinalin interfaceGroupingAggregatorFunction- Parameters:
selected- the groupIds that have been selected to be included in the results. Always ascending.This function is called in the coordinator node after all intermediate results have been gathered from the worker nodes, and aggregated into intermediate blocks.
-
intermediateBlockCount
public int intermediateBlockCount()Description copied from interface:GroupingAggregatorFunctionThe number of blocks used by intermediate state.- Specified by:
intermediateBlockCountin interfaceGroupingAggregatorFunction
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.elasticsearch.core.Releasable
-
toString
-