sandy-sachin7 opened a new pull request, #12418:
URL: https://github.com/apache/arrow-rs/pull/12418

   # Which issue does this PR close?
   
   - Closes #12393
   
   # Rationale for this change
   
   When writing `FixedLenByteArray` (such as `Decimal128`) or `ByteArray` 
values sliced from a shared per-write `Bytes` buffer (as `ArrowWriter`'s 
`chunk_contiguous_vec` does), `update_min` / `update_max` / `update_stat` 
stored `val.clone()` in page and column-chunk statistics. While #12027 detached 
statistics on `close()`, open writers still retained a reference to the entire 
per-write arena buffer until the row group was flushed, inflating peak heap 
memory across concurrent open writers.
   
   # What changes are included in this PR?
   
   - Added a crate-private `clone_detached(&self) -> Self` method with default 
`self.clone()` on the sealed `private::ParquetValueType` trait in 
`parquet/src/data_type.rs`.
   - Overrode `clone_detached` for `ByteArray` and `FixedLenByteArray` to copy 
only the value's own slice via `Bytes::copy_from_slice`.
   - Updated `update_min`, `update_max`, and `update_stat` in 
`parquet/src/column/writer/mod.rs` to call `val.clone_detached()` instead of 
`val.clone()` (only when a min/max value is initialized or replaced).
   - Added unit tests 
`test_fixed_len_byte_array_stats_do_not_pin_shared_buffer` and 
`test_byte_array_stats_do_not_pin_shared_buffer` verifying that dropping a 
written batch while the column writer remains open releases the shared `Bytes` 
arena (`probe.try_into_mut().is_ok()`).
   
   # Are these changes tested?
   
   Yes — two new unit tests in `parquet/src/column/writer/mod.rs` reproduce the 
shared-buffer retention for both `FixedLenByteArray` (chunk statistics) and 
`ByteArray` (page + chunk statistics) before `close()`, fail without the fix, 
and pass alongside all existing `column::writer::tests`.
   
   # Are there any significant user-facing changes?
   
   No.
   
   # AI usage disclosure
   
   An AI coding assistant was used to help draft the implementation, regression 
tests, and PR description; all changes and test results were reviewed and 
verified locally.


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