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§
Sourcefn into_array(self) -> ArrayRefwhere
Self: Sized,
fn into_array(self) -> ArrayRefwhere
Self: Sized,
Converts the array into an ArrayRef
.
Sourcefn encoding(&self) -> EncodingId
fn encoding(&self) -> EncodingId
Returns the encoding of the array.
Sourcefn is_valid(&self, index: usize) -> VortexResult<bool>
fn is_valid(&self, index: usize) -> VortexResult<bool>
Returns whether the item at index
is valid.
Sourcefn is_invalid(&self, index: usize) -> VortexResult<bool>
fn is_invalid(&self, index: usize) -> VortexResult<bool>
Returns whether the item at index
is invalid.
Sourcefn all_valid(&self) -> VortexResult<bool>
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
.
Sourcefn all_invalid(&self) -> VortexResult<bool>
fn all_invalid(&self) -> VortexResult<bool>
Returns whether the array is all invalid.
This is usually cheaper than computing a precise invalid_count
.
Sourcefn valid_count(&self) -> VortexResult<usize>
fn valid_count(&self) -> VortexResult<usize>
Returns the number of valid elements in the array.
Sourcefn invalid_count(&self) -> VortexResult<usize>
fn invalid_count(&self) -> VortexResult<usize>
Returns the number of invalid elements in the array.
Sourcefn validity_mask(&self) -> VortexResult<Mask>
fn validity_mask(&self) -> VortexResult<Mask>
Returns the canonical validity mask for the array.
Sourcefn to_canonical(&self) -> VortexResult<Canonical>
fn to_canonical(&self) -> VortexResult<Canonical>
Returns the canonical representation of the array.
Sourcefn append_to_builder(&self, builder: &mut dyn ArrayBuilder) -> VortexResult<()>
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.
Sourcefn statistics(&self) -> StatsSetRef<'_>
fn statistics(&self) -> StatsSetRef<'_>
Returns the statistics of the array.
Provided Methods§
Sourcefn is_encoding(&self, encoding: EncodingId) -> bool
fn is_encoding(&self, encoding: EncodingId) -> bool
Returns whether the array is of the given encoding.
Sourcefn is_canonical(&self) -> bool
fn is_canonical(&self) -> bool
Whether the array is of a canonical encoding.
Implementations§
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn serialize(
&self,
ctx: &ArrayContext,
options: &SerializeOptions,
) -> Vec<ByteBuffer>
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.
Trait Implementations§
Source§impl IndexOrd<Scalar> for dyn Array + '_
impl IndexOrd<Scalar> for dyn Array + '_
Source§fn index_cmp(&self, idx: usize, elem: &Scalar) -> Option<Ordering>
fn index_cmp(&self, idx: usize, elem: &Scalar) -> Option<Ordering>
idx
with elem
.
For example, if self[idx] > elem, return Some(Greater).fn index_lt(&self, idx: usize, elem: &V) -> bool
fn index_le(&self, idx: usize, elem: &V) -> bool
fn index_gt(&self, idx: usize, elem: &V) -> bool
fn index_ge(&self, idx: usize, elem: &V) -> bool
Source§impl<E> LikeFn<&dyn Array> for E
impl<E> LikeFn<&dyn Array> for E
fn like( &self, array: &dyn Array, pattern: &dyn Array, options: LikeOptions, ) -> VortexResult<Option<ArrayRef>>
Source§impl<'a, E> SerdeVTable<&'a dyn Array> for E
impl<'a, E> SerdeVTable<&'a dyn Array> for E
Source§fn decode(
&self,
parts: &ArrayParts,
ctx: &ArrayContext,
dtype: DType,
len: usize,
) -> VortexResult<ArrayRef>
fn decode( &self, parts: &ArrayParts, ctx: &ArrayContext, dtype: DType, len: usize, ) -> VortexResult<ArrayRef>
ArrayParts
into an ArrayRef
of this encoding.Source§impl<'a, E> StatisticsVTable<&'a dyn Array> for E
impl<'a, E> StatisticsVTable<&'a dyn Array> for E
Source§fn compute_statistics(
&self,
array: &'a dyn Array,
stat: Stat,
) -> VortexResult<StatsSet>
fn compute_statistics( &self, array: &'a dyn Array, stat: Stat, ) -> VortexResult<StatsSet>
Source§impl<E> TakeFromFn<&dyn Array> for E
impl<E> TakeFromFn<&dyn Array> for E
Source§impl ToOwned for dyn Array
impl ToOwned for dyn Array
Source§impl TryFrom<&dyn Array> for RecordBatch
impl TryFrom<&dyn Array> for RecordBatch
Source§type Error = VortexError
type Error = VortexError
Source§fn try_from(value: &dyn Array) -> VortexResult<Self>
fn try_from(value: &dyn Array) -> VortexResult<Self>
Blanket Implementations§
Source§impl<E> BinaryBooleanFn<&dyn Array> for E
impl<E> BinaryBooleanFn<&dyn Array> for E
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
impl<E> BinaryNumericFn<&dyn Array> for E
fn binary_numeric( &self, lhs: &dyn Array, rhs: &dyn Array, op: BinaryNumericOperator, ) -> Result<Option<Arc<dyn Array>>, VortexError>
Source§impl<E> FillForwardFn<&dyn Array> for E
impl<E> FillForwardFn<&dyn Array> for E
fn fill_forward(&self, array: &dyn Array) -> Result<Arc<dyn Array>, VortexError>
Source§impl<E> FillNullFn<&dyn Array> for E
impl<E> FillNullFn<&dyn Array> for E
Source§impl<E> IsConstantFn<&dyn Array> for E
impl<E> IsConstantFn<&dyn Array> for E
Source§fn is_constant(
&self,
array: &dyn Array,
opts: &IsConstantOpts,
) -> Result<Option<bool>, VortexError>
fn is_constant( &self, array: &dyn Array, opts: &IsConstantOpts, ) -> Result<Option<bool>, VortexError>
Source§impl<E> MinMaxFn<&dyn Array> for E
impl<E> MinMaxFn<&dyn Array> for E
fn min_max( &self, array: &dyn Array, ) -> Result<Option<MinMaxResult>, VortexError>
Source§impl<E> ScalarAtFn<&dyn Array> for E
impl<E> ScalarAtFn<&dyn Array> for E
Source§impl<E> SearchSortedFn<&dyn Array> for E
impl<E> SearchSortedFn<&dyn Array> for E
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>
fn search_sorted_many( &self, array: &dyn Array, values: &[Scalar], side: SearchSortedSide, ) -> Result<Vec<SearchResult>, VortexError>
Source§impl<E> SearchSortedUsizeFn<&dyn Array> for E
impl<E> SearchSortedUsizeFn<&dyn Array> for E
fn search_sorted_usize( &self, array: &dyn Array, value: usize, side: SearchSortedSide, ) -> Result<SearchResult, VortexError>
fn search_sorted_usize_many( &self, array: &dyn Array, values: &[usize], side: SearchSortedSide, ) -> Result<Vec<SearchResult>, VortexError>
Source§impl<E> SliceFn<&dyn Array> for E
impl<E> SliceFn<&dyn Array> for E
Source§fn slice(
&self,
array: &dyn Array,
start: usize,
stop: usize,
) -> Result<Arc<dyn Array>, VortexError>
fn slice( &self, array: &dyn Array, start: usize, stop: usize, ) -> Result<Arc<dyn Array>, VortexError>
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
impl<E> TakeFn<&dyn Array> for E
Source§fn take(
&self,
array: &dyn Array,
indices: &dyn Array,
) -> Result<Arc<dyn Array>, VortexError>
fn take( &self, array: &dyn Array, indices: &dyn Array, ) -> Result<Arc<dyn Array>, VortexError>
Source§fn take_into(
&self,
array: &dyn Array,
indices: &dyn Array,
builder: &mut dyn ArrayBuilder,
) -> Result<(), VortexError>
fn take_into( &self, array: &dyn Array, indices: &dyn Array, builder: &mut dyn ArrayBuilder, ) -> Result<(), VortexError>
Self::take
but materializes the result into the provided
builder.Source§impl<E> ToArrowFn<&dyn Array> for E
impl<E> ToArrowFn<&dyn Array> for E
Source§fn preferred_arrow_data_type(
&self,
array: &dyn Array,
) -> Result<Option<DataType>, VortexError>
fn preferred_arrow_data_type( &self, array: &dyn Array, ) -> Result<Option<DataType>, VortexError>
DataType
of the encoding, or None of the canonical
DataType
for the array’s Vortex vortex_dtype::DType
should be used.