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

   # Which issue does this PR close?
   
   - Closes #11669
   
   # Rationale for this change
   
   When zipping two scalar `StringView` or `BinaryView` values (directly with 
`zip` or via `ScalarZipper`), each scalar represents a single value, so it can 
reference at most one buffer (zero buffers if inlined, or one buffer if 
out-of-line).
   
   Previously, zipping cloned and retained the entire `data_buffers()` slice 
from each scalar array. When scalars were sliced from larger multi-buffer 
arrays, unreferenced buffers stayed alive in both `ScalarZipper` and every 
output array it produced.
   
   # What changes are included in this PR?
   
   In `arrow-select/src/zip.rs`:
   
   - Normalize each non-null scalar in `ByteViewScalarImpl` to hold only the 
single `Buffer` it references (none for inline or null scalars; one buffer with 
`buffer_index` rewritten to `0` for out-of-line scalars).
   - Emit `0` buffers for empty (`len == 0`) or all-inline outputs, `1` buffer 
when both out-of-line scalars reference the same buffer (`Buffer::ptr_eq`), and 
`2` buffers when they reference distinct buffers.
   - Assert empty `data_buffers()` in existing sliced-inline tests and add unit 
tests covering multi-buffer `StringViewArray` and `BinaryViewArray` slices, 
shared buffers, single non-null scalars with null masks, empty masks, and 
`ScalarZipper` reuse.
   
   # Are these changes tested?
   
   Yes. Existing and new unit tests are included in `arrow_select::zip::test`:
   
   - `test_zip_kernel_scalar_strings_array_view_sliced_inline` (now asserts 
`data_buffers().is_empty()`)
   - `test_zip_kernel_scalar_binary_array_view_sliced_inline_max_len` (now 
asserts `data_buffers().is_empty()`)
   - `test_zip_scalar_byte_view_only_retains_referenced_buffers`
   - `test_zip_scalar_byte_view_single_non_null_buffer_retention`
   - `test_scalar_zipper_byte_view_reuse_minimal_buffers`
   
   # Are there any significant user-facing changes?
   
   No breaking API changes. Output arrays from `zip` and `ScalarZipper` on 
`StringView` and `BinaryView` scalars now retain only the buffers actually 
referenced by the output views (`0`, `1`, or `2` buffers).
   
   # AI usage disclosure
   
   AI coding assistance was used to draft the implementation, unit tests, and 
PR description; all code changes and test results were reviewed by the author.
   


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