fn flat_slice_memory_size(array: &dyn Array) -> Option<usize>Expand description
Computes array.to_data().get_slice_memory_size() for flat arrays without building the
ArrayData.
The formulas mirror Arrow’s ArrayData::get_slice_memory_size (arrow-data 59.2.0,
get_slice_memory_size in arrow-data/src/data.rs):
- a fixed-width value buffer costs
len * byte_width, where the byte width is the one of the type’s buffer layout, as reported byDataType::primitive_width, - the value bitmap of a boolean array costs
ceil(len / 8), - the offsets buffer of a variable-width array holds
len + 1boundaries and costs(len + 1) * offset_width, - the visible value bytes of a variable-width array cost
offset[len] - offset[0], - the validity bitmap costs
ceil(len / 8), but only if the slice contains a null: converting an array toArrayDatadrops a validity bitmap without any null (ArrayDataBuilder::build), so Arrow only sees one whennull_countis non-zero.
Returns None for data types that are left to Arrow’s general computation (nested, view,
dictionary, union, FixedSizeBinary, Null, …) and when the size computation overflows
usize, which Arrow reports as an error. Callers must then fall back to Arrow.