Skip to content

Commit

Permalink
x2
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Oct 10, 2024
1 parent c7aa11f commit 576cc32
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion datafusion/functions-aggregate/src/min_max/min_max_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,11 @@ impl MinMaxBytesState {
fn set_value(&mut self, group_index: usize, new_val: &[u8]) {
match self.min_max[group_index].as_mut() {
None => {
self.min_max[group_index] = Some(new_val.to_vec());
// No existing value, so allocate a new one (allocate 2x the size of the input)
// to avoid re-allocating for small strings
let mut new_vec = Vec::with_capacity(new_val.len() * 2);
new_vec.extend_from_slice(new_val);
self.min_max[group_index] = Some(new_vec);
self.total_data_bytes += new_val.len();
}
Some(existing_val) => {
Expand Down

0 comments on commit 576cc32

Please sign in to comment.