amaliujia commented on a change in pull request #14775: URL: https://github.com/apache/flink/pull/14775#discussion_r569195501
########## File path: flink-python/src/main/java/org/apache/flink/table/runtime/operators/python/aggregate/AbstractPythonStreamGroupAggregateOperator.java ########## @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.runtime.operators.python.aggregate; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.state.ValueState; +import org.apache.flink.api.common.state.ValueStateDescriptor; +import org.apache.flink.api.common.typeinfo.Types; +import org.apache.flink.api.java.tuple.Tuple2; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.fnexecution.v1.FlinkFnApi; +import org.apache.flink.runtime.state.VoidNamespace; +import org.apache.flink.runtime.state.VoidNamespaceSerializer; +import org.apache.flink.streaming.api.SimpleTimerService; +import org.apache.flink.streaming.api.TimerService; +import org.apache.flink.streaming.api.operators.InternalTimer; +import org.apache.flink.streaming.api.operators.Triggerable; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.functions.python.PythonAggregateFunctionInfo; +import org.apache.flink.table.planner.typeutils.DataViewUtils; +import org.apache.flink.table.runtime.functions.CleanupState; +import org.apache.flink.table.types.logical.BigIntType; +import org.apache.flink.table.types.logical.RowType; +import org.apache.flink.table.types.logical.TinyIntType; + +import java.util.ArrayList; +import java.util.List; + +/** + * Base class for {@link PythonStreamGroupAggregateOperator} and {@link + * PythonStreamGroupTableAggregateOperator}. + */ +@Internal +public abstract class AbstractPythonStreamGroupAggregateOperator + extends AbstractPythonStreamAggregateOperator + implements Triggerable<RowData, VoidNamespace>, CleanupState { + + private static final long serialVersionUID = 1L; + + /** The minimum time in milliseconds until state which was not updated will be retained. */ + private final long minRetentionTime; + + /** The maximum time in milliseconds until state which was not updated will be retained. */ + private final long maxRetentionTime; + + /** + * Indicates whether state cleaning is enabled. Can be calculated from the `minRetentionTime`. + */ + private final boolean stateCleaningEnabled; + + private transient TimerService timerService; + + // holds the latest registered cleanup timer + private transient ValueState<Long> cleanupTimeState; + + public AbstractPythonStreamGroupAggregateOperator( + Configuration config, + RowType inputType, + RowType outputType, + PythonAggregateFunctionInfo[] aggregateFunctions, + DataViewUtils.DataViewSpec[][] dataViewSpecs, + int[] grouping, + int indexOfCountStar, + boolean generateUpdateBefore, + long minRetentionTime, + long maxRetentionTime) { + super( + config, Review comment: nit: indents are a bit wired. Seems `config` can be after `super(`? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org