dianfu commented on a change in pull request #11374: [FLINK-16524][python] 
Optimize the result of FlattenRowCoder and ArrowCoder to generator to eliminate 
unnecessary function calls
URL: https://github.com/apache/flink/pull/11374#discussion_r392012728
 
 

 ##########
 File path: flink-python/pyflink/fn_execution/coder_impl.py
 ##########
 @@ -414,5 +446,28 @@ def create_array(s, t):
         arrays = [create_array(cols[i], self._schema.types[i]) for i in 
range(0, len(self._schema))]
         return pa.RecordBatch.from_arrays(arrays, self._schema)
 
+    def _create_result(self, in_stream: create_InputStream) -> List:
+        self._resettable_io.set_input_bytes(in_stream.read_all(True))
+        # there is only arrow batch in the underlying input stream
+        table = pa.Table.from_batches([next(self._batch_reader)])
+        return [c.to_pandas(date_as_object=True) for c in table.itercolumns()]
+
     def __repr__(self):
         return 'ArrowCoderImpl[%s]' % self._schema
+
+
+class CustomLengthPrefixCoderImpl(StreamCoderImpl):
+    def __init__(self, value_coder):
+        self._value_coder = value_coder
+
+    def encode_to_stream(self, value, out: create_OutputStream, nested: bool) 
-> Any:
+        self._value_coder.encode_to_stream(value, out, nested)
+
+    def decode_from_stream(self, in_stream: create_InputStream, nested: bool) 
-> Any:
+        return self._value_coder.decode_from_stream(in_stream, False)
 
 Review comment:
   decode_from_stream(in_stream, False) -> decode_from_stream(in_stream, 
nested) ?

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