WeiZhong94 commented on a change in pull request #15149:
URL: https://github.com/apache/flink/pull/15149#discussion_r595670773



##########
File path: 
flink-python/src/main/java/org/apache/flink/streaming/api/operators/python/PythonKeyedCoProcessOperator.java
##########
@@ -0,0 +1,314 @@
+/*
+ * 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.streaming.api.operators.python;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeinfo.Types;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
+import org.apache.flink.api.java.typeutils.RowTypeInfo;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.memory.ManagedMemoryUseCase;
+import org.apache.flink.python.PythonFunctionRunner;
+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.functions.python.DataStreamPythonFunctionInfo;
+import org.apache.flink.streaming.api.operators.InternalTimer;
+import org.apache.flink.streaming.api.operators.InternalTimerService;
+import org.apache.flink.streaming.api.operators.TimestampedCollector;
+import org.apache.flink.streaming.api.operators.Triggerable;
+import 
org.apache.flink.streaming.api.runners.python.beam.BeamDataStreamPythonFunctionRunner;
+import org.apache.flink.streaming.api.utils.PythonOperatorUtils;
+import org.apache.flink.streaming.api.utils.PythonTypeUtils;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.types.Row;
+
+import java.util.Collections;
+
+import static 
org.apache.flink.streaming.api.utils.PythonOperatorUtils.KeyedProcessFunctionInputFlag.EVENT_TIME_TIMER;
+import static 
org.apache.flink.streaming.api.utils.PythonOperatorUtils.KeyedProcessFunctionInputFlag.PROC_TIME_TIMER;
+import static 
org.apache.flink.streaming.api.utils.PythonOperatorUtils.KeyedProcessFunctionOutputFlag.DEL_EVENT_TIMER;
+import static 
org.apache.flink.streaming.api.utils.PythonOperatorUtils.KeyedProcessFunctionOutputFlag.DEL_PROC_TIMER;
+import static 
org.apache.flink.streaming.api.utils.PythonOperatorUtils.KeyedProcessFunctionOutputFlag.REGISTER_EVENT_TIMER;
+import static 
org.apache.flink.streaming.api.utils.PythonOperatorUtils.KeyedProcessFunctionOutputFlag.REGISTER_PROC_TIMER;
+
+/** KeyedCoProcessOperator. */
+public class PythonKeyedCoProcessOperator<OUT>
+        extends TwoInputPythonFunctionOperator<Row, Row, Row, OUT>
+        implements ResultTypeQueryable<OUT>, Triggerable<Row, VoidNamespace> {
+
+    private static final String KEYED_CO_PROCESS_FUNCTION_URN =
+            "flink:transform:keyed_process_function:v1";
+
+    private static final String FLAT_MAP_CODER_URN = "flink:coder:flat_map:v1";
+
+    /** The TypeInformation of current key. */
+    private final TypeInformation<Row> keyTypeInfo;
+
+    /** Serializer for current key. */
+    private final TypeSerializer keyTypeSerializer;
+
+    private final TypeInformation<OUT> outputTypeInfo;
+
+    /** TimerService for current operator to register or fire timer. */
+    private transient TimerService timerService;
+
+    /** Reusable row for normal data runner inputs. */
+    private transient Row reusableInput;
+
+    /** Reusable row for timer data runner inputs. */
+    private transient Row reusableTimerData;
+
+    public PythonKeyedCoProcessOperator(
+            Configuration config,
+            TypeInformation<Row> inputTypeInfo1,
+            TypeInformation<Row> inputTypeInfo2,
+            TypeInformation<OUT> outputTypeInfo,
+            DataStreamPythonFunctionInfo pythonFunctionInfo) {
+        super(
+                config,
+                pythonFunctionInfo,
+                FLAT_MAP_CODER_URN,
+                constructRunnerInputTypeInfo(
+                        inputTypeInfo1, inputTypeInfo2, 
constructKeyTypeInfo(inputTypeInfo1)),
+                constructRunnerOutputTypeInfo(
+                        outputTypeInfo, constructKeyTypeInfo(inputTypeInfo1)));
+        this.keyTypeInfo = new RowTypeInfo(((RowTypeInfo) 
inputTypeInfo1).getTypeAt(0));
+        this.keyTypeSerializer =
+                
PythonTypeUtils.TypeInfoToSerializerConverter.typeInfoSerializerConverter(
+                        keyTypeInfo);
+        this.outputTypeInfo = outputTypeInfo;
+    }
+
+    @Override
+    public PythonFunctionRunner createPythonFunctionRunner() throws Exception {

Review comment:
       Agree. The JIRA has been created: 
https://issues.apache.org/jira/browse/FLINK-21792 




----------------------------------------------------------------
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:
[email protected]


Reply via email to