Skip to main content

ByteSize

Trait ByteSize 

Source
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§

Source

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)
Source

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§

Source§

impl ByteSize for Array

ByteSize for Array enum

Source§

impl ByteSize for ArrayV

Available on crate feature views only.

ByteSize for ArrayV - proportional estimate from underlying array

Source§

impl ByteSize for Bitmask

ByteSize for Bitmask - bit-packed bitmask

Source§

impl ByteSize for Cube

Available on crate feature cube only.
Source§

impl ByteSize for Field

ByteSize for Field - metadata only, minimal size

Source§

impl ByteSize for FieldArray

ByteSize for FieldArray - field metadata + array data

Source§

impl ByteSize for Matrix

Available on crate feature matrix only.
Source§

impl ByteSize for NumericArray

ByteSize for NumericArray enum

Source§

impl ByteSize for Scalar

Available on crate features scalar_type and value_type only.

ByteSize for Scalar (when scalar_type feature is enabled)

Source§

impl ByteSize for SuperArray

Available on crate feature chunked only.
Source§

impl ByteSize for SuperArrayV

Available on crate features chunked and views only.

ByteSize for SuperArrayV - sum of slice estimates

Source§

impl ByteSize for SuperTable

Available on crate feature chunked only.
Source§

impl ByteSize for SuperTableV

Available on crate features chunked and views only.

ByteSize for SuperTableV - sum of slice estimates

Source§

impl ByteSize for Table

ByteSize for Table - sum of all column arrays

Source§

impl ByteSize for TableV

Available on crate feature views only.

ByteSize for TableV - sum of column view estimates

Source§

impl ByteSize for TemporalArray

Available on crate feature datetime only.

ByteSize for TemporalArray enum (when datetime feature is enabled)

Source§

impl ByteSize for TextArray

ByteSize for TextArray enum

Source§

impl ByteSize for Value

Available on crate feature value_type only.

ByteSize for Value enum - delegates to inner types

Source§

impl<T: Float> ByteSize for NdArrayV<T>

Available on crate features ndarray and views only.
Source§

impl<T: Float> ByteSize for SuperNdArrayV<T>

Available on crate features chunked and ndarray and views only.
Source§

impl<T: Float> ByteSize for XArray<T>

Available on crate feature xarray only.
Source§

impl<T: Integer> ByteSize for CategoricalArray<T>

ByteSize for CategoricalArray

Source§

impl<T> ByteSize for BooleanArray<T>

ByteSize for BooleanArray

Source§

impl<T> ByteSize for Buffer<T>

ByteSize for Buffer - unified owned/shared buffer

Source§

impl<T> ByteSize for DatetimeArray<T>

Available on crate feature datetime only.
Source§

impl<T> ByteSize for FloatArray<T>

ByteSize for FloatArray

Source§

impl<T> ByteSize for IntegerArray<T>

ByteSize for IntegerArray

Source§

impl<T> ByteSize for NdArray<T>

Available on crate feature ndarray only.
Source§

impl<T> ByteSize for StringArray<T>

ByteSize for StringArray

Source§

impl<T> ByteSize for SuperNdArray<T>

Available on crate features chunked and ndarray only.
Source§

impl<T> ByteSize for Vec64<T>

ByteSize for Vec64 - 64-byte aligned vector