SteNicholas commented on a change in pull request #13983:
URL: https://github.com/apache/flink/pull/13983#discussion_r530141360



##########
File path: flink-python/pyflink/datastream/utils.py
##########
@@ -0,0 +1,75 @@
+################################################################################
+#  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/LICENSE2.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.
+################################################################################
+import ast
+import datetime
+import pickle
+
+from pyflink.common import typeinfo
+from pyflink.common.typeinfo import WrapperTypeInfo, RowTypeInfo, Types, 
BasicArrayTypeInfo, \
+    PrimitiveArrayTypeInfo
+from pyflink.java_gateway import get_gateway
+
+
+def convert_to_python_obj(data, type_info):
+    if type_info is None:
+        return pickle.loads(data)
+    else:
+        gateway = get_gateway()
+        pickle_bytes = gateway.jvm.PythonBridgeUtils. \
+            getPickledBytesFromJavaObject(data, type_info.get_java_type_info())
+        pickle_bytes = list(pickle_bytes[1:])
+        field_data = zip(pickle_bytes, type_info.types)
+        fields = []
+        for data, field_type in field_data:
+            if len(data) == 0:
+                fields.append(None)
+            else:
+                fields.append(java_to_python_converter(data, field_type))
+        return tuple(fields)
+
+
+def java_to_python_converter(data, field_type: WrapperTypeInfo):

Review comment:
       @shuiqiangchen , I refer to the method `java_to_python_converter` in 
table, which also converts pickled bytes to python object. Therefore, the 
naming of this method should be unified.




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


Reply via email to