Skip to content
Draft
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
6 changes: 5 additions & 1 deletion encodings/alp/benches/alp_compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ const BENCH_ARGS: &[(usize, f64, f64)] = &[
(10_000, 0.1, 1.0),
];

static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_array::array_session);
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
vortex_alp::initialize(&session);
session
});

#[divan::bench(types = [f32, f64], args = BENCH_ARGS)]
fn compress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64, f64)) {
Expand Down
10 changes: 0 additions & 10 deletions encodings/alp/src/alp/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ use vortex_session::registry::CachedId;
use crate::ALPFloat;
use crate::alp::Exponents;
use crate::alp::decompress::execute_decompress;
use crate::alp::rules::PARENT_KERNELS;
use crate::alp::rules::RULES;

/// A [`ALP`]-encoded Vortex array.
Expand Down Expand Up @@ -188,15 +187,6 @@ impl VTable for ALP {
) -> VortexResult<Option<ArrayRef>> {
RULES.evaluate(array, parent, child_idx)
}

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

#[array_slots(ALP)]
Expand Down
5 changes: 5 additions & 0 deletions encodings/alp/src/alp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ use vortex_array::dtype::NativePType;
use vortex_array::scalar::PValue;
use vortex_buffer::Buffer;
use vortex_buffer::BufferMut;
use vortex_session::VortexSession;

const SAMPLE_SIZE: usize = 32;

pub(crate) fn initialize(session: &VortexSession) {
rules::initialize(session);
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Exponents {
pub e: u8,
Expand Down
25 changes: 17 additions & 8 deletions encodings/alp/src/alp/rules.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayVTable;
use vortex_array::arrays::Dict;
use vortex_array::arrays::Filter;
use vortex_array::arrays::Slice;
use vortex_array::arrays::dict::TakeExecuteAdaptor;
use vortex_array::arrays::filter::FilterExecuteAdaptor;
use vortex_array::arrays::slice::SliceExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;
use vortex_array::optimizer::kernels::ArrayKernelsExt;
use vortex_array::optimizer::rules::ParentRuleSet;
use vortex_array::scalar_fn::ScalarFnVTable;
use vortex_array::scalar_fn::fns::between::BetweenReduceAdaptor;
use vortex_array::scalar_fn::fns::binary::Binary;
use vortex_array::scalar_fn::fns::binary::CompareExecuteAdaptor;
use vortex_array::scalar_fn::fns::cast::CastReduceAdaptor;
use vortex_array::scalar_fn::fns::mask::Mask;
use vortex_array::scalar_fn::fns::mask::MaskExecuteAdaptor;
use vortex_array::scalar_fn::fns::mask::MaskReduceAdaptor;
use vortex_session::VortexSession;

use crate::ALP;

pub(super) const PARENT_KERNELS: ParentKernelSet<ALP> = ParentKernelSet::new(&[
ParentKernelSet::lift(&CompareExecuteAdaptor(ALP)),
ParentKernelSet::lift(&FilterExecuteAdaptor(ALP)),
ParentKernelSet::lift(&MaskExecuteAdaptor(ALP)),
ParentKernelSet::lift(&SliceExecuteAdaptor(ALP)),
ParentKernelSet::lift(&TakeExecuteAdaptor(ALP)),
]);
pub(super) fn initialize(session: &VortexSession) {
let kernels = session.kernels();
kernels.register_execute_parent_kernel(Binary.id(), ALP, CompareExecuteAdaptor(ALP));
kernels.register_execute_parent_kernel(Filter.id(), ALP, FilterExecuteAdaptor(ALP));
kernels.register_execute_parent_kernel(Mask.id(), ALP, MaskExecuteAdaptor(ALP));
kernels.register_execute_parent_kernel(Slice.id(), ALP, SliceExecuteAdaptor(ALP));
kernels.register_execute_parent_kernel(Dict.id(), ALP, TakeExecuteAdaptor(ALP));
}

pub(super) const RULES: ParentRuleSet<ALP> = ParentRuleSet::new(&[
ParentRuleSet::lift(&BetweenReduceAdaptor(ALP)),
Expand Down
10 changes: 0 additions & 10 deletions encodings/alp/src/alp_rd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ use vortex_error::vortex_panic;
use vortex_session::VortexSession;
use vortex_session::registry::CachedId;

use crate::alp_rd::kernel::PARENT_KERNELS;
use crate::alp_rd::rules::RULES;
use crate::alp_rd_decode;

Expand Down Expand Up @@ -307,15 +306,6 @@ impl VTable for ALPRD {
) -> VortexResult<Option<ArrayRef>> {
RULES.evaluate(array, parent, child_idx)
}

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

/// The left (most significant) parts of the real-double encoded values.
Expand Down
18 changes: 12 additions & 6 deletions encodings/alp/src/alp_rd/kernel.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayVTable;
use vortex_array::arrays::Dict;
use vortex_array::arrays::Filter;
use vortex_array::arrays::Slice;
use vortex_array::arrays::dict::TakeExecuteAdaptor;
use vortex_array::arrays::filter::FilterExecuteAdaptor;
use vortex_array::arrays::slice::SliceExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;
use vortex_array::optimizer::kernels::ArrayKernelsExt;
use vortex_session::VortexSession;

use crate::alp_rd::ALPRD;

pub(crate) static PARENT_KERNELS: ParentKernelSet<ALPRD> = ParentKernelSet::new(&[
ParentKernelSet::lift(&SliceExecuteAdaptor(ALPRD)),
ParentKernelSet::lift(&FilterExecuteAdaptor(ALPRD)),
ParentKernelSet::lift(&TakeExecuteAdaptor(ALPRD)),
]);
pub(crate) fn initialize(session: &VortexSession) {
let kernels = session.kernels();
kernels.register_execute_parent_kernel(Slice.id(), ALPRD, SliceExecuteAdaptor(ALPRD));
kernels.register_execute_parent_kernel(Filter.id(), ALPRD, FilterExecuteAdaptor(ALPRD));
kernels.register_execute_parent_kernel(Dict.id(), ALPRD, TakeExecuteAdaptor(ALPRD));
}
5 changes: 5 additions & 0 deletions encodings/alp/src/alp_rd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use vortex_buffer::BufferMut;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_panic;
use vortex_session::VortexSession;
use vortex_utils::aliases::hash_map::HashMap;

use crate::match_each_alp_float_ptype;
Expand All @@ -55,6 +56,10 @@ const CUT_LIMIT: usize = 16;

const MAX_DICT_SIZE: u8 = 8;

pub(crate) fn initialize(session: &VortexSession) {
kernel::initialize(session);
}

mod private {
pub trait Sealed {}

Expand Down
2 changes: 2 additions & 0 deletions encodings/alp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub fn initialize(session: &VortexSession) {
session.arrays().register(ALP);
}
session.arrays().register(ALPRD);
alp::initialize(session);
alp_rd::initialize(session);

// Register the ALP-specific NaN count aggregate kernel.
session.aggregate_fns().register_aggregate_kernel(
Expand Down
11 changes: 0 additions & 11 deletions encodings/bytebool/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use vortex_error::vortex_panic;
use vortex_session::VortexSession;
use vortex_session::registry::CachedId;

use crate::kernel::PARENT_KERNELS;

/// A [`ByteBool`]-encoded Vortex array.
pub type ByteBoolArray = Array<ByteBool>;

Expand Down Expand Up @@ -157,15 +155,6 @@ impl VTable for ByteBool {
BoolArray::new(boolean_buffer, validity).into_array(),
))
}

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

/// The validity bitmap indicating which elements are non-null.
Expand Down
16 changes: 11 additions & 5 deletions encodings/bytebool/src/kernel.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayVTable;
use vortex_array::arrays::Dict;
use vortex_array::arrays::dict::TakeExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;
use vortex_array::optimizer::kernels::ArrayKernelsExt;
use vortex_array::scalar_fn::ScalarFnVTable;
use vortex_array::scalar_fn::fns::cast::Cast;
use vortex_array::scalar_fn::fns::cast::CastExecuteAdaptor;
use vortex_session::VortexSession;

use crate::ByteBool;

pub(crate) const PARENT_KERNELS: ParentKernelSet<ByteBool> = ParentKernelSet::new(&[
ParentKernelSet::lift(&CastExecuteAdaptor(ByteBool)),
ParentKernelSet::lift(&TakeExecuteAdaptor(ByteBool)),
]);
pub(crate) fn initialize(session: &VortexSession) {
let kernels = session.kernels();
kernels.register_execute_parent_kernel(Cast.id(), ByteBool, CastExecuteAdaptor(ByteBool));
kernels.register_execute_parent_kernel(Dict.id(), ByteBool, TakeExecuteAdaptor(ByteBool));
}
8 changes: 8 additions & 0 deletions encodings/bytebool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@
//! [spec]: https://arrow.apache.org/docs/format/CanonicalExtensions.html#bit-boolean

pub use array::*;
use vortex_array::session::ArraySessionExt;
use vortex_session::VortexSession;

mod array;
mod compute;
mod kernel;
mod rules;
mod slice;

/// Initialize bytebool encoding in the given session.
pub fn initialize(session: &VortexSession) {
session.arrays().register(ByteBool);
kernel::initialize(session);
}
10 changes: 0 additions & 10 deletions encodings/datetime-parts/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use vortex_session::registry::CachedId;

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

Expand Down Expand Up @@ -200,15 +199,6 @@ impl VTable for DateTimeParts {
) -> VortexResult<Option<ArrayRef>> {
PARENT_RULES.evaluate(array, parent, child_idx)
}

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

#[array_slots(DateTimeParts)]
Expand Down
24 changes: 19 additions & 5 deletions encodings/datetime-parts/src/compute/kernel.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayVTable;
use vortex_array::arrays::Dict;
use vortex_array::arrays::dict::TakeExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;
use vortex_array::optimizer::kernels::ArrayKernelsExt;
use vortex_array::scalar_fn::ScalarFnVTable;
use vortex_array::scalar_fn::fns::binary::Binary;
use vortex_array::scalar_fn::fns::binary::CompareExecuteAdaptor;
use vortex_session::VortexSession;

use crate::DateTimeParts;

pub(crate) const PARENT_KERNELS: ParentKernelSet<DateTimeParts> = ParentKernelSet::new(&[
ParentKernelSet::lift(&CompareExecuteAdaptor(DateTimeParts)),
ParentKernelSet::lift(&TakeExecuteAdaptor(DateTimeParts)),
]);
pub(crate) fn initialize(session: &VortexSession) {
let kernels = session.kernels();
kernels.register_execute_parent_kernel(
Binary.id(),
DateTimeParts,
CompareExecuteAdaptor(DateTimeParts),
);
kernels.register_execute_parent_kernel(
Dict.id(),
DateTimeParts,
TakeExecuteAdaptor(DateTimeParts),
);
}
1 change: 1 addition & 0 deletions encodings/datetime-parts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use vortex_session::VortexSession;
/// Initialize datetime-parts encoding in the given session.
pub fn initialize(session: &VortexSession) {
session.arrays().register(DateTimeParts);
compute::kernel::initialize(session);

session.aggregate_fns().register_aggregate_kernel(
DateTimeParts.id(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_array::ArrayVTable;
use vortex_array::arrays::Dict;
use vortex_array::arrays::dict::TakeExecuteAdaptor;
use vortex_array::kernel::ParentKernelSet;
use vortex_array::optimizer::kernels::ArrayKernelsExt;
use vortex_array::scalar_fn::ScalarFnVTable;
use vortex_array::scalar_fn::fns::binary::Binary;
use vortex_array::scalar_fn::fns::binary::CompareExecuteAdaptor;
use vortex_session::VortexSession;

use crate::DecimalByteParts;

pub(crate) const PARENT_KERNELS: ParentKernelSet<DecimalByteParts> = ParentKernelSet::new(&[
ParentKernelSet::lift(&CompareExecuteAdaptor(DecimalByteParts)),
ParentKernelSet::lift(&TakeExecuteAdaptor(DecimalByteParts)),
]);
pub(crate) fn initialize(session: &VortexSession) {
let kernels = session.kernels();
kernels.register_execute_parent_kernel(
Binary.id(),
DecimalByteParts,
CompareExecuteAdaptor(DecimalByteParts),
);
kernels.register_execute_parent_kernel(
Dict.id(),
DecimalByteParts,
TakeExecuteAdaptor(DecimalByteParts),
);
}
10 changes: 0 additions & 10 deletions encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use vortex_error::vortex_panic;
use vortex_session::VortexSession;
use vortex_session::registry::CachedId;

use crate::decimal_byte_parts::compute::kernel::PARENT_KERNELS;
use crate::decimal_byte_parts::rules::PARENT_RULES;

/// A [`DecimalByteParts`]-encoded Vortex array.
Expand Down Expand Up @@ -165,15 +164,6 @@ impl VTable for DecimalByteParts {
fn execute(array: Array<Self>, ctx: &mut ExecutionCtx) -> VortexResult<ExecutionResult> {
to_canonical_decimal(&array, ctx).map(ExecutionResult::done)
}

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

/// The most significant parts of the decimal values.
Expand Down
1 change: 1 addition & 0 deletions encodings/decimal-byte-parts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use vortex_session::VortexSession;
/// Initialize decimal-byte-parts encoding in the given session.
pub fn initialize(session: &VortexSession) {
session.arrays().register(DecimalByteParts);
compute::kernel::initialize(session);

session.aggregate_fns().register_aggregate_kernel(
DecimalByteParts.id(),
Expand Down
6 changes: 5 additions & 1 deletion encodings/experimental/onpair/benches/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ impl DecodeInputs {
use vortex_onpair::onpair_compress;
use vortex_session::VortexSession;

static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_array::array_session);
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
vortex_onpair::initialize(&session);
session
});

#[derive(Copy, Clone, Debug)]
enum Shape {
Expand Down
Loading
Loading