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
81 changes: 30 additions & 51 deletions encodings/alp/src/alp_rd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use vortex_array::ExecutionCtx;
use vortex_array::ExecutionResult;
use vortex_array::IntoArray;
use vortex_array::TypedArrayRef;
use vortex_array::array_slots;
use vortex_array::arrays::Primitive;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::buffer::BufferHandle;
Expand Down Expand Up @@ -105,11 +106,12 @@ impl VTable for ALPRD {
len: usize,
slots: &[Option<ArrayRef>],
) -> VortexResult<()> {
let alprd_slots = ALPRDSlotsView::from_slots(slots);
validate_parts(
dtype,
len,
left_parts_from_slots(slots),
right_parts_from_slots(slots),
alprd_slots.left_parts,
alprd_slots.right_parts,
patches_from_slots(slots, data.patches_data.as_ref(), len).as_ref(),
)
}
Expand Down Expand Up @@ -230,17 +232,18 @@ impl VTable for ALPRD {
}

fn slot_name(_array: ArrayView<'_, Self>, idx: usize) -> String {
SLOT_NAMES[idx].to_string()
ALPRDSlots::NAMES[idx].to_string()
}

fn execute(array: Array<Self>, ctx: &mut ExecutionCtx) -> VortexResult<ExecutionResult> {
let array = require_child!(array, array.left_parts(), 0 => Primitive);
let array = require_child!(array, array.right_parts(), 1 => Primitive);
let array = require_child!(array, array.left_parts(), ALPRDSlots::LEFT_PARTS => Primitive);
let array =
require_child!(array, array.right_parts(), ALPRDSlots::RIGHT_PARTS => Primitive);
require_patches!(
array,
LP_PATCH_INDICES_SLOT,
LP_PATCH_VALUES_SLOT,
LP_PATCH_CHUNK_OFFSETS_SLOT
ALPRDSlots::PATCH_INDICES,
ALPRDSlots::PATCH_VALUES,
ALPRDSlots::PATCH_CHUNK_OFFSETS
);

let dtype = array.dtype().clone();
Expand Down Expand Up @@ -307,29 +310,25 @@ impl VTable for ALPRD {
}
}

