Search in sources :

Example 1 with HashWindowCodeGenerator

use of org.apache.flink.table.planner.codegen.agg.batch.HashWindowCodeGenerator in project flink by apache.

the class BatchExecHashWindowAggregate 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 AggregateInfoList aggInfos = AggregateUtil.transformToBatchAggregateInfoList(aggInputRowType, JavaScalaConversionUtil.toScala(Arrays.asList(aggCalls)), // aggCallNeedRetractions
    null, // orderKeyIndexes
    null);
    final RowType inputRowType = (RowType) inputEdge.getOutputType();
    final HashWindowCodeGenerator hashWindowCodeGenerator = new HashWindowCodeGenerator(new CodeGeneratorContext(config.getTableConfig()), planner.getRelBuilder(), window, inputTimeFieldIndex, inputTimeIsDate, JavaScalaConversionUtil.toScala(Arrays.asList(namedWindowProperties)), aggInfos, inputRowType, grouping, auxGrouping, enableAssignPane, isMerge, isFinal);
    final int groupBufferLimitSize = config.get(ExecutionConfigOptions.TABLE_EXEC_WINDOW_AGG_BUFFER_SIZE_LIMIT);
    final Tuple2<Long, Long> windowSizeAndSlideSize = WindowCodeGenerator.getWindowDef(window);
    final GeneratedOperator<OneInputStreamOperator<RowData, RowData>> generatedOperator = hashWindowCodeGenerator.gen(inputRowType, (RowType) getOutputType(), groupBufferLimitSize, // windowStart
    0, windowSizeAndSlideSize.f0, windowSizeAndSlideSize.f1);
    final long managedMemory = config.get(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_HASH_AGG_MEMORY).getBytes();
    return ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationName(config), createTransformationDescription(config), new CodeGenOperatorFactory<>(generatedOperator), InternalTypeInfo.of(getOutputType()), inputTransform.getParallelism(), managedMemory);
}
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) RowData(org.apache.flink.table.data.RowData) OneInputStreamOperator(org.apache.flink.streaming.api.operators.OneInputStreamOperator) HashWindowCodeGenerator(org.apache.flink.table.planner.codegen.agg.batch.HashWindowCodeGenerator)

Aggregations

Transformation (org.apache.flink.api.dag.Transformation)1 OneInputStreamOperator (org.apache.flink.streaming.api.operators.OneInputStreamOperator)1 RowData (org.apache.flink.table.data.RowData)1 CodeGeneratorContext (org.apache.flink.table.planner.codegen.CodeGeneratorContext)1 HashWindowCodeGenerator (org.apache.flink.table.planner.codegen.agg.batch.HashWindowCodeGenerator)1 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)1 AggregateInfoList (org.apache.flink.table.planner.plan.utils.AggregateInfoList)1 RowType (org.apache.flink.table.types.logical.RowType)1