pub trait Array:
'static
+ Sealed
+ Send
+ Sync
+ Debug
+ DynArrayEq
+ DynArrayHash
+ ArrayVisitor
+ ReduceNode {
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 len(&self) -> usize;
fn dtype(&self) -> &DType;
fn vtable(&self) -> &dyn DynVTable;
fn encoding_id(&self) -> ArrayId;
fn slice(&self, range: Range<usize>) -> VortexResult<ArrayRef>;
fn filter(&self, mask: Mask) -> VortexResult<ArrayRef>;
fn take(&self, indices: ArrayRef) -> 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(&self) -> VortexResult<Validity>;
fn validity_mask(&self) -> VortexResult<Mask>;
fn to_canonical(&self) -> VortexResult<Canonical>;
fn append_to_builder(
&self,
builder: &mut dyn ArrayBuilder,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>;
fn statistics(&self) -> StatsSetRef<'_>;
fn with_children(&self, children: Vec<ArrayRef>) -> VortexResult<ArrayRef>;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
The public API trait for all Vortex arrays.
Required Methods§
Sourcefn as_any_arc(self: Arc<Self>) -> Arc<dyn Any + Send + Sync>
fn as_any_arc(self: Arc<Self>) -> Arc<dyn Any + Send + Sync>
Returns the array as an Arc<dyn Any + Send + Sync>.
Sourcefn encoding_id(&self) -> ArrayId
fn encoding_id(&self) -> ArrayId
Returns the encoding ID of the array.
Sourcefn slice(&self, range: Range<usize>) -> VortexResult<ArrayRef>
fn slice(&self, range: Range<usize>) -> VortexResult<ArrayRef>
Performs a constant-time slice of the array.
Sourcefn filter(&self, mask: Mask) -> VortexResult<ArrayRef>
fn filter(&self, mask: Mask) -> VortexResult<ArrayRef>
Wraps the array in a FilterArray such that it is logically filtered by the given mask.
Sourcefn take(&self, indices: ArrayRef) -> VortexResult<ArrayRef>
fn take(&self, indices: ArrayRef) -> VortexResult<ArrayRef>
Wraps the array in a DictArray such that it is logically taken by the given indices.
Sourcefn scalar_at(&self, index: usize) -> VortexResult<Scalar>
fn scalar_at(&self, index: usize) -> VortexResult<Scalar>
Fetch the scalar at the given index.
This method panics if the index is out of bounds for 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, but may return false
negatives.
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, but may return false
negatives.
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(&self) -> VortexResult<Validity>
fn validity(&self) -> VortexResult<Validity>
Returns the Validity of 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,
ctx: &mut ExecutionCtx,
) -> VortexResult<()>
fn append_to_builder( &self, builder: &mut dyn ArrayBuilder, ctx: &mut ExecutionCtx, ) -> 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: Vec<ArrayRef>) -> VortexResult<ArrayRef>
fn with_children(&self, children: Vec<ArrayRef>) -> VortexResult<ArrayRef>
Replaces the children of the array with the given array references.
Provided Methods§
Implementations§
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn as_opt<M: Matcher>(&self) -> Option<M::Match<'_>>
pub fn as_opt<M: Matcher>(&self) -> Option<M::Match<'_>>
Returns the array downcast by the given matcher.
Sourcepub fn try_into<V: VTable>(self: Arc<Self>) -> Result<V::Array, Arc<Self>>
pub fn try_into<V: VTable>(self: Arc<Self>) -> Result<V::Array, Arc<Self>>
Returns the array downcast to the given A as an owned object.
pub fn as_constant(&self) -> Option<Scalar>
Sourcepub fn nbytes(&self) -> u64
pub fn nbytes(&self) -> u64
Total size of the array in bytes, including all children and buffers.
Sourcepub fn is_canonical(&self) -> bool
pub fn is_canonical(&self) -> bool
Whether the array is of a canonical encoding.
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn try_to_mask_fill_null_false(&self) -> VortexResult<Mask>
pub fn try_to_mask_fill_null_false(&self) -> VortexResult<Mask>
Converts from a possible nullable boolean array. Null values are treated as false.
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn display_values(&self) -> impl Display
pub fn display_values(&self) -> impl Display
Display logical values of the array
For example, an i16 typed array containing the first five non-negative integers is displayed
as: [0i16, 1i16, 2i16, 3i16, 4i16].
§Examples
let array = buffer![0_i16, 1, 2, 3, 4].into_array();
assert_eq!(
format!("{}", array.display_values()),
"[0i16, 1i16, 2i16, 3i16, 4i16]",
)See also: Array::display_as, DisplayArrayAs, and DisplayOptions.
Sourcepub fn display_as(&self, options: DisplayOptions) -> impl Display
pub fn display_as(&self, options: DisplayOptions) -> impl Display
Display the array as specified by the options.
See DisplayOptions for examples.
Sourcepub fn display_tree_encodings_only(&self) -> impl Display
pub fn display_tree_encodings_only(&self) -> impl Display
Display the tree of array encodings and lengths without metadata, buffers, or stats.
§Examples
let array = buffer![0_i16, 1, 2, 3, 4].into_array();
let expected = "root: vortex.primitive(i16, len=5)\n";
assert_eq!(format!("{}", array.display_tree_encodings_only()), expected);
let array = StructArray::from_fields(&[
("x", buffer![1, 2].into_array()),
("y", buffer![3, 4].into_array()),
]).unwrap().into_array();
let expected = "root: vortex.struct({x=i32, y=i32}, len=2)
x: vortex.primitive(i32, len=2)
y: vortex.primitive(i32, len=2)
";
assert_eq!(format!("{}", array.display_tree_encodings_only()), expected);Sourcepub fn display_tree(&self) -> impl Display
pub fn display_tree(&self) -> impl Display
Display the tree of encodings of this array as an indented lists.
While some metadata (such as length, bytes and validity-rate) are included, the logical values of the array are not displayed. To view the logical values see Array::display_as and DisplayOptions.
§Examples
let array = buffer![0_i16, 1, 2, 3, 4].into_array();
let expected = "root: vortex.primitive(i16, len=5) nbytes=10 B (100.00%)
metadata: EmptyMetadata
buffer: values host 10 B (align=2) (100.00%)
";
assert_eq!(format!("{}", array.display_tree()), expected);Sourcepub fn display_table(&self) -> impl Display
pub fn display_table(&self) -> impl Display
Display the array as a formatted table.
For struct arrays, displays a column for each field in the struct. For regular arrays, displays a single column with values.
§Examples
let s = StructArray::from_fields(&[
("x", buffer![1, 2].into_array()),
("y", buffer![3, 4].into_array()),
]).unwrap().into_array();
let expected = "
┌──────┬──────┐
│ x │ y │
├──────┼──────┤
│ 1i32 │ 3i32 │
├──────┼──────┤
│ 2i32 │ 4i32 │
└──────┴──────┘".trim();
assert_eq!(format!("{}", s.display_table()), expected);Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn execute<E: Executable>(
self: Arc<Self>,
ctx: &mut ExecutionCtx,
) -> VortexResult<E>
pub fn execute<E: Executable>( self: Arc<Self>, ctx: &mut ExecutionCtx, ) -> VortexResult<E>
Execute this array to produce an instance of E.
See the Executable implementation for details on how this execution is performed.
Sourcepub fn execute_as<E: Executable>(
self: Arc<Self>,
name: &'static str,
ctx: &mut ExecutionCtx,
) -> VortexResult<E>
pub fn execute_as<E: Executable>( self: Arc<Self>, name: &'static str, ctx: &mut ExecutionCtx, ) -> VortexResult<E>
Execute this array, labeling the execution step with a name for tracing.
Source§impl dyn Array + '_
impl dyn Array + '_
Sourcepub fn apply(&self, expr: &Expression) -> VortexResult<ArrayRef>
pub fn apply(&self, expr: &Expression) -> VortexResult<ArrayRef>
Apply the expression to this array, producing a new array in constant time.
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 normalize(
self: ArrayRef,
options: &mut NormalizeOptions<'_>,
) -> VortexResult<ArrayRef>
pub fn normalize( self: ArrayRef, options: &mut NormalizeOptions<'_>, ) -> VortexResult<ArrayRef>
Normalize the array according to given options.
This operation performs a recursive traversal of the array. Any non-allowed encoding is normalized per the configured operation.
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 ArrowArray
impl AsRef<dyn Array> for ArrowArray
Source§impl AsRef<dyn Array> for CanonicalView<'_>
impl AsRef<dyn Array> for CanonicalView<'_>
Source§impl AsRef<dyn Array> for ChunkedArray
impl AsRef<dyn Array> for ChunkedArray
Source§impl<'a> AsRef<dyn Array> for ColumnarView<'a>
impl<'a> AsRef<dyn Array> for ColumnarView<'a>
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 FilterArray
impl AsRef<dyn Array> for FilterArray
Source§impl AsRef<dyn Array> for FixedSizeListArray
impl AsRef<dyn Array> for FixedSizeListArray
Source§impl AsRef<dyn Array> for ListViewArray
impl AsRef<dyn Array> for ListViewArray
Source§impl AsRef<dyn Array> for MaskedArray
impl AsRef<dyn Array> for MaskedArray
Source§impl AsRef<dyn Array> for PrimitiveArray
impl AsRef<dyn Array> for PrimitiveArray
Source§impl AsRef<dyn Array> for ScalarFnArray
impl AsRef<dyn Array> for ScalarFnArray
Source§impl AsRef<dyn Array> for SliceArray
impl AsRef<dyn Array> for SliceArray
Source§impl AsRef<dyn Array> for StructArray
impl AsRef<dyn Array> for StructArray
Source§impl AsRef<dyn Array> for TemporalArray
impl AsRef<dyn Array> for TemporalArray
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 Display for dyn Array + '_
Display the encoding and limited metadata of this array.
impl Display for dyn Array + '_
Display the encoding and limited metadata of this array.
§Examples
let array = buffer![0_i16, 1, 2, 3, 4].into_array();
assert_eq!(
format!("{}", array),
"vortex.primitive(i16, len=5)",
);Source§impl IndexOrd<Scalar> for dyn Array + '_
impl IndexOrd<Scalar> for dyn Array + '_
Source§fn index_cmp(&self, idx: usize, elem: &Scalar) -> VortexResult<Option<Ordering>>
fn index_cmp(&self, idx: usize, elem: &Scalar) -> VortexResult<Option<Ordering>>
idx with elem.
For example, if self[idx] > elem, return Some(Greater).