Trait Array

Source
pub trait Array:
    'static
    + Sealed
    + Send
    + Sync
    + Debug
    + ArrayVisitor {
Show 24 methods // Required methods fn as_any(&self) -> &dyn Any; fn to_array(&self) -> ArrayRef; fn len(&self) -> usize; fn dtype(&self) -> &DType; fn encoding(&self) -> EncodingRef; fn encoding_id(&self) -> EncodingId; fn slice(&self, start: usize, end: usize) -> VortexResult<ArrayRef>; fn scalar_at(&self, index: usize) -> VortexResult<Scalar>; fn is_valid(&self, index: usize) -> VortexResult<bool>; fn is_invalid(&self, index: usize) -> VortexResult<bool>; fn all_valid(&self) -> VortexResult<bool>; fn all_invalid(&self) -> VortexResult<bool>; fn valid_count(&self) -> VortexResult<usize>; fn invalid_count(&self) -> VortexResult<usize>; fn validity_mask(&self) -> VortexResult<Mask>; fn to_canonical(&self) -> VortexResult<Canonical>; fn append_to_builder( &self, builder: &mut dyn ArrayBuilder, ) -> VortexResult<()>; fn statistics(&self) -> StatsSetRef<'_>; fn with_children(&self, children: &[ArrayRef]) -> VortexResult<ArrayRef>; fn invoke( &self, compute_fn: &ComputeFn, args: &InvocationArgs<'_>, ) -> VortexResult<Option<Output>>; // Provided methods fn is_empty(&self) -> bool { ... } fn is_encoding(&self, encoding: EncodingId) -> bool { ... } fn is_arrow(&self) -> bool { ... } fn is_canonical(&self) -> bool { ... }
}
Expand description

The public API trait for all Vortex arrays.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns the array as a reference to a generic Any trait object.

Source

fn to_array(&self) -> ArrayRef

Returns the array as an ArrayRef.

Source

fn len(&self) -> usize

Returns the length of the array.

Source

fn dtype(&self) -> &DType

Returns the logical Vortex DType of the array.

Source

fn encoding(&self) -> EncodingRef

Returns the encoding of the array.

Source

fn encoding_id(&self) -> EncodingId

Returns the encoding ID of the array.

Source

fn slice(&self, start: usize, end: usize) -> VortexResult<ArrayRef>

Performs a constant-time slice of the array.

Source

fn scalar_at(&self, index: usize) -> VortexResult<Scalar>

Fetch the scalar at the given index.

Source

fn is_valid(&self, index: usize) -> VortexResult<bool>

Returns whether the item at index is valid.

Source

fn is_invalid(&self, index: usize) -> VortexResult<bool>

Returns whether the item at index is invalid.

Source

fn all_valid(&self) -> VortexResult<bool>

Returns whether all items in the array are valid.

This is usually cheaper than computing a precise valid_count.

Source

fn all_invalid(&self) -> VortexResult<bool>

Returns whether the array is all invalid.

This is usually cheaper than computing a precise invalid_count.

Source

fn valid_count(&self) -> VortexResult<usize>

Returns the number of valid elements in the array.

Source

fn invalid_count(&self) -> VortexResult<usize>

Returns the number of invalid elements in the array.

Source

fn validity_mask(&self) -> VortexResult<Mask>

Returns the canonical validity mask for the array.

Source

fn to_canonical(&self) -> VortexResult<Canonical>

Returns the canonical representation of the array.

Source

fn append_to_builder(&self, builder: &mut dyn ArrayBuilder) -> VortexResult<()>

Writes the array into the canonical builder.

The DType of the builder must match that of the array.

Source

fn statistics(&self) -> StatsSetRef<'_>

Returns the statistics of the array.

Source

fn with_children(&self, children: &[ArrayRef]) -> VortexResult<ArrayRef>

Replaces the children of the array with the given array references.

Source

