Search in sources :

Example 1 with LocalSlicingWindowAggOperator

use of org.apache.flink.table.runtime.operators.aggregate.window.LocalSlicingWindowAggOperator in project flink by apache.

the class StreamExecLocalWindowAggregate 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 ZoneId shiftTimeZone = TimeWindowUtil.getShiftTimeZone(windowing.getTimeAttributeType(), config.getLocalTimeZone());
    final SliceAssigner sliceAssigner = createSliceAssigner(windowing, shiftTimeZone);
    final AggregateInfoList aggInfoList = AggregateUtil.deriveStreamWindowAggregateInfoList(inputRowType, JavaScalaConversionUtil.toScala(Arrays.asList(aggCalls)), windowing.getWindow(), // isStateBackendDataViews
    false);
    final GeneratedNamespaceAggsHandleFunction<Long> generatedAggsHandler = createAggsHandler(sliceAssigner, aggInfoList, config, planner.getRelBuilder(), inputRowType.getChildren(), shiftTimeZone);
    final RowDataKeySelector selector = KeySelectorUtil.getRowDataSelector(grouping, InternalTypeInfo.of(inputRowType));
    PagedTypeSerializer<RowData> keySer = (PagedTypeSerializer<RowData>) selector.getProducedType().toSerializer();
    AbstractRowDataSerializer<RowData> valueSer = new RowDataSerializer(inputRowType);
    WindowBuffer.LocalFactory bufferFactory = new RecordsWindowBuffer.LocalFactory(keySer, valueSer, new LocalAggCombiner.Factory(generatedAggsHandler));
    final OneInputStreamOperator<RowData, RowData> localAggOperator = new LocalSlicingWindowAggOperator(selector, sliceAssigner, bufferFactory, shiftTimeZone);
    return ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationMeta(LOCAL_WINDOW_AGGREGATE_TRANSFORMATION, config), SimpleOperatorFactory.of(localAggOperator), InternalTypeInfo.of(getOutputType()), inputTransform.getParallelism(), // use less memory here to let the chained head operator can have more memory
    WINDOW_AGG_MEMORY_RATIO / 2);
}
Also used : SliceAssigner(org.apache.flink.table.runtime.operators.window.slicing.SliceAssigner) 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) ZoneId(java.time.ZoneId) LocalAggCombiner(org.apache.flink.table.runtime.operators.aggregate.window.combines.LocalAggCombiner) RowType(org.apache.flink.table.types.logical.RowType) WindowBuffer(org.apache.flink.table.runtime.operators.aggregate.window.buffers.WindowBuffer) RecordsWindowBuffer(org.apache.flink.table.runtime.operators.aggregate.window.buffers.RecordsWindowBuffer) RowData(org.apache.flink.table.data.RowData) PagedTypeSerializer(org.apache.flink.table.runtime.typeutils.PagedTypeSerializer) RowDataKeySelector(org.apache.flink.table.runtime.keyselector.RowDataKeySelector) LocalSlicingWindowAggOperator(org.apache.flink.table.runtime.operators.aggregate.window.LocalSlicingWindowAggOperator) RowDataSerializer(org.apache.flink.table.runtime.typeutils.RowDataSerializer) AbstractRowDataSerializer(org.apache.flink.table.runtime.typeutils.AbstractRowDataSerializer)

Aggregations

ZoneId (java.time.ZoneId)1 Transformation (org.apache.flink.api.dag.Transformation)1 RowData (org.apache.flink.table.data.RowData)1 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)1 AggregateInfoList (org.apache.flink.table.planner.plan.utils.AggregateInfoList)1 RowDataKeySelector (org.apache.flink.table.runtime.keyselector.RowDataKeySelector)1 LocalSlicingWindowAggOperator (org.apache.flink.table.runtime.operators.aggregate.window.LocalSlicingWindowAggOperator)1 RecordsWindowBuffer (org.apache.flink.table.runtime.operators.aggregate.window.buffers.RecordsWindowBuffer)1 WindowBuffer (org.apache.flink.table.runtime.operators.aggregate.window.buffers.WindowBuffer)1 LocalAggCombiner (org.apache.flink.table.runtime.operators.aggregate.window.combines.LocalAggCombiner)1 SliceAssigner (org.apache.flink.table.runtime.operators.window.slicing.SliceAssigner)1 AbstractRowDataSerializer (org.apache.flink.table.runtime.typeutils.AbstractRowDataSerializer)1 PagedTypeSerializer (org.apache.flink.table.runtime.typeutils.PagedTypeSerializer)1 RowDataSerializer (org.apache.flink.table.runtime.typeutils.RowDataSerializer)1 RowType (org.apache.flink.table.types.logical.RowType)1