dianfu commented on a change in pull request #9977: [FLINK-14497][python]
Support primitive data types in Python user-defined functions
URL: https://github.com/apache/flink/pull/9977#discussion_r338396893
##########
File path: flink-python/pyflink/fn_execution/coders.py
##########
@@ -62,21 +63,229 @@ def __hash__(self):
return hash(self._field_coders)
+class LongCoder(FastCoder):
+ """
+ Coder for 8 bytes long
+ """
+
+ def _create_impl(self):
+ return coder_impl.LongCoderImpl()
+
+ def is_deterministic(self):
+ return True
+
+ def to_type_hint(self):
+ return int
+
+ def __repr__(self):
+ return 'LongCoder'
+
+
+class ByteCoder(FastCoder):
+ """
+ Coder for Byte.
+ """
+
+ def _create_impl(self):
+ return coder_impl.ByteCoderImpl()
+
+ def is_deterministic(self):
+ return True
+
+ def to_type_hint(self):
+ return int
+
+ def __repr__(self):
+ return 'ByteCoder'
+
+
+class ShortCoder(FastCoder):
+ """
+ Coder for Short.
+ """
+
+ def _create_impl(self):
+ return coder_impl.ShortCoderImpl()
+
+ def is_deterministic(self):
+ return True
+
+ def to_type_hint(self):
+ return int
+
+ def __repr__(self):
+ return 'ShortCoder'
+
+
+class IntCoder(FastCoder):
+ """
+ Coder for 4 bytes int
+ """
+
+ def _create_impl(self):
+ return coder_impl.IntCoderImpl()
+
+ def is_deterministic(self):
+ return True
+
+ def to_type_hint(self):
+ return int
+
+ def __repr__(self):
+ return 'IntCoder'
+
+
+class BooleanCoder(FastCoder):
+ """
+ Coder for Boolean
+ """
+
+ def _create_impl(self):
+ return coder_impl.BooleanCoderImpl()
+
+ def is_deterministic(self):
+ return True
+
+ def to_type_hint(self):
+ return bool
+
+ def __repr__(self):
+ return 'BooleanCoder'
+
+
+class FloatCoder(FastCoder):
+ """
+ Coder for Float.
+ """
+
+ def _create_impl(self):
+ return coder_impl.FloatCoderImpl()
+
+ def is_deterministic(self):
+ return True
+
+ def to_type_hint(self):
+ return float
+
+ def __repr__(self):
+ return 'FloatCoder'
+
+
+class DoubleCoder(FastCoder):
+ """
+ Coder for Double.
+ """
+
+ def _create_impl(self):
+ return coder_impl.DoubleCoderImpl()
+
+ def is_deterministic(self):
+ return True
+
+ def to_type_hint(self):
+ return float
+
+ def __repr__(self):
+ return 'DoubleCoder'
+
+
+class BinaryCoder(FastCoder):
+ """
+ Coder for Binary String
Review comment:
bytearray?
----------------------------------------------------------------
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