/// The left (most significant) parts of the real-double encoded values.
pub(super) const LEFT_PARTS_SLOT: usize = 0;
/// The right (least significant) parts of the real-double encoded values.
pub(super) const RIGHT_PARTS_SLOT: usize = 1;
/// The indices of left-parts exception values that could not be dictionary-encoded.
pub(super) const LP_PATCH_SLOTS: PatchSlotIndices = PatchSlotIndices {
indices: LP_PATCH_INDICES_SLOT,
values: LP_PATCH_VALUES_SLOT,
chunk_offsets: LP_PATCH_CHUNK_OFFSETS_SLOT,
#[array_slots(ALPRD)]
pub struct ALPRDSlots {
/// The left (most significant) parts of the real-double encoded values.
pub left_parts: ArrayRef,
/// The right (least significant) parts of the real-double encoded values.
pub right_parts: ArrayRef,
/// The indices of left-parts exception values that could not be dictionary-encoded.
pub patch_indices: Option<ArrayRef>,
/// The exception values for left-parts that could not be dictionary-encoded.
pub patch_values: Option<ArrayRef>,
/// Chunk offsets for the left-parts patch indices/values.
pub patch_chunk_offsets: Option<ArrayRef>,
}

const LP_PATCH_SLOTS: PatchSlotIndices = PatchSlotIndices {
indices: ALPRDSlots::PATCH_INDICES,
values: ALPRDSlots::PATCH_VALUES,
chunk_offsets: ALPRDSlots::PATCH_CHUNK_OFFSETS,
};
pub(super) const LP_PATCH_INDICES_SLOT: usize = 2;
/// The exception values for left-parts that could not be dictionary-encoded.
pub(super) const LP_PATCH_VALUES_SLOT: usize = 3;
/// Chunk offsets for the left-parts patch indices/values.
pub(super) const LP_PATCH_CHUNK_OFFSETS_SLOT: usize = 4;
pub(super) const NUM_SLOTS: usize = 5;
pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = [
"left_parts",
"right_parts",
"patch_indices",
"patch_values",
"patch_chunk_offsets",
];

#[derive(Clone, Debug)]
pub struct ALPRDData {
Expand Down Expand Up @@ -451,18 +450,6 @@ impl ALPRDData {
}
}

fn left_parts_from_slots(slots: &[Option<ArrayRef>]) -> &ArrayRef {
slots[LEFT_PARTS_SLOT]
.as_ref()
.vortex_expect("ALPRDArray left_parts slot")
}

fn right_parts_from_slots(slots: &[Option<ArrayRef>]) -> &ArrayRef {
slots[RIGHT_PARTS_SLOT]
.as_ref()
.vortex_expect("ALPRDArray right_parts slot")
}

fn patches_from_slots(
slots: &[Option<ArrayRef>],
patches_data: Option<&PatchesData>,
Expand Down Expand Up @@ -539,15 +526,7 @@ fn validate_parts(
Ok(())
}

pub trait ALPRDArrayExt: TypedArrayRef<ALPRD> {
fn left_parts(&self) -> &ArrayRef {
left_parts_from_slots(self.as_ref().slots())
}

fn right_parts(&self) -> &ArrayRef {
right_parts_from_slots(self.as_ref().slots())
}

pub trait ALPRDArrayExt: ALPRDArraySlotsExt {
fn right_bit_width(&self) -> u8 {
ALPRDData::right_bit_width(self)
}
Expand Down
1 change: 1 addition & 0 deletions encodings/alp/src/alp_rd/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use vortex_array::scalar_fn::fns::cast::CastReduce;
use vortex_error::VortexResult;

use crate::ALPRDArrayExt;
use crate::ALPRDArraySlotsExt;
use crate::alp_rd::ALPRD;

impl CastReduce for ALPRD {
Expand Down
1 change: 1 addition & 0 deletions encodings/alp/src/alp_rd/compute/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use vortex_mask::Mask;

use crate::ALPRD;
use crate::ALPRDArrayExt;
use crate::ALPRDArraySlotsExt;

impl FilterKernel for ALPRD {
fn filter(
Expand Down
1 change: 1 addition & 0 deletions encodings/alp/src/alp_rd/compute/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use vortex_error::VortexResult;

use crate::ALPRD;
use crate::ALPRDArrayExt;
use crate::ALPRDArraySlotsExt;

impl MaskReduce for ALPRD {
#[allow(clippy::disallowed_methods)]
Expand Down
1 change: 1 addition & 0 deletions encodings/alp/src/alp_rd/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use vortex_error::VortexResult;

use crate::ALPRD;
use crate::ALPRDArrayExt;
use crate::ALPRDArraySlotsExt;

impl TakeExecute for ALPRD {
fn take(
Expand Down
1 change: 1 addition & 0 deletions encodings/alp/src/alp_rd/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use vortex_error::VortexResult;

use crate::ALPRD;
use crate::ALPRDArrayExt;
use crate::ALPRDArraySlotsExt;

impl OperationsVTable<ALPRD> for ALPRD {
fn scalar_at(
Expand Down
1 change: 1 addition & 0 deletions encodings/alp/src/alp_rd/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use vortex_array::arrays::slice::SliceKernel;
use vortex_error::VortexResult;

use crate::ALPRDArrayExt;
use crate::ALPRDArraySlotsExt;
use crate::alp_rd::ALPRD;

impl SliceKernel for ALPRD {
Expand Down
24 changes: 14 additions & 10 deletions encodings/bytebool/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use vortex_array::ExecutionCtx;
use vortex_array::ExecutionResult;
use vortex_array::IntoArray;
use vortex_array::TypedArrayRef;
use vortex_array::array_slots;
use vortex_array::arrays::BoolArray;
use vortex_array::buffer::BufferHandle;
use vortex_array::dtype::DType;
Expand Down Expand Up @@ -72,7 +73,8 @@ impl VTable for ByteBool {
len: usize,
slots: &[Option<ArrayRef>],
) -> VortexResult<()> {
let validity = child_to_validity(slots[VALIDITY_SLOT].as_ref(), dtype.nullability());
let validity =
child_to_validity(slots[ByteBoolSlots::VALIDITY].as_ref(), dtype.nullability());
ByteBoolData::validate(data.buffer(), &validity, dtype, len)
}

Expand Down Expand Up @@ -153,7 +155,7 @@ impl VTable for ByteBool {
}

fn slot_name(_array: ArrayView<'_, Self>, idx: usize) -> String {
SLOT_NAMES[idx].to_string()
ByteBoolSlots::NAMES[idx].to_string()
}

fn reduce_parent(
Expand All @@ -174,10 +176,11 @@ impl VTable for ByteBool {
}
}

/// The validity bitmap indicating which elements are non-null.
pub(super) const VALIDITY_SLOT: usize = 0;
pub(super) const NUM_SLOTS: usize = 1;
pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = ["validity"];
#[array_slots(ByteBool)]
pub struct ByteBoolSlots {
/// The validity bitmap indicating which elements are non-null.
pub validity: Option<ArrayRef>,
}

#[derive(Clone, Debug)]
pub struct ByteBoolData {
Expand All @@ -190,10 +193,11 @@ impl Display for ByteBoolData {
}
}

pub trait ByteBoolArrayExt: TypedArrayRef<ByteBool> {
fn validity(&self) -> Validity {
pub trait ByteBoolArrayExt: TypedArrayRef<ByteBool> + ByteBoolArraySlotsExt {
/// Returns the [`Validity`] derived from the validity slot.
fn bytebool_validity(&self) -> Validity {
child_to_validity(
self.as_ref().slots()[VALIDITY_SLOT].as_ref(),
self.as_ref().slots()[ByteBoolSlots::VALIDITY].as_ref(),
self.as_ref().dtype().nullability(),
)
}
Expand Down Expand Up @@ -302,7 +306,7 @@ impl ByteBoolData {

impl ValidityVTable<ByteBool> for ByteBool {
fn validity(array: ArrayView<'_, ByteBool>) -> VortexResult<Validity> {
Ok(ByteBoolArrayExt::validity(&array))
Ok(array.bytebool_validity())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vortex_array::scalar_fn::fns::cast::CastReduce;
use vortex_error::VortexResult;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;

impl CastReduce for DecimalByteParts {
fn cast(array: ArrayView<'_, Self>, dtype: &DType) -> VortexResult<Option<ArrayRef>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;
use crate::decimal_byte_parts::compute::compare::Sign::Positive;

impl CompareKernel for DecimalByteParts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vortex_error::VortexResult;
use vortex_mask::Mask;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;
impl FilterReduce for DecimalByteParts {
fn filter(array: ArrayView<'_, Self>, mask: &Mask) -> VortexResult<Option<ArrayRef>> {
DecimalByteParts::try_new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vortex_array::scalar::Scalar;
use vortex_error::VortexResult;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;

/// DecimalByteParts-specific is_constant kernel.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;

impl MaskReduce for DecimalByteParts {
fn mask(array: ArrayView<'_, Self>, mask: &ArrayRef) -> VortexResult<Option<ArrayRef>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;

impl TakeExecute for DecimalByteParts {
fn take(
Expand Down
27 changes: 8 additions & 19 deletions encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use vortex_array::EqMode;
use vortex_array::ExecutionCtx;
use vortex_array::ExecutionResult;
use vortex_array::IntoArray;
use vortex_array::TypedArrayRef;
use vortex_array::array_slots;
use vortex_array::arrays::DecimalArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::buffer::BufferHandle;
Expand Down Expand Up @@ -90,9 +90,7 @@ impl VTable for DecimalByteParts {
let Some(decimal_dtype) = dtype.as_decimal_opt() else {
vortex_bail!("expected decimal dtype, got {}", dtype)
};
let msp = slots[MSP_SLOT]
.as_ref()
.vortex_expect("DecimalBytePartsArray msp slot");
let msp = DecimalBytePartsSlotsView::from_slots(slots).msp;
DecimalBytePartsData::validate(msp, *decimal_dtype, dtype, len)
}

Expand Down Expand Up @@ -158,7 +156,7 @@ impl VTable for DecimalByteParts {
}

fn slot_name(_array: ArrayView<'_, Self>, idx: usize) -> String {
SLOT_NAMES[idx].to_string()
DecimalBytePartsSlots::NAMES[idx].to_string()
}

fn reduce_parent(
Expand All @@ -174,10 +172,11 @@ impl VTable for DecimalByteParts {
}
}

/// The most significant parts of the decimal values.
pub(super) const MSP_SLOT: usize = 0;
pub(super) const NUM_SLOTS: usize = 1;
pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = ["msp"];
#[array_slots(DecimalByteParts)]
pub struct DecimalBytePartsSlots {
/// The most significant parts of the decimal values.
pub msp: ArrayRef,
}

/// This array encodes decimals as between 1-4 columns of primitive typed children.
/// The most significant part (msp) sorting the most significant decimal bits.
Expand All @@ -202,16 +201,6 @@ pub struct DecimalBytePartsDataParts {
pub msp: ArrayRef,
}

pub trait DecimalBytePartsArrayExt: TypedArrayRef<DecimalByteParts> {
fn msp(&self) -> &ArrayRef {
self.as_ref().slots()[MSP_SLOT]
.as_ref()
.vortex_expect("DecimalBytePartsArray msp slot")
}
}

impl<T: TypedArrayRef<DecimalByteParts>> DecimalBytePartsArrayExt for T {}

impl DecimalBytePartsData {
pub fn validate(
msp: &ArrayRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;

pub(super) const PARENT_RULES: ParentRuleSet<DecimalByteParts> = ParentRuleSet::new(&[
ParentRuleSet::lift(&DecimalBytePartsFilterPushDownRule),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::DecimalByteParts;
use crate::decimal_byte_parts::DecimalBytePartsArrayExt;
use crate::decimal_byte_parts::DecimalBytePartsArraySlotsExt;

impl SliceReduce for DecimalByteParts {
fn slice(array: ArrayView<'_, Self>, range: Range<usize>) -> VortexResult<Option<ArrayRef>> {
Expand Down
1 change: 1 addition & 0 deletions encodings/fastlanes/src/delta/array/delta_decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use vortex_error::VortexResult;
use crate::DeltaArray;
use crate::bit_transpose::untranspose_validity;
use crate::delta::array::DeltaArrayExt;
use crate::delta::array::DeltaArraySlotsExt;

pub fn delta_decompress(
array: &DeltaArray,
Expand Down
Loading
Loading