Struct arrow2::array::PrimitiveArray [−][src]
pub struct PrimitiveArray<T: NativeType> { /* fields omitted */ }
Expand description
A PrimitiveArray
is arrow’s equivalent to Vec<Option<T: NativeType>>
, i.e.
an array designed for highly performant operations on optionally nullable slots,
backed by a physical type of a physical byte-width, such as i32
or f64
.
The size of this struct is O(1)
as all data is stored behind an std::sync::Arc
.
Example
use arrow2::array::PrimitiveArray;
let array = PrimitiveArray::<i32>::from([Some(1), None, Some(2)]);
assert_eq!(array.value(0), 1);
assert_eq!(array.values().as_slice(), &[1, 0, 2]);
Implementations
Creates a new array out an iterator over values
Creates a new array out an iterator over values
Creates a new array out an iterator over values
Creates a new PrimitiveArray
from an iterator over values
Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
Creates a new PrimitiveArray
from an iterator over optional values
Creates a new PrimitiveArray
from an iterator over optional values
Safety
The iterator must be TrustedLen
.
I.e. that size_hint().1
correctly reports its length.
pub fn iter(&'a self) -> ZipValidity<'a, &'a T, Iter<'a, T>>ⓘNotable traits for ZipValidity<'a, T, I>impl<'a, T, I: Iterator<Item = T>> Iterator for ZipValidity<'a, T, I> type Item = Option<T>;
pub fn iter(&'a self) -> ZipValidity<'a, &'a T, Iter<'a, T>>ⓘNotable traits for ZipValidity<'a, T, I>impl<'a, T, I: Iterator<Item = T>> Iterator for ZipValidity<'a, T, I> type Item = Option<T>;
impl<'a, T, I: Iterator<Item = T>> Iterator for ZipValidity<'a, T, I> type Item = Option<T>;
constructs a new iterator
Returns a new empty PrimitiveArray
.
Returns a new PrimitiveArray
whose all slots are null / None
.
The canonical method to create a PrimitiveArray
out of low-end APIs.
Panics
This function panics iff:
data_type
is not supported by the physical type- The validity is not
None
and its length is different from thevalues
’s length
Returns a slice of this PrimitiveArray
.
Implementation
This operation is O(1)
as it amounts to increase two ref counts.
Panic
This function panics iff offset + length >= self.len()
.
Safe method to retrieve the value at slot i
.
Equivalent to self.values()[i]
.
Returns a new PrimitiveArray
with a different logical type.
This is O(1)
.
Panics
Panics iff the data_type is not supported for the physical type.
Trait Implementations
The DataType
of the Array
. In combination with Array::as_any
, this can be
used to downcast trait objects (dyn Array
) to concrete arrays. Read more
Performs the conversion.
Performs the conversion.
Convert itself from FFI.
impl<T: NativeType + NaturalDataType, Ptr: Borrow<Option<T>>> FromIterator<Ptr> for PrimitiveArray<T>
impl<T: NativeType + NaturalDataType, Ptr: Borrow<Option<T>>> FromIterator<Ptr> for PrimitiveArray<T>
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for PrimitiveArray<T> where
T: RefUnwindSafe,
impl<T> Send for PrimitiveArray<T>
impl<T> Sync for PrimitiveArray<T>
impl<T> Unpin for PrimitiveArray<T>
impl<T> UnwindSafe for PrimitiveArray<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more