vortex_array/compute/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
//! Compute kernels on top of Vortex Arrays.
//!
//! We aim to provide a basic set of compute kernels that can be used to efficiently index, slice,
//! and filter Vortex Arrays in their encoded forms.
//!
//! Every [array variant][crate::ArrayTrait] has the ability to implement their own efficient
//! implementations of these operators, else we will decode, and perform the equivalent operator
//! from Arrow.
pub use boolean::{and, or, AndFn, OrFn};
pub use compare::{compare, scalar_cmp, CompareFn, MaybeCompareFn, Operator};
pub use filter::{filter, FilterFn};
pub use search_sorted::*;
pub use slice::{slice, SliceFn};
pub use take::{take, TakeFn};
use unary::{CastFn, FillForwardFn, ScalarAtFn, SubtractScalarFn};
use vortex_error::VortexResult;
use crate::Array;
mod boolean;
mod compare;
mod filter;
mod search_sorted;
mod slice;
mod take;
pub mod unary;
/// Trait providing compute functions on top of Vortex arrays.
pub trait ArrayCompute {
/// Implemented for arrays that can be casted to different types.
///
/// See: [CastFn].
fn cast(&self) -> Option<&dyn CastFn> {
None
}
/// Binary operator implementation for arrays against other arrays.
///
///See: [CompareFn].
fn compare(&self, _other: &Array, _operator: Operator) -> Option<VortexResult<Array>> {
None
}
/// Array function that returns new arrays a non-null value is repeated across runs of nulls.
///
/// See: [FillForwardFn].
fn fill_forward(&self) -> Option<&dyn FillForwardFn> {
None
}
/// Filtering function on arrays of predicates.
///
/// See: [FilterFn].
fn filter(&self) -> Option<&dyn FilterFn> {
None
}
/// Single item indexing on Vortex arrays.
///
/// See: [ScalarAtFn].
fn scalar_at(&self) -> Option<&dyn ScalarAtFn> {
None
}
/// Broadcast subtraction of scalar from Vortex array.
///
/// See: [SubtractScalarFn].
fn subtract_scalar(&self) -> Option<&dyn SubtractScalarFn> {
None
}
/// Perform a search over an ordered array.
///
/// See: [SearchSortedFn].
fn search_sorted(&self) -> Option<&dyn SearchSortedFn> {
None
}
/// Perform zero-copy slicing of an array.
///
/// See: [SliceFn].
fn slice(&self) -> Option<&dyn SliceFn> {
None
}
/// Take a set of indices from an array. This often forces allocations and decoding of
/// the receiver.
///
/// See: [TakeFn].
fn take(&self) -> Option<&dyn TakeFn> {
None
}
/// Perform a boolean AND operation over two arrays
///
/// See: [AndFn].
fn and(&self) -> Option<&dyn AndFn> {
None
}
/// Perform a boolean OR operation over two arrays
///
/// See: [OrFn].
fn or(&self) -> Option<&dyn OrFn> {
None
}
}