hequn8128 commented on a change in pull request #11044: [FLINK-15913][python] 
Add Python TableFunction Runner and Operator in Blink planner
URL: https://github.com/apache/flink/pull/11044#discussion_r378213520
 
 

 ##########
 File path: 
flink-python/src/main/java/org/apache/flink/table/runtime/operators/python/BaseRowPythonTableFunctionOperator.java
 ##########
 @@ -0,0 +1,148 @@
+/*
+ * 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;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.python.PythonFunctionRunner;
+import org.apache.flink.python.env.PythonEnvironmentManager;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.dataformat.BaseRow;
+import org.apache.flink.table.dataformat.BinaryRow;
+import org.apache.flink.table.dataformat.JoinedRow;
+import org.apache.flink.table.functions.TableFunction;
+import org.apache.flink.table.functions.python.PythonFunctionInfo;
+import org.apache.flink.table.planner.codegen.CodeGeneratorContext;
+import org.apache.flink.table.planner.codegen.ProjectionCodeGenerator;
+import org.apache.flink.table.runtime.generated.GeneratedProjection;
+import org.apache.flink.table.runtime.generated.Projection;
+import 
org.apache.flink.table.runtime.runners.python.BaseRowPythonTableFunctionRunner;
+import org.apache.flink.table.runtime.typeutils.PythonTypeUtils;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.beam.sdk.fn.data.FnDataReceiver;
+
+import java.io.IOException;
+
+/**
+ * The Python {@link TableFunction} operator for the blink planner.
+ */
+@Internal
+public class BaseRowPythonTableFunctionOperator
+       extends AbstractPythonTableFunctionOperator<BaseRow, BaseRow, BaseRow> {
+
+
+       private static final long serialVersionUID = 1L;
+
+       /**
+        * The collector used to collect records.
+        */
+       private transient StreamRecordBaseRowWrappingCollector baseRowWrapper;
+
+       /**
+        * The JoinedRow reused holding the execution result.
+        */
+       private transient JoinedRow reuseJoinedRow;
+
+       /**
+        * The Projection which projects the udtf input fields from the input 
row.
+        */
+       private transient Projection<BaseRow, BinaryRow> udtfInputProjection;
+
+       /**
+        * The TypeSerializer for udtf execution results.
+        */
+       private transient TypeSerializer<BaseRow> udtfOutputTypeSerializer;
+
+       public BaseRowPythonTableFunctionOperator(
+               Configuration config,
+               PythonFunctionInfo tableFunction,
+               RowType inputType,
+               RowType outputType,
+               int[] udtfInputOffsets) {
+               super(config, tableFunction, inputType, outputType, 
udtfInputOffsets);
+       }
+
+       @Override
+       @SuppressWarnings("unchecked")
+       public void open() throws Exception {
+               super.open();
+               baseRowWrapper = new 
StreamRecordBaseRowWrappingCollector(output);
+               reuseJoinedRow = new JoinedRow();
+
+               udtfInputProjection = createUdtfInputProjection();
+               udtfOutputTypeSerializer = 
PythonTypeUtils.toBlinkTypeSerializer(userDefinedFunctionOutputType);
+       }
+
+       @Override
+       public void bufferInput(BaseRow input) {
+               forwardedInputQueue.add(input);
 
 Review comment:
   Take object reuse into consideration.

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


With regards,
Apache Git Services

Reply via email to