Trait Array

Source
pub trait Array:
    Send
    + Sync
    + Debug
    + ArrayStatistics
    + ArrayVariants
    + ArrayVisitor {
Show 24 methods // Required methods fn as_any(&self) -> &dyn Any; fn as_any_arc(self: Arc<Self>) -> Arc<dyn Any + Send + Sync>; fn to_array(&self) -> ArrayRef; fn into_array(self) -> ArrayRef where Self: Sized; fn len(&self) -> usize; fn dtype(&self) -> &DType; fn encoding(&self) -> EncodingId; fn vtable(&self) -> VTableRef; 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 base trait for all Vortex arrays.

Users should invoke functions on this trait. Implementations should implement the corresponding function on the _Impl traits, e.g. ArrayValidityImpl. The functions here dispatch to the implementations, while validating pre- and post-conditions.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

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

Source

fn as_any_arc(self: Arc<Self>) -> Arc<dyn Any + Send + Sync>

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

Source

fn to_array(&self) -> ArrayRef

Returns the array as an ArrayRef.

Source

fn into_array(self) -> ArrayRef
where Self: Sized,

Converts the array into 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) -> EncodingId

Returns the encoding of the array.

Source

fn vtable(&self) -> VTableRef

Returns the encoding VTable.

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 serialize( &self, ctx: &ArrayContext, options: &SerializeOptions, ) -> 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 tree_display(&self) -> impl Display

Trait Implementations§

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 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> 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 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<E> LikeFn<&dyn Array> for E
where E: for<'a> LikeFn<&'a E::Array> + Encoding,

Source§

fn like( &self, array: &dyn Array, pattern: &dyn Array, options: LikeOptions, ) -> VortexResult<Option<ArrayRef>>

Source§

impl<E> TakeFromFn<&dyn Array> for E
where E: for<'a> TakeFromFn<&'a E::Array> + Encoding,

Source§

fn take_from( &self, indices: &dyn Array, array: &dyn Array, ) -> VortexResult<Option<ArrayRef>>

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> 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> 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.

Blanket Implementations§

Source§

impl<E> FillNullFn<&dyn Array> for E
where E: Encoding + for<'a> FillNullFn<&'a <E as Encoding>::Array>,

Source§

fn fill_null( &self, array: &dyn Array, fill_value: Scalar, ) -> Result<Arc<dyn Array>, VortexError>

Source§

impl<E> IsConstantFn<&dyn Array> for E
where E: Encoding + for<'a> IsConstantFn<&'a <E as Encoding>::Array>,

Source§

fn is_constant( &self, array: &dyn Array, opts: &IsConstantOpts, ) -> Result<Option<bool>, VortexError>

Preconditions Read more
Source§

impl<E> IsSortedFn<&dyn Array> for E
where E: Encoding + for<'a> IsSortedFn<&'a <E as Encoding>::Array>,

Source§

fn is_sorted(&self, array: &dyn Array) -> Result<bool, VortexError>

Preconditions Read more
Source§

fn is_strict_sorted(&self, array: &dyn Array) -> Result<bool, VortexError>

Source§

impl<E> MinMaxFn<&dyn Array> for E
where E: Encoding + for<'a> MinMaxFn<&'a <E as Encoding>::Array>,

Source§

fn min_max( &self, array: &dyn Array, ) -> Result<Option<MinMaxResult>, VortexError>

Source§

impl<E> OptimizeFn<&dyn Array> for E
where E: Encoding + for<'a> OptimizeFn<&'a <E as Encoding>::Array>,

Source§

fn optimize(&self, array: &dyn Array) -> Result<Arc<dyn Array>, VortexError>

Source§

impl<E> ScalarAtFn<&dyn Array> for E
where E: Encoding + for<'a> ScalarAtFn<&'a <E as Encoding>::Array>,

Source§

fn scalar_at( &self, array: &dyn Array, index: usize, ) -> Result<Scalar, VortexError>

Source§

impl<E> SearchSortedFn<&dyn Array> for E
where E: Encoding + for<'a> SearchSortedFn<&'a <E as Encoding>::Array>,

Source§

fn search_sorted( &self, array: &dyn Array, value: &Scalar, side: SearchSortedSide, ) -> Result<SearchResult, VortexError>

Source§

fn search_sorted_many( &self, array: &dyn Array, values: &[Scalar], side: SearchSortedSide, ) -> Result<Vec<SearchResult>, VortexError>

Bulk search for many values.
Source§

impl<E> SearchSortedUsizeFn<&dyn Array> for E
where E: Encoding + for<'a> SearchSortedUsizeFn<&'a <E as Encoding>::Array>,

Source§

impl<E> SliceFn<&dyn Array> for E
where E: Encoding + for<'a> SliceFn<&'a <E as Encoding>::Array>,

Source§

fn slice( &self, array: &dyn Array, start: usize, stop: usize, ) -> Result<Arc<dyn Array>, VortexError>

Return a zero-copy slice of an array, between start (inclusive) and end (exclusive). If start >= stop, returns an empty array of the same type as self. Assumes that start or stop are out of bounds, may panic otherwise.
Source§

impl<E> TakeFn<&dyn Array> for E
where E: Encoding + for<'a> TakeFn<&'a <E as Encoding>::Array>,

Source§

fn take( &self, array: &dyn Array, indices: &dyn Array, ) -> Result<Arc<dyn Array>, VortexError>

Create a new array by taking the values from the array at the given indices. Read more
Source§

fn take_into( &self, array: &dyn Array, indices: &dyn Array, builder: &mut dyn ArrayBuilder, ) -> Result<(), VortexError>

Has the same semantics as Self::take but materializes the result into the provided builder.
Source§

impl<E> ToArrowFn<&dyn Array> for E
where E: Encoding + for<'a> ToArrowFn<&'a <E as Encoding>::Array>,

Source§

fn preferred_arrow_data_type( &self, array: &dyn Array, ) -> Result<Option<DataType>, VortexError>

Return the preferred Arrow DataType of the encoding, or None of the canonical DataType for the array’s Vortex vortex_dtype::DType should be used.
Source§

fn to_arrow( &self, array: &dyn Array, data_type: &DataType, ) -> Result<Option<Arc<dyn Array>>, VortexError>

Convert the array to an Arrow array of the given type. Read more
Source§

impl<E> UncompressedSizeFn<&dyn Array> for E
where E: Encoding + for<'a> UncompressedSizeFn<&'a <E as Encoding>::Array>,

Source§

fn uncompressed_size(&self, array: &dyn Array) -> Result<usize, VortexError>

Compute the approximated uncompressed size of the array, in bytes.

Implementations on Foreign Types§

Source§

impl Array for Arc<dyn Array>

Implementors§

Source§

impl<A: ArrayImpl + 'static> Array for A