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§
Sourcefn encoding(&self) -> EncodingRef
fn encoding(&self) -> EncodingRef
Returns the encoding of the array.
Sourcefn encoding_id(&self) -> EncodingId
fn encoding_id(&self) -> EncodingId
Returns the encoding ID of the array.
Sourcefn slice(&self, start: usize, end: usize) -> VortexResult<ArrayRef>
fn slice(&self, start: usize, end: usize) -> VortexResult<ArrayRef>
Performs a constant-time slice of the array.
Sourcefn scalar_at(&self, index: usize) -> VortexResult<Scalar>
fn scalar_at(&self, index: usize) -> VortexResult<Scalar>
Fetch the scalar at the given index.
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.
Sourcefn with_children(&self, children: &[ArrayRef]) -> VortexResult<ArrayRef>
fn with_children(&self, children: &[ArrayRef]) -> VortexResult<ArrayRef>
Replaces the children of the array with the given array references.
Sourcefn invoke(
&self,
compute_fn: &ComputeFn,
args: &InvocationArgs<'_>,
) -> VortexResult<Option<Output>>
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§
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
pub fn is_constant(&self) -> bool
pub fn is_constant_opts(&self, cost: Cost) -> bool
pub fn as_constant(&self) -> Option<Scalar>
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn to_array_iterator(&self) -> impl ArrayIterator + 'static
pub fn to_array_iterator(&self) -> impl ArrayIterator + 'static
Create an ArrayIterator
over the array.
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn serialize(
&self,
ctx: &ArrayContext,
options: &SerializeOptions,
) -> VortexResult<Vec<ByteBuffer>>
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 + '_
impl dyn Array + '_
Sourcepub fn to_array_stream(&self) -> impl ArrayStream + 'static
pub fn to_array_stream(&self) -> impl ArrayStream + 'static
Create an ArrayStream
over the array.
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn as_null_typed(&self) -> NullTyped<'_>
pub fn as_null_typed(&self) -> NullTyped<'_>
Downcasts the array for null-specific behavior.
Sourcepub fn as_bool_typed(&self) -> BoolTyped<'_>
pub fn as_bool_typed(&self) -> BoolTyped<'_>
Downcasts the array for bool-specific behavior.
Sourcepub fn as_primitive_typed(&self) -> PrimitiveTyped<'_>
pub fn as_primitive_typed(&self) -> PrimitiveTyped<'_>
Downcasts the array for primitive-specific behavior.
Sourcepub fn as_decimal_typed(&self) -> DecimalTyped<'_>
pub fn as_decimal_typed(&self) -> DecimalTyped<'_>
Downcasts the array for decimal-specific behavior.
Sourcepub fn as_utf8_typed(&self) -> Utf8Typed<'_>
pub fn as_utf8_typed(&self) -> Utf8Typed<'_>
Downcasts the array for utf8-specific behavior.
Sourcepub fn as_binary_typed(&self) -> BinaryTyped<'_>
pub fn as_binary_typed(&self) -> BinaryTyped<'_>
Downcasts the array for binary-specific behavior.
Sourcepub fn as_struct_typed(&self) -> StructTyped<'_>
pub fn as_struct_typed(&self) -> StructTyped<'_>
Downcasts the array for struct-specific behavior.
Sourcepub fn as_list_typed(&self) -> ListTyped<'_>
pub fn as_list_typed(&self) -> ListTyped<'_>
Downcasts the array for list-specific behavior.
Sourcepub fn as_extension_typed(&self) -> ExtensionTyped<'_>
pub fn as_extension_typed(&self) -> ExtensionTyped<'_>
Downcasts the array for extension-specific behavior.
Trait Implementations§
Source§impl AsRef<dyn Array> for ChunkedArray
impl AsRef<dyn Array> for ChunkedArray
Source§impl AsRef<dyn Array> for ConstantArray
impl AsRef<dyn Array> for ConstantArray
Source§impl AsRef<dyn Array> for DecimalArray
impl AsRef<dyn Array> for DecimalArray
Source§impl AsRef<dyn Array> for ExtensionArray
impl AsRef<dyn Array> for ExtensionArray
Source§impl AsRef<dyn Array> for PrimitiveArray
impl AsRef<dyn Array> for PrimitiveArray
Source§impl AsRef<dyn Array> for StructArray
impl AsRef<dyn Array> for StructArray
Source§impl AsRef<dyn Array> for VarBinArray
impl AsRef<dyn Array> for VarBinArray
Source§impl AsRef<dyn Array> for VarBinViewArray
impl AsRef<dyn Array> for VarBinViewArray
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).