#[repr(C, align(64))]pub enum NumericArray {
Int8(Arc<IntegerArray<i8>>),
Int16(Arc<IntegerArray<i16>>),
Int32(Arc<IntegerArray<i32>>),
Int64(Arc<IntegerArray<i64>>),
UInt8(Arc<IntegerArray<u8>>),
UInt16(Arc<IntegerArray<u16>>),
UInt32(Arc<IntegerArray<u32>>),
UInt64(Arc<IntegerArray<u64>>),
Float32(Arc<FloatArray<f32>>),
Float64(Arc<FloatArray<f64>>),
Null,
}Expand description
§NumericArray
Unified numerical array container
§Purpose
Exists to unify numerical operations, simplify API’s and streamline user ergonomics.
§Usage:
- It is accessible from
Arrayusing.num(), and provides typed variant access via for e.g.,.i64(), so one can drill down to the required granularity viamyarr.num().i64() - This streamlines function implementations,
and, despite the additional
enumlayer, matching lanes in many real-world scenarios. This is because one can for e.g., unify a function signature withimpl Into<NumericArray>, and all of the subtypes, plusArrayandNumericalArray, all qualify. - Additionally, you can then use one
Integerimplementation on the enum dispatch arm for allIntegervariants, or, in many cases, for the entire numeric arm when they are the same.
§Typecasting behaviour
- If the enum already holds the given type (which should be known at compile-time),
then using accessors like
.i32()is zero-cost, as it transfers ownership. - If you want to keep the original, of course use
.clone()beforehand. - If you use an accessor to a different base type, e.g.,
.f32()when it’s a.int32()already in the enum, it will convert it. Therefore, be mindful of performance when this occurs.
§Also see:
- Under crate::traits::type_unions , we additionally
include minimal
Integer,Float,NumericandPrimitivetraits that for which the base Rust primitive types already qualify. These are loose wrappers over thenum-traitscrate to help improve type ergonomics when traits are required, but without requiring any downcasting.
Variants§
Int8(Arc<IntegerArray<i8>>)
Int16(Arc<IntegerArray<i16>>)
Int32(Arc<IntegerArray<i32>>)
Int64(Arc<IntegerArray<i64>>)
UInt8(Arc<IntegerArray<u8>>)
UInt16(Arc<IntegerArray<u16>>)
UInt32(Arc<IntegerArray<u32>>)
UInt64(Arc<IntegerArray<u64>>)
Float32(Arc<FloatArray<f32>>)
Float64(Arc<FloatArray<f64>>)
Null
Implementations§
Source§impl NumericArray
impl NumericArray
Sourcepub fn append_array(&mut self, other: &Self)
pub fn append_array(&mut self, other: &Self)
Appends all values (and null mask if present) from other into self.
Panics if the two arrays are of different variants or incompatible types.
This function uses copy-on-write semantics for arrays wrapped in Arc.
If self is the only owner of its data, appends are performed in place without copying.
If the array data is shared (Arc reference count > 1), the data is first cloned
(so the mutation does not affect other owners), and the append is then performed on the unique copy.
This ensures that calling append_array never mutates data referenced elsewhere,
but also avoids unnecessary cloning when the data is uniquely owned.
Sourcepub fn insert_rows(
&mut self,
index: usize,
other: &Self,
) -> Result<(), MinarrowError>
pub fn insert_rows( &mut self, index: usize, other: &Self, ) -> Result<(), MinarrowError>
Inserts all values (and null mask if present) from other into self at the specified index.
This is an O(n) operation.
Returns an error if the two arrays are of different variants or incompatible types, or if the index is out of bounds.
This function uses copy-on-write semantics for arrays wrapped in Arc.
Sourcepub fn split(self, index: usize) -> Result<(Self, Self), MinarrowError>
pub fn split(self, index: usize) -> Result<(Self, Self), MinarrowError>
Splits the NumericArray at the specified index, consuming self and returning two arrays.
Sourcepub fn i32_ref(&self) -> Result<&IntegerArray<i32>, MinarrowError>
pub fn i32_ref(&self) -> Result<&IntegerArray<i32>, MinarrowError>
Returns a reference to the inner IntegerArray<i32> if the variant matches.
No conversion or cloning is performed.
Sourcepub fn i64_ref(&self) -> Result<&IntegerArray<i64>, MinarrowError>
pub fn i64_ref(&self) -> Result<&IntegerArray<i64>, MinarrowError>
Returns a reference to the inner IntegerArray<i64> if the variant matches.
No conversion or cloning is performed.
Sourcepub fn u32_ref(&self) -> Result<&IntegerArray<u32>, MinarrowError>
pub fn u32_ref(&self) -> Result<&IntegerArray<u32>, MinarrowError>
Returns a reference to the inner IntegerArray<u32> if the variant matches.
No conversion or cloning is performed.
Sourcepub fn u64_ref(&self) -> Result<&IntegerArray<u64>, MinarrowError>
pub fn u64_ref(&self) -> Result<&IntegerArray<u64>, MinarrowError>
Returns a reference to the inner IntegerArray<u64> if the variant matches.
No conversion or cloning is performed.
Sourcepub fn f32_ref(&self) -> Result<&FloatArray<f32>, MinarrowError>
pub fn f32_ref(&self) -> Result<&FloatArray<f32>, MinarrowError>
Returns a reference to the inner FloatArray<f32> if the variant matches.
No conversion or cloning is performed.
Sourcepub fn f64_ref(&self) -> Result<&FloatArray<f64>, MinarrowError>
pub fn f64_ref(&self) -> Result<&FloatArray<f64>, MinarrowError>
Returns a reference to the inner FloatArray<f64> if the variant matches.
No conversion or cloning is performed.
Sourcepub fn i32(self) -> Result<IntegerArray<i32>, MinarrowError>
pub fn i32(self) -> Result<IntegerArray<i32>, MinarrowError>
Convert to IntegerArray
Sourcepub fn i64(self) -> Result<IntegerArray<i64>, MinarrowError>
pub fn i64(self) -> Result<IntegerArray<i64>, MinarrowError>
Convert to IntegerArray
Sourcepub fn u32(self) -> Result<IntegerArray<u32>, MinarrowError>
pub fn u32(self) -> Result<IntegerArray<u32>, MinarrowError>
Convert to IntegerArray
Sourcepub fn u64(self) -> Result<IntegerArray<u64>, MinarrowError>
pub fn u64(self) -> Result<IntegerArray<u64>, MinarrowError>
Convert to IntegerArray
Sourcepub fn f32(self) -> Result<FloatArray<f32>, MinarrowError>
pub fn f32(self) -> Result<FloatArray<f32>, MinarrowError>
Convert to FloatArray
Sourcepub fn f64(self) -> Result<FloatArray<f64>, MinarrowError>
pub fn f64(self) -> Result<FloatArray<f64>, MinarrowError>
Convert to FloatArray
Sourcepub fn bool(self) -> Result<BooleanArray<u8>, MinarrowError>
pub fn bool(self) -> Result<BooleanArray<u8>, MinarrowError>
Converts to BooleanArray
All non-zero values become true, but the null mask is preserved.
Sourcepub fn str(self) -> Result<StringArray<u32>, MinarrowError>
pub fn str(self) -> Result<StringArray<u32>, MinarrowError>
Converts to StringArray
Preserves Null mask.
Trait Implementations§
Source§impl ByteSize for NumericArray
ByteSize for NumericArray enum
impl ByteSize for NumericArray
ByteSize for NumericArray enum
Source§impl Clone for NumericArray
impl Clone for NumericArray
Source§fn clone(&self) -> NumericArray
fn clone(&self) -> NumericArray
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Concatenate for NumericArray
impl Concatenate for NumericArray
Source§impl Debug for NumericArray
impl Debug for NumericArray
Source§impl Default for NumericArray
impl Default for NumericArray
Source§fn default() -> NumericArray
fn default() -> NumericArray
Source§impl Display for NumericArray
impl Display for NumericArray
Source§impl From<NumericArray> for NumericArrayV
impl From<NumericArray> for NumericArrayV
Source§fn from(array: NumericArray) -> Self
fn from(array: NumericArray) -> Self
Source§impl PartialEq for NumericArray
impl PartialEq for NumericArray
Source§impl Shape for NumericArray
impl Shape for NumericArray
impl StructuralPartialEq for NumericArray
Auto Trait Implementations§
impl Freeze for NumericArray
impl RefUnwindSafe for NumericArray
impl Send for NumericArray
impl Sync for NumericArray
impl Unpin for NumericArray
impl UnsafeUnpin for NumericArray
impl UnwindSafe for NumericArray
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomValue for T
impl<T> CustomValue for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.