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

 ##########
 File path: 
flink-python/src/main/java/org/apache/flink/table/runtime/typeutils/serializers/python/TableSerializer.java
 ##########
 @@ -0,0 +1,152 @@
+/*
+ * 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.typeutils.serializers.python;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.Arrays;
+
+import static 
org.apache.flink.api.java.typeutils.runtime.NullMaskUtils.readIntoNullMask;
+
+/**
+ * Base Table Serializer for Table Function.
+ */
+@Internal
+abstract class TableSerializer<T> extends TypeSerializer<T> {
+
+       private final TypeSerializer[] fieldSerializers;
+
+       private transient boolean[] nullMask;
+
+       TableSerializer(TypeSerializer[] fieldSerializers) {
+               this.fieldSerializers = fieldSerializers;
+               this.nullMask = new boolean[Math.max(fieldSerializers.length - 
8, 0)];
+       }
+
+       @Override
+       public boolean isImmutableType() {
+               return false;
+       }
+
+       @Override
+       public TypeSerializer<T> duplicate() {
+               throw new RuntimeException("This method duplicate() should not 
be called");
+       }
+
+       @Override
+       public T createInstance() {
+               return unwantedMethodCall("createInstance()");
+       }
+
+       @Override
+       public T copy(T from) {
+               return unwantedMethodCall("copy(T from)");
+       }
+
+       @Override
+       public T copy(T from, T reuse) {
+               return unwantedMethodCall("copy(T from, T reuse)");
+       }
+
+       @Override
+       public int getLength() {
+               return -1;
+       }
+
+       @Override
+       public T deserialize(T reuse, DataInputView source) throws IOException {
+               return unwantedMethodCall("deserialize(T reuse, DataInputView 
source)");
+       }
+
+       @Override
+       public void copy(DataInputView source, DataOutputView target) throws 
IOException {
+               unwantedMethodCall("copy(DataInputView source, DataOutputView 
target)");
+       }
+
+       private T unwantedMethodCall(String methodName) {
+               throw new RuntimeException(String.format("The method %s should 
not be called", methodName));
+       }
+
+       public abstract T createResult(int len);
+
+       public abstract void setField(T result, int index, Object value);
+
+       @Override
+       public T deserialize(DataInputView source) throws IOException {
 
 Review comment:
   Add some comments for this method. It would be quite helpful for other ones 
to understand.

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


With regards,
Apache Git Services

Reply via email to