Trait Array

Source
pub trait Array:
    Send
    + Sync
    + Debug
    + ArrayStatistics
    + ArrayVariants
    + ArrayVisitor {
Show 22 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<'_>; // 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.

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 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_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 Len for dyn Array + '_

Source§

fn len(&self) -> usize

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

Source§

fn decode( &self, parts: &ArrayParts, ctx: &ArrayContext, dtype: DType, len: usize, ) -> VortexResult<ArrayRef>

Decode an ArrayParts into an ArrayRef of this encoding.
Source§

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

Source§

fn compute_statistics( &self, array: &'a dyn Array, stat: Stat, ) -> VortexResult<StatsSet>

Compute the requested statistic. Can return additional stats.
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> BetweenFn<&dyn Array> for E
where E: Encoding + for<'a> BetweenFn<&'a <E as Encoding>::Array>,

Source§

fn between( &self, arr: &dyn Array, lower: &dyn Array, upper: &dyn Array, options: &BetweenOptions, ) -> Result<Option<Arc<dyn Array>>, VortexError>

Source§

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

Source§

fn binary_boolean( &self, lhs: &dyn Array, rhs: &dyn Array, op: BinaryOperator, ) -> Result<Option<Arc<dyn Array>>, VortexError>

Source§

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

Source§

fn binary_numeric( &self, lhs: &dyn Array, rhs: &dyn Array, op: BinaryNumericOperator, ) -> Result<Option<Arc<dyn Array>>, VortexError>

Source§

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

Source§

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

Source§

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

Source§

fn compare( &self, lhs: &dyn Array, rhs: &dyn Array, operator: Operator, ) -> Result<Option<Arc<dyn Array>>, VortexError>

Compares two arrays and returns a new boolean array with the result of the comparison. Or, returns None if comparison is not supported for these arrays.
Source§

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

Source§

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

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

Source§

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

Filter an array by the provided predicate. Read more
Source§

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

Source§

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

Logically invert a boolean array. Converts true -> false, false -> true, null -> null.
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> MaskFn<&dyn Array> for E
where E: Encoding + for<'a> MaskFn<&'a <E as Encoding>::Array>,

Source§

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

Replace masked values with null in array.
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> 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> SumFn<&dyn Array> for E
where E: Encoding + for<'a> SumFn<&'a <E as Encoding>::Array>,

Source§

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

Preconditions Read more
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