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

Commit

Permalink
Added memory estimation Union.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Aug 14, 2021
1 parent 52112e8 commit eec97ca
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/compute/aggregate/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,22 @@ pub fn estimated_bytes_size(array: &dyn Array) -> usize {
.sum::<usize>()
+ validity_size(array.validity())
}
Union(_, _, _) => unreachable!(),
Union(_, _, _) => {
let array = array.as_any().downcast_ref::<UnionArray>().unwrap();
let types = array.types().len() * std::mem::size_of::<i8>();
let offsets = array
.offsets()
.as_ref()
.map(|x| x.len() * std::mem::size_of::<i32>())
.unwrap_or_default();
let fields = array
.fields()
.iter()
.map(|x| x.as_ref())
.map(estimated_bytes_size)
.sum::<usize>();
types + offsets + fields
}
Dictionary(keys, _) => match keys.as_ref() {
Int8 => dyn_dict!(array, i8),
Int16 => dyn_dict!(array, i16),
Expand Down

0 comments on commit eec97ca

Please sign in to comment.