Skip to content

Commit

Permalink
Fixed error in memory usage of sliced binary/list/utf8arrays (jorgeca…
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Mar 29, 2023
1 parent d4f3906 commit b652400
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/compute/aggregate/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ fn validity_size(validity: Option<&Bitmap>) -> usize {
macro_rules! dyn_binary {
($array:expr, $ty:ty, $o:ty) => {{
let array = $array.as_any().downcast_ref::<$ty>().unwrap();
let offsets = array.offsets();

array.values().len()
+ array.offsets().len() * std::mem::size_of::<$o>()
// in case of Binary/Utf8/List the offsets are sliced,
// not the values buffer
let values_start = offsets[0] as usize;
let values_end = offsets[offsets.len() - 1] as usize;

values_end - values_start
+ offsets.len() * std::mem::size_of::<$o>()
+ validity_size(array.validity())
}};
}
Expand Down

0 comments on commit b652400

Please sign in to comment.