ranflarion opened a new pull request, #12509:
URL: https://github.com/apache/arrow-rs/pull/12509

   # Which issue does this PR close?
   
   - Closes #12508.
   
   # Rationale for this change
   
   `BatchCoalescer` cuts output batches by rows only, so wide rows give batches 
of hundreds of MB: 8,192 rows of 10,000 `Float64` columns are 655 MB. A caller 
cannot bound them from outside, because the builders allocate 
`target_batch_size` values per column for every batch, so a batch finished 
early still holds full-size buffers.
   
   # What changes are included in this PR?
   
   - `BatchCoalescer::with_target_batch_bytes` and a `target_batch_bytes` 
getter. With a target, the row loop of `push_batch`, the direct filter copy and 
the direct indexed copy also complete a batch once the buffered rows reach the 
target. Each row counts as an equal share of its input batch, measured with 
`ArrayData::get_slice_memory_size` (falling back to `get_array_memory_size` for 
layouts it does not size).
   - A batch above the target no longer takes the `biggest_coalesce_batch_size` 
bypass.
   - `InProgressArray::set_batch_size`, called when a batch is started under a 
byte target, so the primitive, boolean, byte, fixed-size binary and view 
builders allocate for the rows that batch is expected to hold.
   
   Two limits. Rows of one input batch that differ a lot in size can take a 
batch past the target. `get_slice_memory_size` counts the whole child of a 
sliced list, so sliced list inputs give smaller batches than the target allows.
   
   # Are these changes tested?
   
   Yes, eight tests in `arrow-select/src/coalesce.rs`: cutting wide rows, 
including that the output buffers are allocated for the cut batch; coalescing 
across input batches; a row larger than the target; narrow rows still reaching 
`target_batch_size`; a stream whose row width changes; the interaction with 
`biggest_coalesce_batch_size`; and the filter and indexed push paths.
   
   No benchmark is included. Without a target the push paths do no extra work 
per row, and I have not measured the cost of sizing each pushed batch when a 
target is set.
   
   # Are there any significant user-facing changes?
   
   Two new public methods on `BatchCoalescer`. Nothing changes unless a target 
is set.
   
   # AI usage disclosure
   
   AI tools were used to write the code, tests and this description. I own this 
change.
   


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

Reply via email to