pub fn estimated_bytes_size(array: &dyn Array) -> usize {
    use DataType::*;
    match array.data_type() {
        Null => 0,
        Boolean => {
            let array = array.as_any().downcast_ref::<BooleanArray>().unwrap();
            array.values().bytes().len() + validity_size(array.validity())
        }
        Int8 => dyn_primitive!(array, i8),
        Int16 => dyn_primitive!(array, i16),
        Int32 | Date32 | Time32(_) | Interval(IntervalUnit::YearMonth) => {
            dyn_primitive!(array, i32)
        }
        Int64 | Date64 | Timestamp(_, _) | Time64(_) | Duration(_) => dyn_primitive!(array, i64),
        UInt8 => dyn_primitive!(array, u16),
        UInt16 => dyn_primitive!(array, u16),
        UInt32 => dyn_primitive!(array, u32),
        UInt64 => dyn_primitive!(array, u64),
        Float16 => unreachable!(),
        Float32 => dyn_primitive!(array, f32),
        Float64 => dyn_primitive!(array, f64),
        Decimal(_, _) => dyn_primitive!(array, i128),
        Interval(IntervalUnit::DayTime) => dyn_primitive!(array, days_ms),
        Binary => dyn_binary!(array, BinaryArray<i32>, i32),
        FixedSizeBinary(_) => {
            let array = array
                .as_any()
                .downcast_ref::<FixedSizeBinaryArray>()
                .unwrap();
            array.values().len() + validity_size(array.validity())
        }
        LargeBinary => dyn_binary!(array, BinaryArray<i64>, i64),
        Utf8 => dyn_binary!(array, Utf8Array<i32>, i32),
        LargeUtf8 => dyn_binary!(array, Utf8Array<i64>, i64),
        List(_) => {
            let array = array.as_any().downcast_ref::<ListArray<i32>>().unwrap();
            estimated_bytes_size(array.values().as_ref())
                + array.offsets().len() * std::mem::size_of::<i32>()
                + validity_size(array.validity())
        }
        FixedSizeList(_, _) => {
            let array = array.as_any().downcast_ref::<ListArray<i64>>().unwrap();
            estimated_bytes_size(array.values().as_ref()) + validity_size(array.validity())
        }
        LargeList(_) => {
            let array = array.as_any().downcast_ref::<ListArray<i64>>().unwrap();
            estimated_bytes_size(array.values().as_ref())
                + array.offsets().len() * std::mem::size_of::<i64>()
                + validity_size(array.validity())
        }
        Struct(_) => {
            let array = array.as_any().downcast_ref::<StructArray>().unwrap();
            array
                .values()
                .iter()
                .map(|x| x.as_ref())
                .map(estimated_bytes_size)
                .sum::<usize>()
                + validity_size(array.validity())
        }
        Union(_) => unreachable!(),
        Dictionary(keys, _) => match keys.as_ref() {
            Int8 => dyn_dict!(array, i8),
            Int16 => dyn_dict!(array, i16),
            Int32 => dyn_dict!(array, i32),
            Int64 => dyn_dict!(array, i64),
            UInt8 => dyn_dict!(array, u8),
            UInt16 => dyn_dict!(array, u16),
            UInt32 => dyn_dict!(array, u32),
            UInt64 => dyn_dict!(array, u64),
            _ => unreachable!(),
        },
    }
}
/// Returns the total (heap) allocated size of the array in bytes.
/// # Implementation
/// This estimation is the sum of the size of its buffers, validity, including nested arrays.
/// Multiple arrays may share buffers and bitmaps. Therefore, the size of 2 arrays is not the
/// sum of the sizes computed from this function. In particular, [`StructArray`]'s size is an upper bound.
///
/// When an array is sliced, its allocated size remains constant because the buffer unchanged.
/// However, this function will yield a smaller number. This is because this function returns
/// the visible size of the buffer, not its total capacity.
///
/// FFI buffers are included in this estimation.
Returns the total (heap) allocated size of the array in bytes.
Returns the total ( heap ) allocated size of the array in bytes .
pub fn estimated_bytes_size(array: &dyn Array) -> usize {
    use DataType::*;
    match array.data_type() {
        Null => 0,
        Boolean => {
            let array = array.as_any().downcast_ref::<BooleanArray>().unwrap();
            array.values().bytes().len() + validity_size(array.validity())
        }
        Int8 => dyn_primitive!(array, i8),
        Int16 => dyn_primitive!(array, i16),
        Int32 | Date32 | Time32(_) | Interval(IntervalUnit::YearMonth) => {
            dyn_primitive!(array, i32)
        }
        Int64 | Date64 | Timestamp(_, _) | Time64(_) | Duration(_) => dyn_primitive!(array, i64),
        UInt8 => dyn_primitive!(array, u16),
        UInt16 => dyn_primitive!(array, u16),
        UInt32 => dyn_primitive!(array, u32),
        UInt64 => dyn_primitive!(array, u64),
        Float16 => unreachable!(),
        Float32 => dyn_primitive!(array, f32),
        Float64 => dyn_primitive!(array, f64),
        Decimal(_, _) => dyn_primitive!(array, i128),
        Interval(IntervalUnit::DayTime) => dyn_primitive!(array, days_ms),
        Binary => dyn_binary!(array, BinaryArray<i32>, i32),
        FixedSizeBinary(_) => {
            let array = array
                .as_any()
                .downcast_ref::<FixedSizeBinaryArray>()
                .unwrap();
            array.values().len() + validity_size(array.validity())
        }
        LargeBinary => dyn_binary!(array, BinaryArray<i64>, i64),
        Utf8 => dyn_binary!(array, Utf8Array<i32>, i32),
        LargeUtf8 => dyn_binary!(array, Utf8Array<i64>, i64),
        List(_) => {
            let array = array.as_any().downcast_ref::<ListArray<i32>>().unwrap();
            estimated_bytes_size(array.values().as_ref())
                + array.offsets().len() * std::mem::size_of::<i32>()
                + validity_size(array.validity())
        }
        FixedSizeList(_, _) => {
            let array = array.as_any().downcast_ref::<ListArray<i64>>().unwrap();
            estimated_bytes_size(array.values().as_ref()) + validity_size(array.validity())
        }
        LargeList(_) => {
            let array = array.as_any().downcast_ref::<ListArray<i64>>().unwrap();
            estimated_bytes_size(array.values().as_ref())
                + array.offsets().len() * std::mem::size_of::<i64>()
                + validity_size(array.validity())
        }
        Struct(_) => {
            let array = array.as_any().downcast_ref::<StructArray>().unwrap();
            array
                .values()
                .iter()
                .map(|x| x.as_ref())
                .map(estimated_bytes_size)
                .sum::<usize>()
                + validity_size(array.validity())
        }
        Union(_) => unreachable!(),
        Dictionary(keys, _) => match keys.as_ref() {
            Int8 => dyn_dict!(array, i8),
            Int16 => dyn_dict!(array, i16),
            Int32 => dyn_dict!(array, i32),
            Int64 => dyn_dict!(array, i64),
            UInt8 => dyn_dict!(array, u8),
            UInt16 => dyn_dict!(array, u16),
            UInt32 => dyn_dict!(array, u32),
            UInt64 => dyn_dict!(array, u64),
            _ => unreachable!(),
        },
    }
}
pub fn estimated_bytes_size ( array : & dyn Array ) -> usize { use DataType :: * ; match array . data_type ( ) { Null => 0 , Boolean => { let array = array . as_any ( ) . downcast_ref :: < BooleanArray > ( ) . unwrap ( ) ; array . values ( ) . bytes ( ) . len ( ) + validity_size ( array . validity ( ) ) } Int8 => dyn_primitive ! ( array i8 ) , Int16 => dyn_primitive ! ( array i16 ) , Int32 | Date32 | Time32 ( _ ) | Interval ( IntervalUnit :: YearMonth ) => { dyn_primitive ! ( array i32 ) } Int64 | Date64 | Timestamp ( _ , _ ) | Time64 ( _ ) | Duration ( _ ) => dyn_primitive ! ( array i64 ) , UInt8 => dyn_primitive ! ( array u16 ) , UInt16 => dyn_primitive ! ( array u16 ) , UInt32 => dyn_primitive ! ( array u32 ) , UInt64 => dyn_primitive ! ( array u64 ) , Float16 => unreachable ! ( ) , Float32 => dyn_primitive ! ( array f32 ) , Float64 => dyn_primitive ! ( array f64 ) , Decimal ( _ , _ ) => dyn_primitive ! ( array i128 ) , Interval ( IntervalUnit :: DayTime ) => dyn_primitive ! ( array days_ms ) , Binary => dyn_binary ! ( array BinaryArray i32 i32 ) , FixedSizeBinary ( _ ) => { let array = array . as_any ( ) . downcast_ref :: < FixedSizeBinaryArray > ( ) . unwrap ( ) ; array . values ( ) . len ( ) + validity_size ( array . validity ( ) ) } LargeBinary => dyn_binary ! ( array BinaryArray i64 i64 ) , Utf8 => dyn_binary ! ( array Utf8Array i32 i32 ) , LargeUtf8 => dyn_binary ! ( array Utf8Array i64 i64 ) , List ( _ ) => { let array = array . as_any ( ) . downcast_ref :: < ListArray < i32 > > ( ) . unwrap ( ) ; estimated_bytes_size ( array . values ( ) . as_ref ( ) ) + array . offsets ( ) . len ( ) * std :: mem :: size_of :: < i32 > ( ) + validity_size ( array . validity ( ) ) } FixedSizeList ( _ , _ ) => { let array = array . as_any ( ) . downcast_ref :: < ListArray < i64 > > ( ) . unwrap ( ) ; estimated_bytes_size ( array . values ( ) . as_ref ( ) ) + validity_size ( array . validity ( ) ) } LargeList ( _ ) => { let array = array . as_any ( ) . downcast_ref :: < ListArray < i64 > > ( ) . unwrap ( ) ; estimated_bytes_size ( array . values ( ) . as_ref ( ) ) + array . offsets ( ) . len ( ) * std :: mem :: size_of :: < i64 > ( ) + validity_size ( array . validity ( ) ) } Struct ( _ ) => { let array = array . as_any ( ) . downcast_ref :: < StructArray > ( ) . unwrap ( ) ; array . values ( ) . iter ( ) . map ( | x | x . as_ref ( ) ) . map ( estimated_bytes_size ) . sum :: < usize > ( ) + validity_size ( array . validity ( ) ) } Union ( _ ) => unreachable ! ( ) , Dictionary ( keys , _ ) => match keys . as_ref ( ) { Int8 => dyn_dict ! ( array i8 ) , Int16 => dyn_dict ! ( array i16 ) , Int32 => dyn_dict ! ( array i32 ) , Int64 => dyn_dict ! ( array i64 ) , UInt8 => dyn_dict ! ( array u8 ) , UInt16 => dyn_dict ! ( array u16 ) , UInt32 => dyn_dict ! ( array u32 ) , UInt64 => dyn_dict ! ( array u64 ) , _ => unreachable ! ( ) , } , } }
Returns the total (heap) allocated size of the array in bytes.
Returns the total ( heap ) allocated size of the array in bytes .
array
&dyn Array
implementation
This estimation is the sum of the size of its buffers, validity, including nested arrays.
Multiple arrays may share buffers and bitmaps. Therefore, the size of 2 arrays is not the
sum of the sizes computed from this function. In particular, [`StructArray`]'s size is an upper bound.

When an array is sliced, its allocated size remains constant because the buffer unchanged.
However, this function will yield a smaller number. This is because this function returns
the visible size of the buffer, not its total capacity.

FFI buffers are included in this estimation.
This estimation is the sum of the size of its buffers validity including nested arrays . Multiple arrays may share buffers and bitmaps . Therefore the size of 2 arrays is not the sum of the sizes computed from this function . In particular [ ` StructArray ` ] ' s size is an upper bound . When an array is sliced its allocated size remains constant because the buffer unchanged . However this function will yield a smaller number . This is because this function returns the visible size of the buffer not its total capacity . FFI buffers are included in this estimation .