Search in sources :

Example 1 with MapBundleOperator

use of org.apache.flink.table.runtime.operators.bundle.MapBundleOperator in project flink by apache.

the class StreamExecLocalGroupAggregate method translateToPlanInternal.

@SuppressWarnings("unchecked")
@Override
protected Transformation<RowData> translateToPlanInternal(PlannerBase planner, ExecNodeConfig config) {
    final ExecEdge inputEdge = getInputEdges().get(0);
    final Transformation<RowData> inputTransform = (Transformation<RowData>) inputEdge.translateToPlan(planner);
    final RowType inputRowType = (RowType) inputEdge.getOutputType();
    final AggsHandlerCodeGenerator generator = new AggsHandlerCodeGenerator(new CodeGeneratorContext(config.getTableConfig()), planner.getRelBuilder(), JavaScalaConversionUtil.toScala(inputRowType.getChildren()), // the local aggregate result will be buffered, so need copy
    true);
    generator.needAccumulate().needMerge(0, true, null);
    if (needRetraction) {
        generator.needRetract();
    }
    final AggregateInfoList aggInfoList = AggregateUtil.transformToStreamAggregateInfoList(inputRowType, JavaScalaConversionUtil.toScala(Arrays.asList(aggCalls)), aggCallNeedRetractions, needRetraction, // isStateBackendDataViews
    false, // needDistinctInfo
    true);
    final GeneratedAggsHandleFunction aggsHandler = generator.generateAggsHandler("GroupAggsHandler", aggInfoList);
    final MiniBatchLocalGroupAggFunction aggFunction = new MiniBatchLocalGroupAggFunction(aggsHandler);
    final RowDataKeySelector selector = KeySelectorUtil.getRowDataSelector(grouping, (InternalTypeInfo<RowData>) inputTransform.getOutputType());
    final MapBundleOperator<RowData, RowData, RowData, RowData> operator = new MapBundleOperator<>(aggFunction, AggregateUtil.createMiniBatchTrigger(config), selector);
    return ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationMeta(LOCAL_GROUP_AGGREGATE_TRANSFORMATION, config), operator, InternalTypeInfo.of(getOutputType()), inputTransform.getParallelism());
}
Also used : Transformation(org.apache.flink.api.dag.Transformation) AggregateInfoList(org.apache.flink.table.planner.plan.utils.AggregateInfoList) ExecEdge(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge) CodeGeneratorContext(org.apache.flink.table.planner.codegen.CodeGeneratorContext) RowType(org.apache.flink.table.types.logical.RowType) AggsHandlerCodeGenerator(org.apache.flink.table.planner.codegen.agg.AggsHandlerCodeGenerator) GeneratedAggsHandleFunction(org.apache.flink.table.runtime.generated.GeneratedAggsHandleFunction) RowData(org.apache.flink.table.data.RowData) MapBundleOperator(org.apache.flink.table.runtime.operators.bundle.MapBundleOperator) RowDataKeySelector(org.apache.flink.table.runtime.keyselector.RowDataKeySelector) MiniBatchLocalGroupAggFunction(org.apache.flink.table.runtime.operators.aggregate.MiniBatchLocalGroupAggFunction)

Aggregations

Transformation (org.apache.flink.api.dag.Transformation)1 RowData (org.apache.flink.table.data.RowData)1 CodeGeneratorContext (org.apache.flink.table.planner.codegen.CodeGeneratorContext)1 AggsHandlerCodeGenerator (org.apache.flink.table.planner.codegen.agg.AggsHandlerCodeGenerator)1 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)1 AggregateInfoList (org.apache.flink.table.planner.plan.utils.AggregateInfoList)1 GeneratedAggsHandleFunction (org.apache.flink.table.runtime.generated.GeneratedAggsHandleFunction)1 RowDataKeySelector (org.apache.flink.table.runtime.keyselector.RowDataKeySelector)1 MiniBatchLocalGroupAggFunction (org.apache.flink.table.runtime.operators.aggregate.MiniBatchLocalGroupAggFunction)1 MapBundleOperator (org.apache.flink.table.runtime.operators.bundle.MapBundleOperator)1 RowType (org.apache.flink.table.types.logical.RowType)1