pub trait ByteSize {
// Required methods
fn est_bytes(&self) -> usize;
fn logical_bytes(&self) -> usize;
}Expand description
Trait for estimating the memory footprint of a type.
Returns the estimated number of bytes occupied by the object in memory, including all owned data buffers, masks, and nested structures.
For types with directly calculatable sizes (e.g., n * size_of::<T>()),
this returns the exact value. For complex types, this provides a best estimate.
Required Methods§
Sourcefn est_bytes(&self) -> usize
fn est_bytes(&self) -> usize
Returns the estimated byte size of this object in memory.
This includes:
- Data buffers (values, offsets, indices)
- Null masks (bitmaps)
- Dictionary data (for categorical types)
- Nested structures (for recursive types)
Does not include:
- Stack size of the struct itself (only heap allocations)
- Arc pointer overhead (counted once per allocation, not per reference)
Sourcefn logical_bytes(&self) -> usize
fn logical_bytes(&self) -> usize
Returns the exact logical byte size of the data.
The figure counts the bytes the values occupy in Arrow buffer terms.
Value buffers count len * element_width, offsets count
(len + 1) * offset_width, null masks count ceil(len / 8)
and dictionaries count their summed string contents. Capacity slack
left behind by buffer growth is excluded, which is the difference
from est_bytes. That method reports the
memory footprint of the allocations, where this one reports the
data itself, so callers use it for throughput denominators and
wire-size planning where the figure must match the payload.
Views report the window they cover rather than the backing array.
§Warning
The non-Arrow numerical container types (Matrix, NdArray and their chunked
and view forms, plus XArray) do not yet define logical byte
accounting currently and panic with unimplemented! when called.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl ByteSize for Array
ByteSize for Array enum
impl ByteSize for ArrayV
views only.ByteSize for ArrayV - proportional estimate from underlying array
impl ByteSize for Bitmask
ByteSize for Bitmask - bit-packed bitmask
impl ByteSize for Cube
cube only.impl ByteSize for Field
ByteSize for Field - metadata only, minimal size
impl ByteSize for FieldArray
ByteSize for FieldArray - field metadata + array data
impl ByteSize for Matrix
matrix only.impl ByteSize for NumericArray
ByteSize for NumericArray enum
impl ByteSize for Scalar
scalar_type and value_type only.ByteSize for Scalar (when scalar_type feature is enabled)
impl ByteSize for SuperArray
chunked only.impl ByteSize for SuperArrayV
chunked and views only.ByteSize for SuperArrayV - sum of slice estimates
impl ByteSize for SuperTable
chunked only.impl ByteSize for SuperTableV
chunked and views only.ByteSize for SuperTableV - sum of slice estimates
impl ByteSize for Table
ByteSize for Table - sum of all column arrays
impl ByteSize for TableV
views only.ByteSize for TableV - sum of column view estimates
impl ByteSize for TemporalArray
datetime only.ByteSize for TemporalArray enum (when datetime feature is enabled)
impl ByteSize for TextArray
ByteSize for TextArray enum
impl ByteSize for Value
value_type only.ByteSize for Value enum - delegates to inner types
impl<T: Float> ByteSize for NdArrayV<T>
ndarray and views only.impl<T: Float> ByteSize for SuperNdArrayV<T>
chunked and ndarray and views only.impl<T: Float> ByteSize for XArray<T>
xarray only.impl<T: Integer> ByteSize for CategoricalArray<T>
ByteSize for CategoricalArray
impl<T> ByteSize for BooleanArray<T>
ByteSize for BooleanArray
impl<T> ByteSize for Buffer<T>
ByteSize for Buffer
impl<T> ByteSize for DatetimeArray<T>
datetime only.impl<T> ByteSize for FloatArray<T>
ByteSize for FloatArray
impl<T> ByteSize for IntegerArray<T>
ByteSize for IntegerArray
impl<T> ByteSize for NdArray<T>
ndarray only.impl<T> ByteSize for StringArray<T>
ByteSize for StringArray
impl<T> ByteSize for SuperNdArray<T>
chunked and ndarray only.impl<T> ByteSize for Vec64<T>
ByteSize for Vec64