You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/12/04 08:24:11 UTC

[GitHub] [flink] WeiZhong94 commented on a change in pull request #10086: [FLINK-14584][python] Support complex data types in Python user-defined functions

WeiZhong94 commented on a change in pull request #10086: [FLINK-14584][python] Support complex data types in Python user-defined functions
URL: https://github.com/apache/flink/pull/10086#discussion_r353088625
 
 

 ##########
 File path: flink-python/pyflink/fn_execution/coders.py
 ##########
 @@ -68,6 +70,98 @@ def __hash__(self):
         return hash(self._field_coders)
 
 
+class CollectionCoder(FastCoder):
+    """
+    Base coder for collection.
+    """
+    def __init__(self, elem_coder):
+        self._elem_coder = elem_coder
+
+    def _create_impl(self):
+        return self._impl_coder()(self._elem_coder.get_impl())
+
+    def _impl_coder(self):
+        raise NotImplementedError
+
+    def is_deterministic(self):
+        return self._elem_coder.is_deterministic()
+
+    def to_type_hint(self):
+        return []
+
+    def __eq__(self, other):
+        return (self.__class__ == other.__class__
+                and self._elem_coder == other._elem_coder)
+
+    def __repr__(self):
+        return '%s[%s]' % (self.__class__.__name__, str(self._elem_coder))
+
+    def __ne__(self, other):
+        return not self == other
+
+    def __hash__(self):
+        return hash(self._elem_coder)
+
+
+class ArrayCoder(CollectionCoder):
+    """
+    Coder for Array.
+    """
+
+    def __init__(self, elem_coder):
+        self._elem_coder = elem_coder
+        super(ArrayCoder, self).__init__(elem_coder)
+
+    def _impl_coder(self):
 
 Review comment:
   How about override _create_impl directly?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services