mod binary_numeric;
mod boolean;
mod compare;
mod invert;
mod search_sorted;
use vortex_error::VortexResult;
use vortex_scalar::Scalar;
use crate::array::constant::ConstantArray;
use crate::array::ConstantEncoding;
use crate::compute::{
BinaryBooleanFn, BinaryNumericFn, CompareFn, ComputeVTable, FilterFn, FilterMask, InvertFn,
ScalarAtFn, SearchSortedFn, SliceFn, TakeFn,
};
use crate::{ArrayData, IntoArrayData};
impl ComputeVTable for ConstantEncoding {
fn binary_boolean_fn(&self) -> Option<&dyn BinaryBooleanFn<ArrayData>> {
Some(self)
}
fn binary_numeric_fn(&self) -> Option<&dyn BinaryNumericFn<ArrayData>> {
Some(self)
}
fn compare_fn(&self) -> Option<&dyn CompareFn<ArrayData>> {
Some(self)
}
fn filter_fn(&self) -> Option<&dyn FilterFn<ArrayData>> {
Some(self)
}
fn invert_fn(&self) -> Option<&dyn InvertFn<ArrayData>> {
Some(self)
}
fn scalar_at_fn(&self) -> Option<&dyn ScalarAtFn<ArrayData>> {
Some(self)
}
fn search_sorted_fn(&self) -> Option<&dyn SearchSortedFn<ArrayData>> {
Some(self)
}
fn slice_fn(&self) -> Option<&dyn SliceFn<ArrayData>> {
Some(self)
}
fn take_fn(&self) -> Option<&dyn TakeFn<ArrayData>> {
Some(self)
}
}
impl ScalarAtFn<ConstantArray> for ConstantEncoding {
fn scalar_at(&self, array: &ConstantArray, _index: usize) -> VortexResult<Scalar> {
Ok(array.scalar())
}
}
impl TakeFn<ConstantArray> for ConstantEncoding {
fn take(&self, array: &ConstantArray, indices: &ArrayData) -> VortexResult<ArrayData> {
Ok(ConstantArray::new(array.scalar(), indices.len()).into_array())
}
}
impl SliceFn<ConstantArray> for ConstantEncoding {
fn slice(&self, array: &ConstantArray, start: usize, stop: usize) -> VortexResult<ArrayData> {
Ok(ConstantArray::new(array.scalar(), stop - start).into_array())
}
}
impl FilterFn<ConstantArray> for ConstantEncoding {
fn filter(&self, array: &ConstantArray, mask: FilterMask) -> VortexResult<ArrayData> {
Ok(ConstantArray::new(array.scalar(), mask.true_count()).into_array())
}
}