Skip to content

Commit

Permalink
more sizebytes helpers for arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed May 27, 2024
1 parent 948b430 commit d90247d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/re_types_core/src/size_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ impl<T: SizeBytes> SizeBytes for Arc<T> {
}
}

impl<T: SizeBytes> SizeBytes for Box<T> {
#[inline]
fn heap_size_bytes(&self) -> u64 {
T::total_size_bytes(&**self)
}
}

// TODO(rust-lang/rust#31844): `impl<T: bytemuck::Pod> SizeBytesExt for T {}` would be nice but
// violates orphan rules.
macro_rules! impl_size_bytes_pod {
Expand Down Expand Up @@ -327,11 +334,19 @@ impl SizeBytes for Field {
}

impl SizeBytes for dyn Array {
#[inline]
fn heap_size_bytes(&self) -> u64 {
estimated_bytes_size(self) as _
}
}

impl SizeBytes for Box<dyn Array> {
#[inline]
fn heap_size_bytes(&self) -> u64 {
estimated_bytes_size(&**self as _) as _
}
}

// --- Arrow estimations ---

// The following is a modified version of [1], available under MIT OR Apache-2.0.
Expand Down

0 comments on commit d90247d

Please sign in to comment.