Expand description
§FloatArray Module - Mid-Level, Inner Typed Float Array
Arrow-compatible, SIMD-aligned floating-point array optimised for analytical workloads.
§Overview
- Logical type: fixed-width floats (
T: Float). - Physical storage:
Buffer<T>(backed byVec64<T>for 64-byte alignment) plus optional Arrow-style validity mask (Bitmask). - Usable standalone or as the floating-point arm of higher-level enums (
NumericArray,Array). - Supports both explicit null masks and NaN-as-null semantics (at the caller’s discretion).
- Zero-copy compatible with standard
Vecand slice types.
§Features
- Construction from slices,
Vec, orVec64, with or without a null mask. - Mutation: push/set, bulk null insertion, resize.
- Iteration: safe and (optionally) parallel via the
MaskedArraytrait surface. - Display: formatted preview with numeric formatting helpers.
§Null Semantics
- Explicit mask: Arrow-compatible null representation (
1 = valid,0 = null). - NaN-based: one also has the option to skip the mask entirely and use
NaNas a sentinel for missing values (similar to Pandas/NumPy conventions), but this is not recommended as it is not a supported pattern in this library suite and therefore may yield unexpected results.
§Performance Benchmarks
Benchmarks under examples/hotloop_benchmark_std compare construction + sum over 1000 elems,
averaged across 1000 runs on a 2024 Intel(R) Core(TM) Ultra 7 155H (22 logical CPUs, 32 GB RAM).
Build note: use --release for representative numbers; debug builds distort results.
Averaged Results (1000 runs, size = 1000)
Vec<f64>(raw): avg = 0.632 µsFloatArray(minarrow, direct): avg = 0.636 µsFloat64Array(arrow-rs, struct): avg = 0.798 µsFloatArray(minarrow, enum): avg = 1.047 µsFloat64Array(arrow-rs, dynamic trait): avg = 1.255 µs
Takeaways
- Direct
FloatArraymatches rawVec<f64>performance while adding SIMD alignment + Arrow interop. - NaN-based null handling eliminates mask overhead in NaN-tolerant workflows.
- Enum wrapping adds small overhead but remains faster than arrow-rs dynamic dispatch.
- For latency-critical workloads, use direct
FloatArray; otherwise differences are negligible.
Structs§
- Float
Array - FloatArray