xuyangzhong commented on code in PR #25861:
URL: https://github.com/apache/flink/pull/25861#discussion_r1912753558


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/aggregate/asyncwindow/processors/AbstractAsyncStateSliceWindowAggProcessor.java:
##########
@@ -0,0 +1,198 @@
+/*
+ * 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.aggregate.asyncwindow.processors;
+
+import org.apache.flink.api.common.state.v2.StateFuture;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.core.state.StateFutureUtils;
+import org.apache.flink.table.data.RowData;
+import 
org.apache.flink.table.runtime.generated.GeneratedNamespaceAggsHandleFunction;
+import 
org.apache.flink.table.runtime.operators.aggregate.asyncwindow.buffers.AsyncStateWindowBuffer;
+import org.apache.flink.table.runtime.operators.window.MergeCallback;
+import 
org.apache.flink.table.runtime.operators.window.asyncprocessing.tvf.common.AsyncStateWindowProcessor;
+import 
org.apache.flink.table.runtime.operators.window.asyncprocessing.tvf.slicing.AsyncStateSlicingWindowProcessor;
+import 
org.apache.flink.table.runtime.operators.window.tvf.common.WindowTimerService;
+import 
org.apache.flink.table.runtime.operators.window.tvf.slicing.SliceAssigner;
+import 
org.apache.flink.table.runtime.operators.window.tvf.slicing.SliceSharedAssigner;
+import 
org.apache.flink.table.runtime.operators.window.tvf.slicing.SlicingWindowTimerServiceImpl;
+
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.List;
+
+import static 
org.apache.flink.table.runtime.util.AsyncStateUtils.REUSABLE_TRUE_STATE_FUTURE;
+import static 
org.apache.flink.table.runtime.util.AsyncStateUtils.REUSABLE_VOID_STATE_FUTURE;
+import static 
org.apache.flink.table.runtime.util.TimeWindowUtil.getNextTriggerWatermark;
+import static org.apache.flink.table.runtime.util.TimeWindowUtil.isWindowFired;
+
+/** A base implementation of {@link AsyncStateSlicingWindowProcessor} for 
window aggregate. */
+public abstract class AbstractAsyncStateSliceWindowAggProcessor
+        extends AbstractAsyncStateWindowAggProcessor<Long>
+        implements AsyncStateSlicingWindowProcessor<Long> {
+
+    protected final AsyncStateWindowBuffer.Factory windowBufferFactory;
+    protected final SliceAssigner sliceAssigner;
+    protected final long windowInterval;
+
+    // 
----------------------------------------------------------------------------------------
+
+    /** The next progress to trigger windows. */
+    private transient long nextTriggerProgress;
+
+    protected transient AsyncStateWindowBuffer windowBuffer;
+
+    public AbstractAsyncStateSliceWindowAggProcessor(
+            GeneratedNamespaceAggsHandleFunction<Long> genAggsHandler,
+            AsyncStateWindowBuffer.Factory bufferFactory,
+            SliceAssigner sliceAssigner,
+            TypeSerializer<RowData> accSerializer,
+            int indexOfCountStar,
+            ZoneId shiftTimeZone) {
+        super(
+                genAggsHandler,
+                sliceAssigner,
+                accSerializer,
+                sliceAssigner.isEventTime(),
+                indexOfCountStar,
+                shiftTimeZone,
+                Long.MIN_VALUE);
+        this.windowBufferFactory = bufferFactory;
+        this.sliceAssigner = sliceAssigner;
+        this.windowInterval = sliceAssigner.getSliceEndInterval();
+    }
+
+    @Override
+    public void open(AsyncStateWindowProcessor.Context<Long> context) throws 
Exception {
+        super.open(context);
+        this.windowBuffer =
+                windowBufferFactory.create(
+                        ctx.getOperatorOwner(),
+                        ctx.getMemoryManager(),
+                        ctx.getMemorySize(),
+                        ctx.getRuntimeContext(),
+                        windowTimerService,
+                        ctx.getAsyncKeyContext(),
+                        windowState,
+                        isEventTime,
+                        shiftTimeZone);
+
+        this.nextTriggerProgress = Long.MIN_VALUE;
+    }
+
+    @Override
+    protected WindowTimerService<Long> getWindowTimerService() {
+        return new SlicingWindowTimerServiceImpl(ctx.getTimerService(), 
shiftTimeZone);
+    }
+
+    @Override
+    public StateFuture<Boolean> processElement(RowData key, RowData element) 
throws Exception {

Review Comment:
   I create an WindowAggProcessorBase to abstract common methods.



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to