Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Fixed error in memory usage of sliced binary/list/utf8arrays (#1293)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Nov 13, 2022
1 parent 484875a commit 48a5322
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/compute/aggregate/memory.rs
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 48a5322

Please sign in to comment.