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§
Sourcefn as_slice(&self) -> &[T::Native]
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.
Sourcefn from_values(values: Vec<T::Native>) -> Self
fn from_values(values: Vec<T::Native>) -> Self
Construct an array from a vector of values.
Provided Methods§
Sourcefn from_iter_values(values: impl IntoIterator<Item = T::Native>) -> Selfwhere
Self: Sized,
fn from_iter_values(values: impl IntoIterator<Item = T::Native>) -> Selfwhere
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
impl FloatArray<BFloat16Type> for FixedSizeBinaryArray
Source§fn as_slice(&self) -> &[bf16]
fn as_slice(&self) -> &[bf16]
Returns the underlying bf16 values as a borrowed slice.
§Preconditions
value_length()must be 2 (theFixedSizeBinary(2)storage shape used byBFloat16Array). 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’sALIGNMENTconstant, ≥32 bytes) or viaBuffer::from_vec::<u16>(aligned toalign_of::<u16>()== 2); both meetbf16’s 2-byte requirement. Externally-builtFixedSizeBinaryArrays arriving via FFI, IPC, orBuffer::from_custom_allocationare not required by arrow-rs to be aligned beyond a single byte; passing one to this method violates the precondition. Adebug_assertbelow 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).