mzabaluev commented on code in PR #23648:
URL: https://github.com/apache/datafusion/pull/23648#discussion_r3602302229


##########
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:
   @KonaeAkira if we're going into micro-benchmarking territory, the previous 
code might be better in smaller take case when the remaining vector is drained 
in place, because it's subtract-while-copying vs. copy, then subtract in place. 
But this highly depends on vectorization, and the other case benefits from a 
smaller alloc-and-copy. Maybe there needs to be another split helper with a map 
closure to address both cases.



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