pub struct PrimitiveArray<T: ArrowNativeType> { /* private fields */ }Expand description
A column of fixed-width scalars with an optional validity bitmap.
See the module documentation for the layout.
Implementations§
Source§impl<T: ArrowNativeType> PrimitiveArray<T>
impl<T: ArrowNativeType> PrimitiveArray<T>
Sourcepub fn try_new(
values: ScalarBuffer<T>,
validity: Option<Bitmap>,
) -> Result<Self>
pub fn try_new( values: ScalarBuffer<T>, validity: Option<Bitmap>, ) -> Result<Self>
Builds an array from a values buffer and an optional validity bitmap.
§Errors
DataError::ValidityLengthMismatch when the bitmap does not cover
exactly one bit per value.
use astrs_data::array::{Array, Int32Array};
use astrs_data::{Bitmap, ScalarBuffer};
let values = ScalarBuffer::from_slice(&[1, 2, 3]);
let validity: Bitmap = [true, false, true].into_iter().collect();
let array = Int32Array::try_new(values, Some(validity))?;
assert_eq!(array.null_count(), 1);Sourcepub fn try_new_with_type(
data_type: DataType,
values: ScalarBuffer<T>,
validity: Option<Bitmap>,
) -> Result<Self>
pub fn try_new_with_type( data_type: DataType, values: ScalarBuffer<T>, validity: Option<Bitmap>, ) -> Result<Self>
Builds an array that reports a data type other than T::DATA_TYPE.
Only the types whose value width matches T are accepted, which is how
crate::array::TimestampArray and crate::array::DurationArray
reuse the i64 layout.
§Errors
DataError::TypeMismatchwhendata_type’s value width differs fromT’s.DataError::ValidityLengthMismatchwhen the bitmap length is wrong.
Sourcepub fn from_values(values: impl IntoIterator<Item = T>) -> Self
pub fn from_values(values: impl IntoIterator<Item = T>) -> Self
Builds an array with no nulls.
use astrs_data::array::{Array, Float64Array};
let array = Float64Array::from_values([1.0, 2.5]);
assert_eq!(array.null_count(), 0);
assert!(array.validity().is_none());Sourcepub fn from_opt_iter(values: impl IntoIterator<Item = Option<T>>) -> Self
pub fn from_opt_iter(values: impl IntoIterator<Item = Option<T>>) -> Self
Builds an array from optional values, null slots holding T::default().
Sourcepub fn values(&self) -> &[T]
pub fn values(&self) -> &[T]
The raw values, including the placeholder in every null slot.
This is the SIMD-ready view the blueprint’s zero-copy path exists for: the slice starts at the array’s window and is 64-byte aligned whenever the window starts on an alignment boundary.
Sourcepub const fn values_buffer(&self) -> &ScalarBuffer<T>
pub const fn values_buffer(&self) -> &ScalarBuffer<T>
The values buffer.
Sourcepub fn value(&self, index: usize) -> Option<T>
pub fn value(&self, index: usize) -> Option<T>
The raw slot value at index, ignoring validity.
Returns None only when index is out of range.
Sourcepub fn get(&self, index: usize) -> Option<T>
pub fn get(&self, index: usize) -> Option<T>
The logical value at index: None when the slot is null or out of
range.
Sourcepub fn values_iter(&self) -> impl Iterator<Item = T> + '_
pub fn values_iter(&self) -> impl Iterator<Item = T> + '_
Iterates over the non-null values, skipping nulls entirely.
Sourcepub fn slice(&self, offset: usize, len: usize) -> Self
pub fn slice(&self, offset: usize, len: usize) -> Self
A zero-copy sub-range, clamped to the array (the crate-wide slicing convention).
Sourcepub fn try_slice(&self, offset: usize, len: usize) -> Result<Self>
pub fn try_slice(&self, offset: usize, len: usize) -> Result<Self>
Checked PrimitiveArray::slice.
§Errors
DataError::SliceOutOfBounds when the window leaves the array.
Sourcepub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
pub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
Returns a copy with a different validity bitmap.
§Errors
DataError::ValidityLengthMismatch when the bitmap length is wrong.
Trait Implementations§
Source§impl<T: ArrowNativeType> Array for PrimitiveArray<T>
impl<T: ArrowNativeType> Array for PrimitiveArray<T>
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
ArrayExt::downcast.Source§fn validity(&self) -> Option<&Bitmap>
fn validity(&self) -> Option<&Bitmap>
None when every slot is valid. Read moreSource§fn buffer_memory_size(&self) -> usize
fn buffer_memory_size(&self) -> usize
Source§fn null_count(&self) -> usize
fn null_count(&self) -> usize
Source§impl<T: ArrowNativeType> ArrayAccessor for &PrimitiveArray<T>
impl<T: ArrowNativeType> ArrayAccessor for &PrimitiveArray<T>
Source§impl<T: Clone + ArrowNativeType> Clone for PrimitiveArray<T>
impl<T: Clone + ArrowNativeType> Clone for PrimitiveArray<T>
Source§impl<T: ArrowNativeType> Debug for PrimitiveArray<T>
impl<T: ArrowNativeType> Debug for PrimitiveArray<T>
Source§impl<T: ArrowNativeType> From<Vec<T>> for PrimitiveArray<T>
impl<T: ArrowNativeType> From<Vec<T>> for PrimitiveArray<T>
Source§impl<T: ArrowNativeType, const N: usize> From<[T; N]> for PrimitiveArray<T>
impl<T: ArrowNativeType, const N: usize> From<[T; N]> for PrimitiveArray<T>
Source§impl<T: ArrowNativeType> FromIterator<Option<T>> for PrimitiveArray<T>
impl<T: ArrowNativeType> FromIterator<Option<T>> for PrimitiveArray<T>
Source§impl<T: ArrowNativeType> FromIterator<T> for PrimitiveArray<T>
impl<T: ArrowNativeType> FromIterator<T> for PrimitiveArray<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<'a, T: ArrowNativeType> IntoIterator for &'a PrimitiveArray<T>
impl<'a, T: ArrowNativeType> IntoIterator for &'a PrimitiveArray<T>
Auto Trait Implementations§
impl<T> !Freeze for PrimitiveArray<T>
impl<T> RefUnwindSafe for PrimitiveArray<T>where
ScalarBuffer<T>: RefUnwindSafe,
impl<T> Send for PrimitiveArray<T>where
ScalarBuffer<T>: Send,
impl<T> Sync for PrimitiveArray<T>where
ScalarBuffer<T>: Sync,
impl<T> Unpin for PrimitiveArray<T>where
ScalarBuffer<T>: Unpin,
impl<T> UnsafeUnpin for PrimitiveArray<T>where
ScalarBuffer<T>: UnsafeUnpin,
impl<T> UnwindSafe for PrimitiveArray<T>where
ScalarBuffer<T>: UnwindSafe,
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<A> IntoArrayRef for Awhere
A: Array,
impl<A> IntoArrayRef for Awhere
A: Array,
Source§fn into_array_ref(self) -> ArrayRef
fn into_array_ref(self) -> ArrayRef
self into a shared, dynamically typed column.