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_r392004453
##########
File path: flink-python/pyflink/fn_execution/coder_impl.py
##########
@@ -51,18 +55,27 @@ def generate_null_mask_search_table():
return tuple(null_mask)
- def encode_to_stream(self, value, out_stream, nested):
- self.write_null_mask(value, out_stream)
+ def encode_to_stream(self, iter_value, out_stream, nested):
field_coders = self._field_coders
- for i in range(self._filed_count):
- item = value[i]
- if item is not None:
- field_coders[i].encode_to_stream(item, out_stream, nested)
+ data_out_stream = self.data_out_stream
+ for value in iter_value:
+ self.write_null_mask(value, data_out_stream)
+ for i in range(self._filed_count):
+ item = value[i]
+ if item is not None:
+ field_coders[i].encode_to_stream(item, data_out_stream,
nested)
+ out_stream.write_var_int64(data_out_stream.size())
+ out_stream.write(data_out_stream.get())
+ data_out_stream._clear()
def decode_from_stream(self, in_stream, nested):
+ while in_stream.size() > 0:
+ yield self.create_result(in_stream, nested)
+
+ def create_result(self, in_stream: create_InputStream, nested: bool) ->
List:
Review comment:
rename to _decode_one_row_from_stream?
----------------------------------------------------------------
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