#[repr(C, align(64))]pub enum Array {
NumericArray(NumericArray),
TextArray(TextArray),
TemporalArray(TemporalArray),
BooleanArray(Arc<BooleanArray<()>>),
Null,
}Expand description
§Array
Standard Array type. Wrap in a FieldArray when using inside a Table
or as a standalone value requiring tagged metadata.
§Overview
The dual-enum approach may look verbose but works well in practice:
- Enables clean function signatures with direct access to concrete types
(e.g.
&NumericArray), supporting trait-aligned dispatch without exhaustive matches at every call site. - Supports ergonomic categorisation: functions typically match on the outer enum for broad category handling (numeric, text, temporal, boolean), while allowing inner variant matching for precise type handling.
- The focused typeset (no nested types) helps keeps enum size efficient as memory is allocated for the largest variant.
§Usage
Functions can accept references tailored to the intended match granularity:
&IntegerArray: direct reference to the inner type e.g.,arr.num().i64().&NumericArray: any numeric type viaarr.num().&Array: match on categories or individual types.
§Benefits
- No heap allocation or runtime indirection - all enum variants are inline with minimal discriminant cost.
- Unified call sites with compiler-enforced type safety.
- Easy casting to inner types (e.g.,
.str()for strings). - Supports aggressive compiler inlining, unlike approaches relying on dynamic dispatch and downcasting.
§Trade-offs
- Adds ~30–100 ns latency compared to direct inner type calls - only noticeable in extreme low-latency contexts such as HFT.
- Requires enum matching at dispatch sites compared to direct inner type usage.
§Examples
use minarrow::{
Array, IntegerArray, NumericArray, arr_bool, arr_f64, arr_i32, arr_i64,
arr_str32, vec64
};
// Fast macro construction
let int_arr = arr_i32![1, 2, 3, 4];
let float_arr = arr_f64![0.5, 1.5, 2.5];
let bool_arr = arr_bool![true, false, true];
let str_arr = arr_str32!["a", "b", "c"];
assert_eq!(int_arr.len(), 4);
assert_eq!(str_arr.len(), 3);
// Manual construction
let int = IntegerArray::<i64>::from_slice(&[100, 200]);
let wrapped: NumericArray = NumericArray::Int64(std::sync::Arc::new(int));
let array = Array::NumericArray(wrapped);Variants§
NumericArray(NumericArray)
TextArray(TextArray)
TemporalArray(TemporalArray)
BooleanArray(Arc<BooleanArray<()>>)
Null
Implementations§
Source§impl Array
impl Array
Sourcepub fn from_int8(arr: IntegerArray<i8>) -> Self
pub fn from_int8(arr: IntegerArray<i8>) -> Self
Creates an Array enum with an Int8 array.
Sourcepub fn from_uint8(arr: IntegerArray<u8>) -> Self
pub fn from_uint8(arr: IntegerArray<u8>) -> Self
Creates an Array enum with an UInt8 array.
Sourcepub fn from_int16(arr: IntegerArray<i16>) -> Self
pub fn from_int16(arr: IntegerArray<i16>) -> Self
Creates an Array enum with an Int16 array.
Sourcepub fn from_uint16(arr: IntegerArray<u16>) -> Self
pub fn from_uint16(arr: IntegerArray<u16>) -> Self
Creates an Array enum with an UInt16 array.
Sourcepub fn from_int32(arr: IntegerArray<i32>) -> Self
pub fn from_int32(arr: IntegerArray<i32>) -> Self
Creates an Array enum with an Int32 array.
Sourcepub fn from_int64(arr: IntegerArray<i64>) -> Self
pub fn from_int64(arr: IntegerArray<i64>) -> Self
Creates an Array enum with an Int64 array.
Sourcepub fn from_uint32(arr: IntegerArray<u32>) -> Self
pub fn from_uint32(arr: IntegerArray<u32>) -> Self
Creates an Array enum with a UInt32 array.
Sourcepub fn from_uint64(arr: IntegerArray<u64>) -> Self
pub fn from_uint64(arr: IntegerArray<u64>) -> Self
Creates an Array enum with an UInt64 array.
Sourcepub fn from_float32(arr: FloatArray<f32>) -> Self
pub fn from_float32(arr: FloatArray<f32>) -> Self
Creates an Array enum with a Float32 array.
Sourcepub fn from_float64(arr: FloatArray<f64>) -> Self
pub fn from_float64(arr: FloatArray<f64>) -> Self
Creates an Array enum with a Float64 array.
Sourcepub fn from_string32(arr: StringArray<u32>) -> Self
pub fn from_string32(arr: StringArray<u32>) -> Self
Creates an Array enum with a String32 array.
Sourcepub fn from_string64(arr: StringArray<u64>) -> Self
pub fn from_string64(arr: StringArray<u64>) -> Self
Creates an Array enum with a String64 array.
Sourcepub fn from_categorical32(arr: CategoricalArray<u32>) -> Self
pub fn from_categorical32(arr: CategoricalArray<u32>) -> Self
Creates an Array enum with a Categorical32 array.
Sourcepub fn from_categorical8(arr: CategoricalArray<u8>) -> Self
pub fn from_categorical8(arr: CategoricalArray<u8>) -> Self
Creates an Array enum with a Categorical8 array.
Sourcepub fn from_categorical16(arr: CategoricalArray<u16>) -> Self
pub fn from_categorical16(arr: CategoricalArray<u16>) -> Self
Creates an Array enum with a Categorical16 array.
Sourcepub fn from_categorical64(arr: CategoricalArray<u64>) -> Self
pub fn from_categorical64(arr: CategoricalArray<u64>) -> Self
Creates an Array enum with a Categorical64 array.
Sourcepub fn from_datetime_i32(arr: DatetimeArray<i32>) -> Self
pub fn from_datetime_i32(arr: DatetimeArray<i32>) -> Self
Creates an Array enum with a DatetimeI32 array.
Sourcepub fn from_datetime_i64(arr: DatetimeArray<i64>) -> Self
pub fn from_datetime_i64(arr: DatetimeArray<i64>) -> Self
Creates an Array enum with a DatetimeI64 array.
Sourcepub fn from_bool(arr: BooleanArray<()>) -> Self
pub fn from_bool(arr: BooleanArray<()>) -> Self
Creates an Array enum with a Boolean array.
Sourcepub fn fa(self, name: impl Into<String>) -> FieldArray
pub fn fa(self, name: impl Into<String>) -> FieldArray
Wraps this Array in a FieldArray with the given name.
Infers the Arrow type and nullability from the array itself.
§Example
use minarrow::{Array, IntegerArray, MaskedArray};
let mut arr = IntegerArray::<i32>::default();
arr.push(1);
arr.push(2);
let array = Array::from_int32(arr);
let field_array = array.fa("my_column");
assert_eq!(field_array.field.name, "my_column");Sourcepub fn num(&self) -> NumericArray
pub fn num(&self) -> NumericArray
Returns an inner NumericArray.
- If already a
NumericArray, returns the inner value as a shared handle with no data copy. - Other types: casts and copies.
- Panics on
Null. Consider the try variant for a safe alternative.
Sourcepub fn try_num(&self) -> Result<NumericArray, MinarrowError>
pub fn try_num(&self) -> Result<NumericArray, MinarrowError>
Returns an inner NumericArray, with Err on Null.
- If already a
NumericArray, returns the inner value as a shared handle with no data copy. - Other types: casts and copies.
Sourcepub fn str(&self) -> TextArray
pub fn str(&self) -> TextArray
Returns an inner TextArray.
- If already a
TextArray, returns the inner value as a shared handle with no data copy. - Other types: casts (to string) and copies.
- Panics on
Null. Consider the try variant for a safe alternative.
Sourcepub fn try_str(&self) -> Result<TextArray, MinarrowError>
pub fn try_str(&self) -> Result<TextArray, MinarrowError>
Returns an inner TextArray, with Err on Null.
- If already a
TextArray, returns the inner value as a shared handle with no data copy. - Other types: casts (to string) and copies.
Sourcepub fn bool(&self) -> Arc<BooleanArray<()>> ⓘ
pub fn bool(&self) -> Arc<BooleanArray<()>> ⓘ
Returns the inner BooleanArray.
- If already a
BooleanArray, returns the inner value as a shared handle with no data copy. - Other types: calculates the boolean mask based on whether the value is present, and non-zero,
and copies. In these cases, any null mask is preserved, rather than becoming
false. - Panics on
Null. Consider the try variant for a safe alternative.
Sourcepub fn try_bool(&self) -> Result<Arc<BooleanArray<()>>, MinarrowError>
pub fn try_bool(&self) -> Result<Arc<BooleanArray<()>>, MinarrowError>
Returns the inner BooleanArray, with Err on Null.
- If already a
BooleanArray, returns the inner value as a shared handle with no data copy. - Other types: calculates the boolean mask based on whether the value is present, and non-zero,
and copies. In these cases, any null mask is preserved, rather than becoming
false.
Sourcepub fn dt(&self) -> TemporalArray
pub fn dt(&self) -> TemporalArray
Returns the inner TemporalArray.
- If already a
TemporalArray, returns the inner value as a shared handle with no data copy. - Other types: casts and (often) copies.
§Datetime conversions
- String parses a timestamp in milliseconds since the Unix epoch.
If the
datetime_opsfeature is on, it also attempts common ISO8601/RFC3339 and%Y-%m-%dformats. Keep this in mind, because your API will break if you toggle thedatetime_opsfeature on/off but keep the previous code. - Integer becomes milliseconds since epoch.
- Floats round as integers to milliseconds since epoch.
- Boolean returns
TemporalArray::Null.
Panics on Null. Consider the try variant for a safe alternative.
Sourcepub fn try_dt(&self) -> Result<TemporalArray, MinarrowError>
pub fn try_dt(&self) -> Result<TemporalArray, MinarrowError>
Returns the inner TemporalArray, with Err on Null.
- If already a
TemporalArray, returns the inner value as a shared handle with no data copy. - Other types: casts and (often) copies. See
dtfor the conversion rules.
Sourcepub fn delete_range(&mut self, start: usize, end: usize)
pub fn delete_range(&mut self, start: usize, end: usize)
Removes the rows in [start, end), shifting later rows left.
A shared inner array is cloned first i.e. copy-on-write.
§Panics
Panics if start > end or end > len.
Sourcepub fn push(&mut self, value: Scalar) -> Result<(), MinarrowError>
pub fn push(&mut self, value: Scalar) -> Result<(), MinarrowError>
The scalar is converted to the array’s element type. String and
categorical arrays take its text form, and categorical arrays intern it.
Returns an error when the value cannot be represented as the array’s type,
or the array is Null.
Mutation is copy-on-write. The inner array is held behind Arc, so a
uniquely owned array is mutated in place, while a shared array is cloned
once before the push and the mutation lands on the clone. An array becomes
shared when it is cloned or held inside another structure such as a Table.
Sourcepub fn push_null(&mut self) -> Result<(), MinarrowError>
pub fn push_null(&mut self) -> Result<(), MinarrowError>
Appends a null to the array. Returns an error when the array is Null.
Mutation is copy-on-write.
Sourcepub fn set(&mut self, idx: usize, value: Scalar) -> Result<(), MinarrowError>
pub fn set(&mut self, idx: usize, value: Scalar) -> Result<(), MinarrowError>
Sets the element at idx to value, converting it to the element type.
A Scalar::Null value masks the element null and leaves the buffer
contents in place.
Returns an error when the value cannot be represented as the array’s type,
or the array is Null. Mutation is copy-on-write.
Sourcepub fn set_range(
&mut self,
range: Range<usize>,
value: Scalar,
) -> Result<(), MinarrowError>
pub fn set_range( &mut self, range: Range<usize>, value: Scalar, ) -> Result<(), MinarrowError>
Sets every element in range to value, converting it to the element type.
The scalar converts once and each variant then writes through its own
typed buffer, so the per-element work carries no dispatch. A
Scalar::Null value masks the whole range null and leaves the buffer
contents in place. Categorical arrays intern the value into the
dictionary once and repeat its code across the range.
Returns an error when the value cannot be represented as the array’s
type, when the range reaches past the array’s length, or when the
array is Null. Mutation is copy-on-write.
Sourcepub fn view(&self, offset: usize, len: usize) -> ArrayV
pub fn view(&self, offset: usize, len: usize) -> ArrayV
Returns a metadata view and reference over the specified window of this array.
Does not slice the object (yet).
Panics if out of bounds.
Sourcepub fn view_tuple(&self, offset: usize, len: usize) -> ArrayVT<'_>
pub fn view_tuple(&self, offset: usize, len: usize) -> ArrayVT<'_>
Returns a metadata view and reference over the specified window of this array.
Does not slice the object (yet).
Panics if out of bounds.
Sourcepub fn gather_indices(&self, indices: &[usize]) -> Array
pub fn gather_indices(&self, indices: &[usize]) -> Array
Gather the elements at the given indices into a new materialised Array.
Sourcepub fn gather_mask(&self, mask: &Bitmask) -> Array
pub fn gather_mask(&self, mask: &Bitmask) -> Array
Gather the elements at set mask bits into a new materialised Array.
The mask must match the array length.
Sourcepub fn inner<T: 'static>(&self) -> &Arc<T> ⓘ
pub fn inner<T: 'static>(&self) -> &Arc<T> ⓘ
Returns a reference to the inner array as type Arc<T>.
This is compile-time safe if T matches the actual payload, but will panic otherwise.
Prefer .inner_check() for Option-based pattern.
Sourcepub fn inner_mut<T: 'static>(&mut self) -> &mut Arc<T> ⓘ
pub fn inner_mut<T: 'static>(&mut self) -> &mut Arc<T> ⓘ
Returns a mutable reference to the inner array as type T.
This method is compile-time safe when the type T matches the actual inner type,
but relies on TypeId checks and unsafe casting. If an incorrect type is specified,
this will panic at runtime.
Prefer inner_check_mut if you want an Option-based version that avoids panics.
Sourcepub fn inner_check<T: 'static>(&self) -> Option<&Arc<T>>
pub fn inner_check<T: 'static>(&self) -> Option<&Arc<T>>
Returns a reference to the inner array as type T, if the type matches.
This method performs a runtime TypeId check to verify that the provided type T
corresponds to the actual inner variant. If the types match, returns Some(&T);
otherwise, returns None without panicking.
Use when the type of the variant is uncertain at compile time.
Sourcepub fn inner_check_mut<T: 'static>(&mut self) -> Option<&mut Arc<T>>
pub fn inner_check_mut<T: 'static>(&mut self) -> Option<&mut Arc<T>>
Returns a mutable reference to the inner array as type T, if the type matches.
This method performs a runtime TypeId check to verify that the provided type T
corresponds to the actual inner variant. If the types match, returns Some(&mut T);
otherwise, returns None without panicking.
Use when the type of the variant is uncertain at compile time.
pub fn as_slice<T>(&self, offset: usize, len: usize) -> &[T]
pub fn slice_raw<T: 'static>(&self, offset: usize, len: usize) -> Option<&[T]>
Sourcepub fn slice_clone(&self, offset: usize, len: usize) -> Self
pub fn slice_clone(&self, offset: usize, len: usize) -> Self
Returns a new Array of the same variant sliced to the given offset and length
.
Copies the data of the scoped range that’s selected.
If out-of-bounds, returns Self::Null. All null mask, offsets, etc. are trimmed.
Sourcepub fn arrow_type(&self) -> ArrowType
pub fn arrow_type(&self) -> ArrowType
Arrow physical type for this array.
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Column nullability
Sourcepub fn is_categorical_array(&self) -> bool
pub fn is_categorical_array(&self) -> bool
Returns true if this is a categorical array.
Sourcepub fn is_string_array(&self) -> bool
pub fn is_string_array(&self) -> bool
Returns true if this is a string array i.e. non-categorical text.
Sourcepub fn is_text_array(&self) -> bool
pub fn is_text_array(&self) -> bool
Returns true if this is any text array, string or categorical.
Sourcepub fn is_boolean_array(&self) -> bool
pub fn is_boolean_array(&self) -> bool
Returns true if this is a boolean array.
Sourcepub fn is_integer_array(&self) -> bool
pub fn is_integer_array(&self) -> bool
Returns true if this is an integer array.
Sourcepub fn is_float_array(&self) -> bool
pub fn is_float_array(&self) -> bool
Returns true if this is a floating-point array.
Sourcepub fn is_numerical_array(&self) -> bool
pub fn is_numerical_array(&self) -> bool
Returns true if this is any numeric array, integer or float.
Sourcepub fn is_datetime_array(&self) -> bool
pub fn is_datetime_array(&self) -> bool
Returns true if this is a datetime/temporal array.
Sourcepub fn has_nulls(&self) -> bool
pub fn has_nulls(&self) -> bool
Returns true when the array holds at least one null.
Delegates straight to the variant’s has_nulls, which itself resolves
to the inner array’s MaskedArray::has_nulls. Null is treated as
empty and reports no nulls.
Sourcepub fn value_to_string(&self, idx: usize) -> String
pub fn value_to_string(&self, idx: usize) -> String
Format the element at idx as a human-readable string.
Returns "null" for null elements. Uses the same formatting as
the array’s Display implementation.
Sourcepub fn get<T: MaskedArray + 'static>(
&self,
idx: usize,
) -> Option<T::CopyType<'_>>
pub fn get<T: MaskedArray + 'static>( &self, idx: usize, ) -> Option<T::CopyType<'_>>
Returns the value at index idx, or None if out of bounds or null.
Sourcepub unsafe fn get_unchecked<T: MaskedArray + 'static>(
&self,
idx: usize,
) -> Option<T::CopyType<'_>>
pub unsafe fn get_unchecked<T: MaskedArray + 'static>( &self, idx: usize, ) -> Option<T::CopyType<'_>>
Returns the value at index idx (unchecked).
§Safety
The caller is responsible for ensuring idx is within valid length
bounds. No bounds check is performed.
Sourcepub fn get_str(&self, idx: usize) -> Option<&str>
pub fn get_str(&self, idx: usize) -> Option<&str>
Returns the string value at index idx, or None if out of bounds or null.
Sourcepub unsafe fn get_str_unchecked(&self, idx: usize) -> Option<&str>
pub unsafe fn get_str_unchecked(&self, idx: usize) -> Option<&str>
Returns the string value at index idx.
§Safety
The caller is responsible for ensuring idx is within valid length
bounds. No bounds check is performed. Still returns None if null.
Sourcepub fn get_scalar(&self, idx: usize) -> Option<Scalar>
pub fn get_scalar(&self, idx: usize) -> Option<Scalar>
Extract the element at idx as a Scalar, or None if out of bounds.
Returns Scalar::Null for null elements.
Sourcepub fn null_array(arrow_type: &ArrowType, n_rows: usize) -> Array
pub fn null_array(arrow_type: &ArrowType, n_rows: usize) -> Array
Create an all-null array of the given ArrowType with n_rows elements.
The data buffer is zero-filled and every element is masked as null. For datetime types, set the time_unit on the returned array afterwards.
Sourcepub fn from_arrow_dtype(dtype: &ArrowType) -> Array
pub fn from_arrow_dtype(dtype: &ArrowType) -> Array
Zero-row Array of the given ArrowType, built from each variant’s Default.
Sourcepub fn from_scalars(scalars: &[Scalar]) -> Array
pub fn from_scalars(scalars: &[Scalar]) -> Array
Build an array from a slice of Scalars.
All scalars must be the same type. The type is inferred from the first
non-Null element. If all elements are Null, returns Array::Null.
Sourcepub fn compare_at(&self, i: usize, j: usize) -> Ordering
pub fn compare_at(&self, i: usize, j: usize) -> Ordering
Compare two elements within the same array by index.
Uses total ordering for floats via total_cmp(). Nulls sort last:
null > any value, null == null.
Sourcepub fn value_eq(&self, idx: usize, other: &Array, other_idx: usize) -> bool
pub fn value_eq(&self, idx: usize, other: &Array, other_idx: usize) -> bool
Performs a normalised equality check between two element positions, intended for cases where industry consistency trumps for e.g., standards such as IEEE. Examples include NaN equals NaN, -0.0 equals 0.0, and potentially other minor cases depending on the type variants. See documentation below for the accommodations specific to each type:
- Null equals null.
- Comparisons across different array variants return false.
- Floats normalise NaN equality, so any NaN equals any NaN, and -0.0
equals 0.0 per IEEE
==. - Integers and booleans compare with plain
==. - Text values compare as their resolved strings, so two categorical arrays with different dictionaries still compare correctly.
- Temporal values compare on the raw stored value. Reconciling time units is the caller’s concern, to avoid expensive repetitive checks on a known type.
Sourcepub fn hash_element_at<H: Hasher>(&self, idx: usize, state: &mut H)
pub fn hash_element_at<H: Hasher>(&self, idx: usize, state: &mut H)
Hash the element at idx into the provided hasher.
Null elements hash a fixed dummy value. Floats hash every NaN bit
pattern as one value and -0.0 as 0.0 so values that compare equal
under value_eq also hash equal.
Sourcepub fn set_null_mask(&mut self, mask: Bitmask)
pub fn set_null_mask(&mut self, mask: Bitmask)
Set null mask on Array by matching on variants
Sourcepub fn data_ptr_and_byte_len(&self) -> (*const u8, usize, usize)
pub fn data_ptr_and_byte_len(&self) -> (*const u8, usize, usize)
Returns a pointer to the backing data (contiguous bytes), length in elements, and element size.
This is not logical length - it is total raw bytes in the buffer, so for non-fixed width types such as bit-packed booleans or strings, please factor this in accordingly.
Sourcepub fn null_mask_ptr_and_byte_len(&self) -> Option<(*const u8, usize)>
pub fn null_mask_ptr_and_byte_len(&self) -> Option<(*const u8, usize)>
Returns a pointer to the null mask and its length in bytes, if present.
Sourcepub fn offsets_ptr_and_len(&self) -> Option<(*const u8, usize)>
pub fn offsets_ptr_and_len(&self) -> Option<(*const u8, usize)>
Offsets pointer/len for variable-length types
Sourcepub fn null_count(&self) -> usize
pub fn null_count(&self) -> usize
Returns the null count of the array
Sourcepub fn concat_array(&mut self, other: &Self)
pub fn concat_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 the first array.
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.
The second array is allocated into the buffer, which is standard.
Sourcepub fn concat_array_range(
&mut self,
other: &Self,
offset: usize,
len: usize,
) -> Result<(), MinarrowError>
pub fn concat_array_range( &mut self, other: &Self, offset: usize, len: usize, ) -> Result<(), MinarrowError>
Appends rows [offset..offset+len) from another array into self.
Extends data and null masks directly from the source range.
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.
Sourcepub fn split(
self,
index: usize,
field: &Arc<Field>,
) -> Result<SuperArray, MinarrowError>
pub fn split( self, index: usize, field: &Arc<Field>, ) -> Result<SuperArray, MinarrowError>
Splits the Array at the specified index, consuming self and returning a SuperArray with two FieldArray chunks.
Splits the underlying buffers (via vec .split_off()), allocating new storage for the second half.
More efficient than cloning the entire array but requires allocation.
Sourcepub fn to_apache_arrow(&self, name: &str) -> ArrayRef
pub fn to_apache_arrow(&self, name: &str) -> ArrayRef
Build an arrow-rs ArrayRef, deriving a Field from the array shape.
Panics on FFI failure. For a fallible variant returning
Result<_, MinarrowError>, see Array::try_to_apache_arrow.
For Timestamp/Time/Duration/Interval, wrap in a FieldArray with the
desired Field and use FieldArray::to_apache_arrow().
Sourcepub fn try_to_apache_arrow(&self, name: &str) -> Result<ArrayRef, MinarrowError>
pub fn try_to_apache_arrow(&self, name: &str) -> Result<ArrayRef, MinarrowError>
Fallible variant of Array::to_apache_arrow.
Sourcepub fn to_polars(&self, name: &str) -> Series
pub fn to_polars(&self, name: &str) -> Series
Build a Polars Series, deriving a Field from the array shape.
Panics on FFI failure. For a fallible variant, see
Array::try_to_polars.
For Timestamp/Time/Duration/Interval, wrap in a FieldArray with the
desired Field and use FieldArray::to_polars().
Sourcepub fn try_to_polars(&self, name: &str) -> Result<Series, MinarrowError>
pub fn try_to_polars(&self, name: &str) -> Result<Series, MinarrowError>
Fallible variant of Array::to_polars.
Sourcepub fn from_apache_arrow(arr: &ArrayRef) -> Array
pub fn from_apache_arrow(arr: &ArrayRef) -> Array
Import an arrow-rs ArrayRef into a Minarrow Array.
The recovered Field (dtype + nullable + metadata) is dropped. Use
crate::FieldArray::from_apache_arrow to preserve it.
Panics on FFI failure. For a fallible variant, see
Array::try_from_apache_arrow.
Sourcepub fn try_from_apache_arrow(arr: &ArrayRef) -> Result<Array, MinarrowError>
pub fn try_from_apache_arrow(arr: &ArrayRef) -> Result<Array, MinarrowError>
Fallible variant of Array::from_apache_arrow.
Sourcepub fn from_polars(s: &Series) -> Array
pub fn from_polars(s: &Series) -> Array
Import a Polars Series into a Minarrow Array.
A polars Series is inherently multi-chunked; the canonical mapping
is Series <-> crate::SuperArray. This helper routes through
crate::SuperArray::from_polars and then consolidates the
chunks into a single contiguous, 64-byte aligned buffer. The series
name and recovered Field metadata are dropped on the way through;
use crate::FieldArray::from_polars to preserve them.
§Performance note
Two separate costs to be aware of:
-
Alignment copy: Polars data is typically 8-byte aligned (per the Arrow spec default), while Minarrow uses 64-byte aligned
Vec64<T>buffers for SIMD. Most of the time this results in a memory copy to realign on import, unless the source data happens to be pre-aligned to 64 bytes. The FFI hand-off itself is pointer-level zero-copy; the realignment is done byBuffer::from_sharedwhen the source isn’t 64-byte aligned. -
Consolidation copy: Multi-chunk Series are merged into a single contiguous buffer, which is a second O(n) allocation and copy pass. Single-chunk Series (e.g. after
s.rechunk()on the caller side) skip this step. The consolidation itself is cheap on Linux when thevmap64feature is enabled.
In practice you should expect at least one full allocation + copy
when importing polars data into an Array. If you would like to
preserve the original chunk boundaries and avoid the consolidation
step, use crate::SuperArray::from_polars directly - though the
alignment copy will still occur per chunk that isn’t pre-aligned.
Panics on FFI failure. For a fallible variant, see
Array::try_from_polars.
Sourcepub fn try_from_polars(s: &Series) -> Result<Array, MinarrowError>
pub fn try_from_polars(s: &Series) -> Result<Array, MinarrowError>
Fallible variant of Array::from_polars.
Trait Implementations§
Source§impl Concatenate for Array
impl Concatenate for Array
Source§impl<'a> From<&'a Array> for BitmaskV<'a>
Extract the boolean data from an Array. Panics if not a BooleanArray variant.
impl<'a> From<&'a Array> for BitmaskV<'a>
Extract the boolean data from an Array. Panics if not a BooleanArray variant.
Source§impl From<Arc<CategoricalArray<u8>>> for Array
Available on crate feature default_categorical_8 only.
impl From<Arc<CategoricalArray<u8>>> for Array
default_categorical_8 only.Source§impl From<Arc<CategoricalArray<u16>>> for Array
Available on crate feature extended_categorical only.
impl From<Arc<CategoricalArray<u16>>> for Array
extended_categorical only.Source§impl From<Arc<CategoricalArray<u32>>> for Array
Available on crate feature extended_categorical or non-crate feature default_categorical_8 only.
impl From<Arc<CategoricalArray<u32>>> for Array
extended_categorical or non-crate feature default_categorical_8 only.Source§impl From<Arc<CategoricalArray<u64>>> for Array
Available on crate feature extended_categorical only.
impl From<Arc<CategoricalArray<u64>>> for Array
extended_categorical only.Source§impl From<Arc<IntegerArray<i8>>> for Array
Available on crate feature extended_numeric_types only.
impl From<Arc<IntegerArray<i8>>> for Array
extended_numeric_types only.Source§impl From<Arc<IntegerArray<i16>>> for Array
Available on crate feature extended_numeric_types only.
impl From<Arc<IntegerArray<i16>>> for Array
extended_numeric_types only.Source§impl From<Arc<IntegerArray<u8>>> for Array
Available on crate feature extended_numeric_types only.
impl From<Arc<IntegerArray<u8>>> for Array
extended_numeric_types only.Source§impl From<Arc<IntegerArray<u16>>> for Array
Available on crate feature extended_numeric_types only.
impl From<Arc<IntegerArray<u16>>> for Array
extended_numeric_types only.Source§impl From<Array> for SuperArray
impl From<Array> for SuperArray
Source§impl From<Array> for BooleanArrayV
impl From<Array> for BooleanArrayV
Source§impl From<Array> for NumericArrayV
impl From<Array> for NumericArrayV
Source§impl From<Array> for TemporalArrayV
impl From<Array> for TemporalArrayV
Source§impl From<Array> for TextArrayV
impl From<Array> for TextArrayV
Source§impl From<ArrayV> for Array
ArrayView -> Array
impl From<ArrayV> for Array
ArrayView -> Array
Delegates to to_array, which Arc-bumps the underlying allocation when the
view spans its full backing array (offset = 0, len = array.len()) and only
reallocates via slice_clone for genuinely windowed views.
Source§impl From<BooleanArray<()>> for Array
impl From<BooleanArray<()>> for Array
Source§fn from(a: BooleanArray<()>) -> Self
fn from(a: BooleanArray<()>) -> Self
Source§impl From<CategoricalArray<u8>> for Array
Available on crate feature default_categorical_8 only.
impl From<CategoricalArray<u8>> for Array
default_categorical_8 only.Source§fn from(a: CategoricalArray<u8>) -> Self
fn from(a: CategoricalArray<u8>) -> Self
Source§impl From<CategoricalArray<u16>> for Array
Available on crate feature extended_categorical only.
impl From<CategoricalArray<u16>> for Array
extended_categorical only.Source§fn from(a: CategoricalArray<u16>) -> Self
fn from(a: CategoricalArray<u16>) -> Self
Source§impl From<CategoricalArray<u32>> for Array
Available on crate feature extended_categorical or non-crate feature default_categorical_8 only.
impl From<CategoricalArray<u32>> for Array
extended_categorical or non-crate feature default_categorical_8 only.Source§fn from(a: CategoricalArray<u32>) -> Self
fn from(a: CategoricalArray<u32>) -> Self
Source§impl From<CategoricalArray<u64>> for Array
Available on crate feature extended_categorical only.
impl From<CategoricalArray<u64>> for Array
extended_categorical only.Source§fn from(a: CategoricalArray<u64>) -> Self
fn from(a: CategoricalArray<u64>) -> Self
Source§impl From<DatetimeArray<i32>> for Array
Available on crate feature datetime only.
impl From<DatetimeArray<i32>> for Array
datetime only.Source§fn from(a: DatetimeArray<i32>) -> Self
fn from(a: DatetimeArray<i32>) -> Self
Source§impl From<DatetimeArray<i64>> for Array
Available on crate feature datetime only.
impl From<DatetimeArray<i64>> for Array
datetime only.Source§fn from(a: DatetimeArray<i64>) -> Self
fn from(a: DatetimeArray<i64>) -> Self
Source§impl From<FloatArray<f32>> for Array
impl From<FloatArray<f32>> for Array
Source§fn from(a: FloatArray<f32>) -> Self
fn from(a: FloatArray<f32>) -> Self
Source§impl From<FloatArray<f64>> for Array
impl From<FloatArray<f64>> for Array
Source§fn from(a: FloatArray<f64>) -> Self
fn from(a: FloatArray<f64>) -> Self
Source§impl From<IntegerArray<i8>> for Array
Available on crate feature extended_numeric_types only.
impl From<IntegerArray<i8>> for Array
extended_numeric_types only.Source§fn from(a: IntegerArray<i8>) -> Self
fn from(a: IntegerArray<i8>) -> Self
Source§impl From<IntegerArray<i16>> for Array
Available on crate feature extended_numeric_types only.
impl From<IntegerArray<i16>> for Array
extended_numeric_types only.Source§fn from(a: IntegerArray<i16>) -> Self
fn from(a: IntegerArray<i16>) -> Self
Source§impl From<IntegerArray<i32>> for Array
impl From<IntegerArray<i32>> for Array
Source§fn from(a: IntegerArray<i32>) -> Self
fn from(a: IntegerArray<i32>) -> Self
Source§impl From<IntegerArray<i64>> for Array
impl From<IntegerArray<i64>> for Array
Source§fn from(a: IntegerArray<i64>) -> Self
fn from(a: IntegerArray<i64>) -> Self
Source§impl From<IntegerArray<u8>> for Array
Available on crate feature extended_numeric_types only.
impl From<IntegerArray<u8>> for Array
extended_numeric_types only.Source§fn from(a: IntegerArray<u8>) -> Self
fn from(a: IntegerArray<u8>) -> Self
Source§impl From<IntegerArray<u16>> for Array
Available on crate feature extended_numeric_types only.
impl From<IntegerArray<u16>> for Array
extended_numeric_types only.Source§fn from(a: IntegerArray<u16>) -> Self
fn from(a: IntegerArray<u16>) -> Self
Source§impl From<IntegerArray<u32>> for Array
impl From<IntegerArray<u32>> for Array
Source§fn from(a: IntegerArray<u32>) -> Self
fn from(a: IntegerArray<u32>) -> Self
Source§impl From<IntegerArray<u64>> for Array
impl From<IntegerArray<u64>> for Array
Source§fn from(a: IntegerArray<u64>) -> Self
fn from(a: IntegerArray<u64>) -> Self
Source§impl From<StringArray<u32>> for Array
impl From<StringArray<u32>> for Array
Source§fn from(a: StringArray<u32>) -> Self
fn from(a: StringArray<u32>) -> Self
Source§impl From<StringArray<u64>> for Array
Available on crate feature large_string only.
impl From<StringArray<u64>> for Array
large_string only.Source§fn from(a: StringArray<u64>) -> Self
fn from(a: StringArray<u64>) -> Self
Source§impl FromIterator<Array> for SuperArray
impl FromIterator<Array> for SuperArray
Source§impl RowSelection for Array
Available on crate features select and views only.
impl RowSelection for Array
select and views only.Source§fn r<S: DataSelector>(&self, selection: S) -> ArrayV
fn r<S: DataSelector>(&self, selection: S) -> ArrayV
Select rows by index or range, returning an ArrayV (view)
For contiguous selections (ranges), creates a zero-copy view. For non-contiguous selections (index arrays), gathers into a new array.
Source§fn get_row_count(&self) -> usize
fn get_row_count(&self) -> usize
Source§impl Shape for Array
impl Shape for Array
impl StructuralPartialEq for Array
Source§impl TryFrom<SuperArray> for Array
impl TryFrom<SuperArray> for Array
Source§fn try_from(value: SuperArray) -> Result<Self, Self::Error>
fn try_from(value: SuperArray) -> Result<Self, Self::Error>
Rejoins the chunks into one array.
Source§type Error = MinarrowError
type Error = MinarrowError
Source§impl TryFrom<Table> for Array
impl TryFrom<Table> for Array
Source§fn try_from(value: Table) -> Result<Self, Self::Error>
fn try_from(value: Table) -> Result<Self, Self::Error>
Takes the array of a one-column table.
A single-column table is that column, which is the shape a one-column projection arrives in. A wider table has no single reading, so it reports the column count instead of taking the first.
Source§type Error = MinarrowError
type Error = MinarrowError
Source§impl TryFrom<Vec<Array>> for Array
impl TryFrom<Vec<Array>> for Array
Source§fn try_from(value: Vec<Array>) -> Result<Self, Self::Error>
fn try_from(value: Vec<Array>) -> Result<Self, Self::Error>
Joins a sequence of arrays end to end.
The pieces must share an element type, which the join itself enforces. An empty sequence yields the default array.
Source§type Error = MinarrowError
type Error = MinarrowError
Auto Trait Implementations§
impl !RefUnwindSafe for Array
impl !UnwindSafe for Array
impl Freeze for Array
impl Send for Array
impl Sync for Array
impl Unpin for Array
impl UnsafeUnpin for Array
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> 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,
impl<T, Rhs, Output> NumOps<Rhs, Output> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> 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 more