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 fixed 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, Array};
use arrow2::bitmap::Bitmap;
let array = PrimitiveArray::from([Some(1), None, Some(10)]);
assert_eq!(array.values().as_slice(), &[1, 0, 10]);
assert_eq!(array.validity(), Some(&Bitmap::from([true, false, true])));

Implementations

Creates a (non-null) PrimitiveArray from an iterator of values.

Implementation

This does not assume that the iterator has a known length.

Creates a (non-null) PrimitiveArray from a slice of values.

Implementation

This is essentially a memcopy and is the fastest way to create a PrimitiveArray.

Creates a (non-null) PrimitiveArray from a TrustedLen of values.

Implementation

This does not assume that the iterator has a known length.

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 PrimitiveArray from a TrustedLen of optional values.

Creates a PrimitiveArray from an iterator of optional values.

Safety

The iterator must be TrustedLen. I.e. that size_hint().1 correctly reports its length.

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 the values’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().

Returns a slice of this PrimitiveArray.

Implementation

This operation is O(1) as it amounts to increase two ref counts.

Safety

The caller must ensure that offset + length <= self.len().

Sets the validity bitmap on this PrimitiveArray.

Panics

This function panics iff validity.len() != self.len().

The optional validity.

The values Buffer. Values on null slots are undetermined (they can be anything).

Returns the value at slot i. Equivalent to self.values()[i]. The value on null slots is undetermined (it can be anything).

Returns the element at index i as T. The value on null slots is undetermined (it can be anything).

Safety

Caller must be sure that i < self.len()

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

Convert to trait object.

The length of the Array. Every array has a length corresponding to the number of elements (slots). Read more

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

The validity of the Array: every array has an optional Bitmap that, when available specifies whether the array slot is valid or not (null). When the validity is None, all slots are valid. Read more

Slices the Array, returning a new Box<dyn Array>. Read more

Slices the Array, returning a new Box<dyn Array>. Read more

Sets the validity bitmap on this Array. Read more

whether the array is empty

The number of null slots on this Array. Read more

Returns whether slot i is null. Read more

Returns whether slot i is valid. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Convert itself from FFI. Read more

Creates a value from an iterator. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The pointers to the buffers.

The offset

The children

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.