PCTEJA commented on code in PR #4505:
URL: https://github.com/apache/iceberg-python/pull/4505#discussion_r4760055904


##########
pyiceberg/io/pyarrow.py:
##########
@@ -3233,14 +3245,43 @@ def bin_pack_record_batches(batches: 
Iterable[pa.RecordBatch], target_file_size:
         ``ParquetWriter`` with ``OutputStream.tell()`` (#2998).
     """
     buffer: list[pa.RecordBatch] = []
-    buffer_bytes = 0
+    buffer_bytes = 0.0
     for batch in batches:
-        buffer.append(batch)
-        buffer_bytes += batch.nbytes
-        if buffer_bytes >= target_file_size:
-            yield buffer
-            buffer = []
-            buffer_bytes = 0
+        if batch.num_rows == 0:
+            buffer.append(batch)
+            continue
+        offset = 0
+        while offset < batch.num_rows:
+            remaining_rows = batch.num_rows - offset
+            space = target_file_size - buffer_bytes
+            fit = remaining_rows if batch.nbytes == 0 else int(space * 
batch.num_rows / batch.nbytes)

Review Comment:
   060c41d cached 



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

Reply via email to