fn invoke( &self, compute_fn: &ComputeFn, args: &InvocationArgs<'_>, ) -> VortexResult<Option<Output>>

Optionally invoke a kernel for the given compute function.

These encoding-specific kernels are independent of kernels registered directly with compute functions using ComputeFn::register_kernel, and are attempted only if none of the function-specific kernels returns a result.

This allows encodings the opportunity to generically implement many compute functions that share some property, for example ComputeFn::is_elementwise, without prior knowledge of the function itself, while still allowing users to override the implementation of compute functions for built-in encodings. For an example, see the implementation for chunked arrays.

The first input in the InvocationArgs is always the array itself.

Warning: do not call compute_fn.invoke(args) directly, as this will result in a recursive call.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns whether the array is empty (has zero rows).

Source

fn is_encoding(&self, encoding: EncodingId) -> bool

Returns whether the array is of the given encoding.

Source

fn is_arrow(&self) -> bool

Returns whether this array is an arrow encoding.

Source

fn is_canonical(&self) -> bool

Whether the array is of a canonical encoding.

Implementations§

Source§

impl dyn Array

Source

pub fn is_constant(&self) -> bool

Source

pub fn is_constant_opts(&self, cost: Cost) -> bool

Source

pub fn as_constant(&self) -> Option<Scalar>

Source§

impl dyn Array + '_

Source

pub fn as_<V: VTable>(&self) -> &V::Array

Returns the array downcast to the given A.

Source

pub fn as_opt<V: VTable>(&self) -> Option<&V::Array>

Returns the array downcast to the given A.

Source

pub fn is<V: VTable>(&self) -> bool

Is self an array with encoding from vtable V.

Source§

impl dyn Array + '_

Source

pub fn nbytes(&self) -> usize

Total size of the array in bytes, including all children and buffers.

Source§

impl dyn Array + '_

Source

pub fn to_array_iterator(&self) -> impl ArrayIterator + 'static

Create an ArrayIterator over the array.

Source§

impl dyn Array + '_

Source

pub fn serialize( &self, ctx: &ArrayContext, options: &SerializeOptions, ) -> VortexResult<Vec<ByteBuffer>>

Serialize the array into a sequence of byte buffers that should be written contiguously. This function returns a vec to avoid copying data buffers.

Optionally, padding can be included to guarantee buffer alignment and ensure zero-copy reads within the context of an external file or stream. In this case, the alignment of the first byte buffer should be respected when writing the buffers to the stream or file.

The format of this blob is a sequence of data buffers, possible with prefixed padding, followed by a flatbuffer containing an fba::Array message, and ending with a little-endian u32 describing the length of the flatbuffer message.

Source§

impl dyn Array + '_

Source

pub fn to_array_stream(&self) -> impl ArrayStream + 'static

Create an ArrayStream over the array.

Source§

impl dyn Array + '_

Source

pub fn tree_display(&self) -> impl Display

Source§

impl dyn Array + '_

Source

pub fn as_null_typed(&self) -> NullTyped<'_>

Downcasts the array for null-specific behavior.

Source

pub fn as_bool_typed(&self) -> BoolTyped<'_>

Downcasts the array for bool-specific behavior.

Source

pub fn as_primitive_typed(&self) -> PrimitiveTyped<'_>

Downcasts the array for primitive-specific behavior.

Source

pub fn as_decimal_typed(&self) -> DecimalTyped<'_>

Downcasts the array for decimal-specific behavior.

Source

pub fn as_utf8_typed(&self) -> Utf8Typed<'_>

Downcasts the array for utf8-specific behavior.

Source

pub fn as_binary_typed(&self) -> BinaryTyped<'_>

Downcasts the array for binary-specific behavior.

Source

pub fn as_struct_typed(&self) -> StructTyped<'_>

Downcasts the array for struct-specific behavior.

Source

pub fn as_list_typed(&self) -> ListTyped<'_>

Downcasts the array for list-specific behavior.

Source

pub fn as_extension_typed(&self) -> ExtensionTyped<'_>

Downcasts the array for extension-specific behavior.

Trait Implementations§

Source§

impl AsRef<dyn Array> for BoolArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for Canonical

Source§

fn as_ref(&self) -> &(dyn Array + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for ChunkedArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for ConstantArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for DecimalArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for ExtensionArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for ListArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for NullArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for PrimitiveArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for StructArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for VarBinArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<dyn Array> for VarBinViewArray

Source§

fn as_ref(&self) -> &dyn Array

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Display for dyn Array

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a (dyn Array + 'static)> for Input<'a>

Source§

fn from(value: &'a dyn Array) -> Self

Converts to this type from the input type.
Source§

impl IndexOrd<Scalar> for dyn Array + '_

Source§

fn index_cmp(&self, idx: usize, elem: &Scalar) -> Option<Ordering>

PartialOrd of the value at index idx with elem. For example, if self[idx] > elem, return Some(Greater).
Source§

fn index_len(&self) -> usize

Get the length of the underlying ordered collection
Source§

fn index_lt(&self, idx: usize, elem: &V) -> bool

Source§

fn index_le(&self, idx: usize, elem: &V) -> bool

Source§

fn index_gt(&self, idx: usize, elem: &V) -> bool

Source§

fn index_ge(&self, idx: usize, elem: &V) -> bool

Source§

impl ToOwned for dyn Array

Source§

type Owned = Arc<dyn Array>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

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

impl TryFrom<&(dyn Array + 'static)> for ArrayData

Source§

type Error = VortexError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &dyn Array) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&(dyn Array + 'static)> for Mask

Source§

fn try_from(array: &dyn Array) -> Result<Self, Self::Error>

Converts from a possible nullable boolean array. Null values are treated as false.

Source§

type Error = VortexError

The type returned in the event of a conversion error.
Source§

impl TryFrom<&(dyn Array + 'static)> for RecordBatch

Source§

type Error = VortexError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &dyn Array) -> VortexResult<Self>

Performs the conversion.

Implementations on Foreign Types§

Source§

impl Array for Arc<dyn Array>

Implementors§