Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions encodings/alp/src/alp/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@

use vortex_array::Array;
use vortex_array::ArrayRef;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::compute::TakeKernel;
use vortex_array::compute::TakeKernelAdapter;
use vortex_array::compute::take;
use vortex_array::register_kernel;
use vortex_array::arrays::TakeExecute;
use vortex_error::VortexResult;

use crate::ALPArray;
use crate::ALPVTable;

impl TakeKernel for ALPVTable {
fn take(&self, array: &ALPArray, indices: &dyn Array) -> VortexResult<ArrayRef> {
let taken_encoded = take(array.encoded(), indices)?;
impl TakeExecute for ALPVTable {
fn take(
array: &ALPArray,
indices: &dyn Array,
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<ArrayRef>> {
let taken_encoded = array.encoded().take(indices.to_array())?;
let taken_patches = array
.patches()
.map(|p| p.take(indices))
Expand All @@ -29,12 +31,12 @@ impl TakeKernel for ALPVTable {
)
})
.transpose()?;
Ok(ALPArray::new(taken_encoded, array.exponents(), taken_patches).into_array())
Ok(Some(
ALPArray::new(taken_encoded, array.exponents(), taken_patches).into_array(),
))
}
}

register_kernel!(TakeKernelAdapter(ALPVTable).lift());

#[cfg(test)]
mod test {
use rstest::rstest;
Expand Down
2 changes: 2 additions & 0 deletions encodings/alp/src/alp/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

use vortex_array::arrays::FilterExecuteAdaptor;
use vortex_array::arrays::SliceExecuteAdaptor;
use vortex_array::arrays::TakeExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;

use crate::ALPVTable;

pub(super) const PARENT_KERNELS: ParentKernelSet<ALPVTable> = ParentKernelSet::new(&[
ParentKernelSet::lift(&FilterExecuteAdaptor(ALPVTable)),
ParentKernelSet::lift(&SliceExecuteAdaptor(ALPVTable)),
ParentKernelSet::lift(&TakeExecuteAdaptor(ALPVTable)),
]);
44 changes: 23 additions & 21 deletions encodings/alp/src/alp_rd/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@

use vortex_array::Array;
use vortex_array::ArrayRef;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::compute::TakeKernel;
use vortex_array::compute::TakeKernelAdapter;
use vortex_array::arrays::TakeExecute;
use vortex_array::compute::fill_null;
use vortex_array::compute::take;
use vortex_array::register_kernel;
use vortex_error::VortexResult;
use vortex_scalar::Scalar;
use vortex_scalar::ScalarValue;

use crate::ALPRDArray;
use crate::ALPRDVTable;

impl TakeKernel for ALPRDVTable {
fn take(&self, array: &ALPRDArray, indices: &dyn Array) -> VortexResult<ArrayRef> {
let taken_left_parts = take(array.left_parts(), indices)?;
impl TakeExecute for ALPRDVTable {
fn take(
array: &ALPRDArray,
indices: &dyn Array,
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<ArrayRef>> {
let taken_left_parts = array.left_parts().take(indices.to_array())?;
let left_parts_exceptions = array
.left_parts_patches()
.map(|patches| patches.take(indices))
Expand All @@ -33,26 +35,26 @@ impl TakeKernel for ALPRDVTable {
})
.transpose()?;
let right_parts = fill_null(
&take(array.right_parts(), indices)?,
&array.right_parts().take(indices.to_array())?,
&Scalar::new(array.right_parts().dtype().clone(), ScalarValue::from(0)),
)?;

Ok(ALPRDArray::try_new(
array
.dtype()
.with_nullability(taken_left_parts.dtype().nullability()),
taken_left_parts,
array.left_parts_dictionary().clone(),
right_parts,
array.right_bit_width(),
left_parts_exceptions,
)?
.into_array())
Ok(Some(
ALPRDArray::try_new(
array
.dtype()
.with_nullability(taken_left_parts.dtype().nullability()),
taken_left_parts,
array.left_parts_dictionary().clone(),
right_parts,
array.right_bit_width(),
left_parts_exceptions,
)?
.into_array(),
))
}
}

register_kernel!(TakeKernelAdapter(ALPRDVTable).lift());

#[cfg(test)]
mod test {
use rstest::rstest;
Expand Down
2 changes: 2 additions & 0 deletions encodings/alp/src/alp_rd/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

use vortex_array::arrays::FilterExecuteAdaptor;
use vortex_array::arrays::SliceExecuteAdaptor;
use vortex_array::arrays::TakeExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;

use crate::alp_rd::ALPRDVTable;

pub(crate) static PARENT_KERNELS: ParentKernelSet<ALPRDVTable> = ParentKernelSet::new(&[
ParentKernelSet::lift(&SliceExecuteAdaptor(ALPRDVTable)),
ParentKernelSet::lift(&FilterExecuteAdaptor(ALPRDVTable)),
ParentKernelSet::lift(&TakeExecuteAdaptor(ALPRDVTable)),
]);
11 changes: 11 additions & 0 deletions encodings/bytebool/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ use vortex_error::vortex_panic;
use vortex_scalar::Scalar;
use vortex_session::VortexSession;

use crate::kernel::PARENT_KERNELS;

vtable!(ByteBool);

impl VTable for ByteBoolVTable {
Expand Down Expand Up @@ -124,6 +126,15 @@ impl VTable for ByteBoolVTable {
let validity = array.validity().clone();
Ok(BoolArray::new(boolean_buffer, validity).into_array())
}

fn execute_parent(
array: &Self::Array,
parent: &ArrayRef,
child_idx: usize,
ctx: &mut ExecutionCtx,
) -> VortexResult<Option<ArrayRef>> {
PARENT_KERNELS.execute(array, parent, child_idx, ctx)
}
}

#[derive(Clone, Debug)]
Expand Down
18 changes: 11 additions & 7 deletions encodings/bytebool/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
use num_traits::AsPrimitive;
use vortex_array::Array;
use vortex_array::ArrayRef;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::ToCanonical;
use vortex_array::arrays::TakeExecute;
use vortex_array::compute::CastKernel;
use vortex_array::compute::CastKernelAdapter;
use vortex_array::compute::MaskKernel;
use vortex_array::compute::MaskKernelAdapter;
use vortex_array::compute::TakeKernel;
use vortex_array::compute::TakeKernelAdapter;
use vortex_array::register_kernel;
use vortex_array::vtable::ValidityHelper;
use vortex_dtype::DType;
Expand Down Expand Up @@ -55,8 +55,12 @@ impl MaskKernel for ByteBoolVTable {

register_kernel!(MaskKernelAdapter(ByteBoolVTable).lift());

impl TakeKernel for ByteBoolVTable {
fn take(&self, array: &ByteBoolArray, indices: &dyn Array) -> VortexResult<ArrayRef> {
impl TakeExecute for ByteBoolVTable {
fn take(
array: &ByteBoolArray,
indices: &dyn Array,
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<ArrayRef>> {
let indices = indices.to_primitive();
let bools = array.as_slice();

Expand All @@ -74,12 +78,12 @@ impl TakeKernel for ByteBoolVTable {
.collect::<Vec<bool>>()
});

Ok(ByteBoolArray::from_vec(taken_bools, validity).into_array())
Ok(Some(
ByteBoolArray::from_vec(taken_bools, validity).into_array(),
))
}
}

register_kernel!(TakeKernelAdapter(ByteBoolVTable).lift());

#[cfg(test)]
mod tests {
use rstest::rstest;
Expand Down
10 changes: 10 additions & 0 deletions encodings/bytebool/src/kernel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::arrays::TakeExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;

use crate::ByteBoolVTable;

pub(crate) const PARENT_KERNELS: ParentKernelSet<ByteBoolVTable> =
ParentKernelSet::new(&[ParentKernelSet::lift(&TakeExecuteAdaptor(ByteBoolVTable))]);
1 change: 1 addition & 0 deletions encodings/bytebool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pub use array::*;

mod array;
mod compute;
mod kernel;
mod rules;
mod slice;
10 changes: 10 additions & 0 deletions encodings/datetime-parts/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use vortex_error::vortex_err;
use vortex_session::VortexSession;

use crate::canonical::decode_to_temporal;
use crate::compute::kernel::PARENT_KERNELS;
use crate::compute::rules::PARENT_RULES;

vtable!(DateTimeParts);
Expand Down Expand Up @@ -168,6 +169,15 @@ impl VTable for DateTimePartsVTable {
) -> VortexResult<Option<ArrayRef>> {
PARENT_RULES.evaluate(array, parent, child_idx)
}

fn execute_parent(
array: &Self::Array,
parent: &ArrayRef,
child_idx: usize,
ctx: &mut ExecutionCtx,
) -> VortexResult<Option<ArrayRef>> {
PARENT_KERNELS.execute(array, parent, child_idx, ctx)
}
}

#[derive(Clone, Debug)]
Expand Down
12 changes: 12 additions & 0 deletions encodings/datetime-parts/src/compute/kernel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::arrays::TakeExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;

use crate::DateTimePartsVTable;

pub(crate) const PARENT_KERNELS: ParentKernelSet<DateTimePartsVTable> =
ParentKernelSet::new(&[ParentKernelSet::lift(&TakeExecuteAdaptor(
DateTimePartsVTable,
))]);
1 change: 1 addition & 0 deletions encodings/datetime-parts/src/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod cast;
mod compare;
mod filter;
mod is_constant;
pub(crate) mod kernel;
mod mask;
pub(super) mod rules;
mod slice;
Expand Down
Loading
Loading