Search in sources :

Example 1 with SortWindowCodeGenerator

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

the class BatchExecSortWindowAggregate 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 int groupBufferLimitSize = config.get(ExecutionConfigOptions.TABLE_EXEC_WINDOW_AGG_BUFFER_SIZE_LIMIT);
    final Tuple2<Long, Long> windowSizeAndSlideSize = WindowCodeGenerator.getWindowDef(window);
    final SortWindowCodeGenerator windowCodeGenerator = new SortWindowCodeGenerator(new CodeGeneratorContext(config.getTableConfig()), planner.getRelBuilder(), window, inputTimeFieldIndex, inputTimeIsDate, JavaScalaConversionUtil.toScala(Arrays.asList(namedWindowProperties)), aggInfos, (RowType) inputEdge.getOutputType(), (RowType) getOutputType(), groupBufferLimitSize, // windowStart
    0L, windowSizeAndSlideSize.f0, windowSizeAndSlideSize.f1, grouping, auxGrouping, enableAssignPane, isMerge, isFinal);
    final GeneratedOperator<OneInputStreamOperator<RowData, RowData>> generatedOperator;
    if (grouping.length == 0) {
        generatedOperator = windowCodeGenerator.genWithoutKeys();
    } else {
        generatedOperator = windowCodeGenerator.genWithKeys();
    }
    return ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationName(config), createTransformationDescription(config), new CodeGenOperatorFactory<>(generatedOperator), 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) RowData(org.apache.flink.table.data.RowData) OneInputStreamOperator(org.apache.flink.streaming.api.operators.OneInputStreamOperator) SortWindowCodeGenerator(org.apache.flink.table.planner.codegen.agg.batch.SortWindowCodeGenerator)

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 SortWindowCodeGenerator (org.apache.flink.table.planner.codegen.agg.batch.SortWindowCodeGenerator)1 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)1 AggregateInfoList (org.apache.flink.table.planner.plan.utils.AggregateInfoList)1