Skip to main content

Module float

Module float 

Source
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 by Vec64<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 Vec and slice types.

§Features

  • Construction from slices, Vec, or Vec64, with or without a null mask.
  • Mutation: push/set, bulk null insertion, resize.
  • Iteration: safe and (optionally) parallel via the MaskedArray trait 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 NaN as 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 µs
  • FloatArray (minarrow, direct): avg = 0.636 µs
  • Float64Array (arrow-rs, struct): avg = 0.798 µs
  • FloatArray (minarrow, enum): avg = 1.047 µs
  • Float64Array (arrow-rs, dynamic trait): avg = 1.255 µs

Takeaways

  • Direct FloatArray matches raw Vec<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§

FloatArray
FloatArray