Skip to main content

FloatArray

Trait FloatArray 

Source
pub trait FloatArray<T: ArrowFloatType + ?Sized>:
    Array
    + Clone
    + 'static {
    type FloatType: ArrowFloatType;

    // Required methods
    fn as_slice(&self) -> &[T::Native];
    fn from_values(values: Vec<T::Native>) -> Self;

    // Provided method
    fn from_iter_values(values: impl IntoIterator<Item = T::Native>) -> Self
       where Self: Sized { ... }
}
Expand description

FloatArray is a trait that is implemented by all float type arrays

This is similar to arrow_array::PrimitiveArray but applies to all float types (including bfloat16) and is implemented as a trait and not a struct

Required Associated Types§

Required Methods§

Source

fn as_slice(&self) -> &[T::Native]

Returns a reference to the underlying data as a slice.

§Panics

Implementations may panic if the array’s storage shape does not match the expected element layout. In particular, the bf16 impl panics if value_length() != 2 (the FixedSizeBinary(2) shape required by BFloat16Array).

§Preconditions

Implementations may impose additional invariants on the underlying buffer. The bf16 impl requires the value buffer to be at least 2-byte aligned — satisfied automatically by every in-tree Lance constructor, but external callers passing externally-built arrays (FFI, IPC, Buffer::from_custom_allocation) must ensure alignment. See the impl’s docstring for details.

Source

fn from_values(values: Vec<T::Native>) -> Self

Construct an array from a vector of values.

Provided Methods§

Source

fn from_iter_values(values: impl IntoIterator<Item = T::Native>) -> Self
where Self: Sized,

Construct an array from an iterator of values.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FloatArray<BFloat16Type> for FixedSizeBinaryArray

Source§

fn as_slice(&self) -> &[bf16]

Returns the underlying bf16 values as a borrowed slice.

§Preconditions
  • value_length() must be 2 (the FixedSizeBinary(2) storage shape used by BFloat16Array). Asserted at entry.
  • The value buffer must be at least 2-byte aligned. Lance’s in-tree constructors always satisfy this: value buffers are built either via MutableBuffer (aligned to arrow-buffer’s ALIGNMENT constant, ≥32 bytes) or via Buffer::from_vec::<u16> (aligned to align_of::<u16>() == 2); both meet bf16’s 2-byte requirement. Externally-built FixedSizeBinaryArrays arriving via FFI, IPC, or Buffer::from_custom_allocation are not required by arrow-rs to be aligned beyond a single byte; passing one to this method violates the precondition. A debug_assert below catches such inputs in debug and test builds.
§Endianness

lance-arrow is gated on target_endian = "little" at the crate root, so this method always returns values in the same byte order Lance writes (see BFloat16Array::value and the FromIterator impls).

Source§

type FloatType = BFloat16Type

Source§

fn from_values(values: Vec<bf16>) -> Self

Source§

impl FloatArray<Float16Type> for Float16Array

Source§

impl FloatArray<Float32Type> for Float32Array

Source§

impl FloatArray<Float64Type> for Float64Array

Implementors§