KonaeAkira commented on code in PR #23648:
URL: https://github.com/apache/datafusion/pull/23648#discussion_r3602428224
##########
datafusion/physical-plan/src/aggregates/group_values/multi_group_by/list.rs:
##########
@@ -218,20 +214,11 @@ impl<O: OffsetSizeTrait> GroupColumn for
ListGroupValueBuilder<O> {
let cut_offset = self.offsets[n];
let cut = cut_offset.as_usize();
- // First-n offsets: 0, off[1], ..., off[n].
- let first_n_offsets: Vec<O> = self.offsets[..=n].to_vec();
-
- // Remaining offsets shifted so that what was offsets[n] becomes 0.
- // Overwrite the array in place.
- // SAFETY: the write range is at most as large as offsets.len().
- // Values in the possible overlap are read before being overwritten.
- unsafe {
- let dst = self.offsets.as_mut_ptr();
- for (i, &off) in self.offsets[n..].iter().enumerate() {
- *dst.add(i) = off - cut_offset;
- }
- }
- self.offsets.truncate(self.offsets.len() - n);
Review Comment:
One more thing that just occurred to me: `split_vec_min_alloc(&mut
self.offsets, n)` returns a vector with exact capacity in case `n * 2 <=
self.offsets.len()`:
https://github.com/apache/datafusion/blob/fb8fe7ae61efc12c6c09a00d025e35c750e2ee86/datafusion/common/src/utils/mod.rs#L405-L412
in which case `first_n_offsets.push(cut_offset);` will always reallocate,
which is bad.
This affects `bytes.rs` as well.
--
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]