lincoln-lil commented on code in PR #25815:
URL: https://github.com/apache/flink/pull/25815#discussion_r1914359274


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/AsyncStateTableStreamOperator.java:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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;
+
+import org.apache.flink.core.memory.ManagedMemoryUseCase;
+import 
org.apache.flink.runtime.asyncprocessing.operators.AbstractAsyncStateStreamOperator;
+import org.apache.flink.runtime.execution.Environment;
+import org.apache.flink.streaming.api.TimerService;
+import org.apache.flink.streaming.api.operators.InternalTimerService;
+import org.apache.flink.streaming.api.watermark.Watermark;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.runtime.tasks.ProcessingTimeService;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * Table operator to invoke close always. This is a base class for both batch 
and stream operators
+ * without key.
+ *
+ * <p>This class is nearly identical with {@link TableStreamOperator}, but 
extending from {@link
+ * AbstractAsyncStateStreamOperator} to integrate with asynchronous state 
access.
+ */
+public abstract class AsyncStateTableStreamOperator<OUT>
+        extends AbstractAsyncStateStreamOperator<OUT> {
+
+    /** We listen to this ourselves because we don't have an {@link 
InternalTimerService}. */
+    protected long currentWatermark = Long.MIN_VALUE;
+
+    protected transient ContextImpl ctx;
+
+    @Override
+    public void open() throws Exception {
+        super.open();
+        this.ctx = new ContextImpl(getProcessingTimeService());
+    }
+
+    @Override
+    public boolean useSplittableTimers() {
+        return true;
+    }
+
+    /** Compute memory size from memory faction. */
+    public long computeMemorySize() {

Review Comment:
   When will this calculation be used?



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/window/utils/WindowJoinHelper.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.join.window.utils;
+
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.metrics.Meter;
+import org.apache.flink.metrics.MeterView;
+import org.apache.flink.metrics.groups.OperatorMetricGroup;
+import org.apache.flink.streaming.api.operators.TimestampedCollector;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.util.RowDataUtil;
+import org.apache.flink.table.data.utils.JoinedRowData;
+import org.apache.flink.table.runtime.operators.join.FlinkJoinType;
+import 
org.apache.flink.table.runtime.operators.join.JoinConditionWithNullFilters;
+import org.apache.flink.table.runtime.operators.join.window.WindowJoinOperator;
+import 
org.apache.flink.table.runtime.operators.join.window.asyncprocessing.AsyncStateWindowJoinOperator;
+import 
org.apache.flink.table.runtime.operators.window.tvf.common.WindowTimerService;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.types.RowKind;
+
+import javax.annotation.Nullable;
+
+import java.time.ZoneId;
+import java.util.IdentityHashMap;
+
+import static org.apache.flink.table.runtime.util.TimeWindowUtil.isWindowFired;
+
+/**
+ * A helper to do the window join operations for {@link WindowJoinOperator} 
and {@link
+ * AsyncStateWindowJoinOperator}.
+ */
+public abstract class WindowJoinHelper {
+
+    private static final String LEFT_LATE_ELEMENTS_DROPPED_METRIC_NAME =
+            "leftNumLateRecordsDropped";
+    private static final String LEFT_LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME =
+            "leftLateRecordsDroppedRate";
+    private static final String RIGHT_LATE_ELEMENTS_DROPPED_METRIC_NAME =
+            "rightNumLateRecordsDropped";
+    private static final String RIGHT_LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME =
+            "rightLateRecordsDroppedRate";
+    private static final String WATERMARK_LATENCY_METRIC_NAME = 
"watermarkLatency";
+
+    private final ZoneId shiftTimeZone;
+
+    private final WindowTimerService<Long> windowTimerService;
+
+    protected final RowDataSerializer leftSerializer;
+
+    protected final RowDataSerializer rightSerializer;
+
+    protected final JoinConditionWithNullFilters joinCondition;
+
+    private final int leftWindowEndIndex;
+    private final int rightWindowEndIndex;
+
+    /** This is used for emitting elements with a given timestamp. */
+    protected final TimestampedCollector<RowData> collector;
+
+    private final WindowJoinProcessor windowJoinProcessor;
+
+    // ------------------------------------------------------------------------
+    // Metrics
+    // ------------------------------------------------------------------------
+
+    private final Meter leftLateRecordsDroppedRate;
+    private final Meter rightLateRecordsDroppedRate;
+
+    public WindowJoinHelper(
+            RowDataSerializer leftSerializer,
+            RowDataSerializer rightSerializer,
+            ZoneId shiftTimeZone,
+            WindowTimerService<Long> windowTimerService,
+            JoinConditionWithNullFilters joinCondition,
+            int leftWindowEndIndex,
+            int rightWindowEndIndex,
+            TimestampedCollector<RowData> collector,
+            FlinkJoinType joinType,
+            OperatorMetricGroup metrics) {
+        this.leftSerializer = leftSerializer;
+        this.rightSerializer = rightSerializer;
+        this.shiftTimeZone = shiftTimeZone;
+        this.windowTimerService = windowTimerService;
+        this.joinCondition = joinCondition;
+        this.leftWindowEndIndex = leftWindowEndIndex;
+        this.rightWindowEndIndex = rightWindowEndIndex;
+        this.collector = collector;
+
+        this.windowJoinProcessor = getWindowJoinProcessor(joinType);
+
+        // register metrics

Review Comment:
   We commonly place the metric registrations in the open/setup methods, but it 
is a bit obscure to place it in the constructor, WDYT?



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