viirya commented on code in PR #52391:
URL: https://github.com/apache/spark/pull/52391#discussion_r2396370292
##########
python/pyspark/sql/pandas/serializers.py:
##########
@@ -1630,8 +1633,23 @@ def row_stream():
yield (batch_key, row)
for batch_key, group_rows in groupby(row_stream(), key=lambda x:
x[0]):
- df = pd.DataFrame([row for _, row in group_rows])
- yield (batch_key, df)
+ rows = []
+ accumulate_size = 0
+ for _, row in group_rows:
+ rows.append(row)
+ # Short circuit batch size calculation if the batch size is
+ # unlimited as computing batch size is computationally
expensive.
+ if self.arrow_max_bytes_per_batch != 2**31 - 1:
+ accumulate_size += sum(sys.getsizeof(x) for x in row)
Review Comment:
Hmm, is `sys.getsizeof` accurate for nested type columns?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]