dianfu commented on a change in pull request #11118: [FLINK-16072][python] Optimize the performance of the write/read null mask URL: https://github.com/apache/flink/pull/11118#discussion_r381766299
########## File path: flink-python/pyflink/fn_execution/coder_impl.py ########## @@ -24,57 +24,71 @@ from pyflink.table import Row +def generate_null_mask_search_table(): + """ + Each bit of one byte represents if the column at the specified position is None or not, e.g. + 0x84 represents the first column and the sixth column are None. + """ + num = 256 + null_mask = [] + for b in range(num): + every_num_null_mask = [(b & 0x80) > 0, (b & 0x40) > 0, (b & 0x20) > 0, (b & 0x10) > 0, + (b & 0x08) > 0, (b & 0x04) > 0, (b & 0x02) > 0, (b & 0x01) > 0] + null_mask.append(tuple(every_num_null_mask)) + + return tuple(null_mask) + + class FlattenRowCoderImpl(StreamCoderImpl): + null_mask_search_table = generate_null_mask_search_table() Review comment: What about make it an instance variable as it's faster than static variable: https://stackoverflow.com/questions/2714573/instance-variables-vs-class-variables-in-python ---------------------------------------------------------------- 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 With regards, Apache Git Services