diff --git a/docs/developer-guide/internals/execution.md b/docs/developer-guide/internals/execution.md index 07eb88875b5..06c5dcf2ae0 100644 --- a/docs/developer-guide/internals/execution.md +++ b/docs/developer-guide/internals/execution.md @@ -319,6 +319,28 @@ Rules of thumb: - Treat `execute` as the fallback. If no reduce rule or parent kernel applies, the encoding decodes itself and uses `ExecuteChild` to request child execution when needed. +## In-Place Mutation via Owned Arrays and Buffers + +Vortex execution passes arrays by owned `ArrayRef` (`Arc`) wherever possible. +When the `Arc` reference count is 1, the executor can mutate the array and its buffers in place, +avoiding unnecessary allocations and copies. This is a key performance optimization that threads +through two levels of the stack: **arrays** and **buffers**. + +At the array level, `take_slot` and `put_slot` use `Arc::get_mut` to check for unique +ownership. When the refcount is 1, the slot is modified in place without cloning the parent. +At the buffer level, `Buffer::try_into_mut` converts an immutable `Buffer` into a +`BufferMut` without copying when the underlying allocation has a single reference. Kernels +use this to write results directly into their input buffers. + +The execution loop is structured so that this works naturally. When the scheduler pushes a +parent onto the work stack via `ExecuteSlot`, it takes the child out with `take_slot` and +moves the parent onto the stack — giving it refcount 1. The child is then executed +independently. Crucially, leaf arrays (the ones that actually touch buffers) are produced +fresh by decode steps — they are new allocations with no other references. As results propagate +back up the stack, each `put_slot` finds its parent with refcount 1 (it was owned on the +stack), and each buffer produced by a leaf kernel has refcount 1 (it was just created). So +the in-place mutation path is hit at every level by construction, not by accident. + ## Future Work The execution model is designed to support additional function types beyond scalar functions: diff --git a/encodings/alp/public-api.lock b/encodings/alp/public-api.lock index 78a049ce12a..66e4ad9994f 100644 --- a/encodings/alp/public-api.lock +++ b/encodings/alp/public-api.lock @@ -92,12 +92,12 @@ pub fn vortex_alp::ALP::slot_name(_array: &vortex_alp::ALPArray, idx: usize) -> pub fn vortex_alp::ALP::slots(array: &vortex_alp::ALPArray) -> &[core::option::Option] +pub fn vortex_alp::ALP::slots_mut(array: &mut vortex_alp::ALPArray) -> &mut [core::option::Option] + pub fn vortex_alp::ALP::stats(array: &vortex_alp::ALPArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_alp::ALP::vtable(_array: &Self::Array) -> &Self -pub fn vortex_alp::ALP::with_slots(array: &mut vortex_alp::ALPArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_alp::ALP pub fn vortex_alp::ALP::scalar_at(array: &vortex_alp::ALPArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult @@ -252,12 +252,12 @@ pub fn vortex_alp::ALPRD::slot_name(_array: &vortex_alp::ALPRDArray, idx: usize) pub fn vortex_alp::ALPRD::slots(array: &vortex_alp::ALPRDArray) -> &[core::option::Option] +pub fn vortex_alp::ALPRD::slots_mut(array: &mut vortex_alp::ALPRDArray) -> &mut [core::option::Option] + pub fn vortex_alp::ALPRD::stats(array: &vortex_alp::ALPRDArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_alp::ALPRD::vtable(_array: &Self::Array) -> &Self -pub fn vortex_alp::ALPRD::with_slots(array: &mut vortex_alp::ALPRDArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_alp::ALPRD pub fn vortex_alp::ALPRD::scalar_at(array: &vortex_alp::ALPRDArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/alp/src/alp/array.rs b/encodings/alp/src/alp/array.rs index eb71ebbd6a1..0dc8fd4b22d 100644 --- a/encodings/alp/src/alp/array.rs +++ b/encodings/alp/src/alp/array.rs @@ -109,22 +109,8 @@ impl VTable for ALP { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut ALPArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ALPArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - - // If patch slots are being cleared, clear the metadata too - if slots[PATCH_INDICES_SLOT].is_none() || slots[PATCH_VALUES_SLOT].is_none() { - array.patch_offset = None; - array.patch_offset_within_chunk = None; - } - - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut ALPArray) -> &mut [Option] { + &mut array.slots } fn metadata(array: &ALPArray) -> VortexResult { diff --git a/encodings/alp/src/alp_rd/array.rs b/encodings/alp/src/alp_rd/array.rs index 79f7ad0dcdb..ccc8076ae11 100644 --- a/encodings/alp/src/alp_rd/array.rs +++ b/encodings/alp/src/alp_rd/array.rs @@ -41,7 +41,6 @@ use vortex_buffer::Buffer; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -99,7 +98,7 @@ impl VTable for ALPRD { array.left_parts_dictionary.array_hash(state, precision); array.right_parts().array_hash(state, precision); array.right_bit_width.hash(state); - array.left_parts_patches.array_hash(state, precision); + array.left_parts_patches().array_hash(state, precision); } fn array_eq(array: &ALPRDArray, other: &ALPRDArray, precision: Precision) -> bool { @@ -111,8 +110,8 @@ impl VTable for ALPRD { && array.right_parts().array_eq(other.right_parts(), precision) && array.right_bit_width == other.right_bit_width && array - .left_parts_patches - .array_eq(&other.left_parts_patches, precision) + .left_parts_patches() + .array_eq(&other.left_parts_patches(), precision) } fn nbuffers(_array: &ALPRDArray) -> usize { @@ -239,34 +238,8 @@ impl VTable for ALPRD { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut ALPRDArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ALPRDArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - - // Reconstruct patches from slots + existing metadata - array.left_parts_patches = - match (&slots[LP_PATCH_INDICES_SLOT], &slots[LP_PATCH_VALUES_SLOT]) { - (Some(indices), Some(values)) => { - let old = array - .left_parts_patches - .as_ref() - .vortex_expect("ALPRDArray had patch slots but no patches metadata"); - Some(Patches::new( - old.array_len(), - old.offset(), - indices.clone(), - values.clone(), - slots[LP_PATCH_CHUNK_OFFSETS_SLOT].clone(), - )?) - } - _ => None, - }; - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut ALPRDArray) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { @@ -374,7 +347,8 @@ pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = [ pub struct ALPRDArray { dtype: DType, slots: Vec>, - left_parts_patches: Option, + patch_offset: Option, + patch_offset_within_chunk: Option, left_parts_dictionary: Buffer, right_bit_width: u8, stats_set: ArrayStats, @@ -452,13 +426,18 @@ impl ALPRDArray { .transpose()?; let slots = Self::make_slots(&left_parts, &right_parts, &left_parts_patches); + let (patch_offset, patch_offset_within_chunk) = match &left_parts_patches { + Some(p) => (Some(p.offset()), p.offset_within_chunk()), + None => (None, None), + }; Ok(Self { dtype, slots, + patch_offset, + patch_offset_within_chunk, left_parts_dictionary, right_bit_width, - left_parts_patches, stats_set: Default::default(), }) } @@ -474,11 +453,16 @@ impl ALPRDArray { left_parts_patches: Option, ) -> Self { let slots = Self::make_slots(&left_parts, &right_parts, &left_parts_patches); + let (patch_offset, patch_offset_within_chunk) = match &left_parts_patches { + Some(p) => (Some(p.offset()), p.offset_within_chunk()), + None => (None, None), + }; Self { dtype, slots, - left_parts_patches, + patch_offset, + patch_offset_within_chunk, left_parts_dictionary, right_bit_width, stats_set: Default::default(), @@ -509,6 +493,7 @@ impl ALPRDArray { /// Return all the owned parts of the array pub fn into_parts(mut self) -> ALPRDArrayParts { + let left_parts_patches = self.left_parts_patches(); let left_parts = self.slots[LEFT_PARTS_SLOT] .take() .vortex_expect("ALPRDArray left_parts slot"); @@ -518,7 +503,7 @@ impl ALPRDArray { ALPRDArrayParts { dtype: self.dtype, left_parts, - left_parts_patches: self.left_parts_patches, + left_parts_patches, left_parts_dictionary: self.left_parts_dictionary, right_parts, } @@ -556,7 +541,27 @@ impl ALPRDArray { /// Patches of left-most bits. pub fn left_parts_patches(&self) -> Option { - self.left_parts_patches.clone() + match ( + &self.slots[LP_PATCH_INDICES_SLOT], + &self.slots[LP_PATCH_VALUES_SLOT], + ) { + (Some(indices), Some(values)) => { + let patch_offset = self + .patch_offset + .vortex_expect("has patch slots but no patch_offset"); + Some(unsafe { + Patches::new_unchecked( + self.left_parts().len(), + patch_offset, + indices.clone(), + values.clone(), + self.slots[LP_PATCH_CHUNK_OFFSETS_SLOT].clone(), + self.patch_offset_within_chunk, + ) + }) + } + _ => None, + } } /// The dictionary that maps the codes in `left_parts` into bit patterns. @@ -566,19 +571,21 @@ impl ALPRDArray { } pub fn replace_left_parts_patches(&mut self, patches: Option) { - // Update both the patches and the corresponding slots to keep them in sync. - let (pi, pv, pco) = match &patches { + let (pi, pv, pco, patch_offset, patch_offset_within_chunk) = match &patches { Some(p) => ( Some(p.indices().clone()), Some(p.values().clone()), p.chunk_offsets().clone(), + Some(p.offset()), + p.offset_within_chunk(), ), - None => (None, None, None), + None => (None, None, None, None, None), }; self.slots[LP_PATCH_INDICES_SLOT] = pi; self.slots[LP_PATCH_VALUES_SLOT] = pv; self.slots[LP_PATCH_CHUNK_OFFSETS_SLOT] = pco; - self.left_parts_patches = patches; + self.patch_offset = patch_offset; + self.patch_offset_within_chunk = patch_offset_within_chunk; } } diff --git a/encodings/bytebool/public-api.lock b/encodings/bytebool/public-api.lock index dc9c43f62b8..b020a01334c 100644 --- a/encodings/bytebool/public-api.lock +++ b/encodings/bytebool/public-api.lock @@ -38,7 +38,7 @@ pub type vortex_bytebool::ByteBool::Metadata = vortex_array::metadata::EmptyMeta pub type vortex_bytebool::ByteBool::OperationsVTable = vortex_bytebool::ByteBool -pub type vortex_bytebool::ByteBool::ValidityVTable = vortex_array::vtable::validity::ValidityVTableFromValidityHelper +pub type vortex_bytebool::ByteBool::ValidityVTable = vortex_bytebool::ByteBool pub fn vortex_bytebool::ByteBool::array_eq(array: &vortex_bytebool::ByteBoolArray, other: &vortex_bytebool::ByteBoolArray, precision: vortex_array::hash::Precision) -> bool @@ -74,16 +74,20 @@ pub fn vortex_bytebool::ByteBool::slot_name(_array: &vortex_bytebool::ByteBoolAr pub fn vortex_bytebool::ByteBool::slots(array: &vortex_bytebool::ByteBoolArray) -> &[core::option::Option] +pub fn vortex_bytebool::ByteBool::slots_mut(array: &mut vortex_bytebool::ByteBoolArray) -> &mut [core::option::Option] + pub fn vortex_bytebool::ByteBool::stats(array: &vortex_bytebool::ByteBoolArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_bytebool::ByteBool::vtable(_array: &Self::Array) -> &Self -pub fn vortex_bytebool::ByteBool::with_slots(array: &mut vortex_bytebool::ByteBoolArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_bytebool::ByteBool pub fn vortex_bytebool::ByteBool::scalar_at(array: &vortex_bytebool::ByteBoolArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult +impl vortex_array::vtable::validity::ValidityVTable for vortex_bytebool::ByteBool + +pub fn vortex_bytebool::ByteBool::validity(array: &vortex_bytebool::ByteBoolArray) -> vortex_error::VortexResult + pub struct vortex_bytebool::ByteBoolArray impl vortex_bytebool::ByteBoolArray @@ -133,7 +137,3 @@ pub fn vortex_bytebool::ByteBoolArray::deref(&self) -> &Self::Target impl vortex_array::array::IntoArray for vortex_bytebool::ByteBoolArray pub fn vortex_bytebool::ByteBoolArray::into_array(self) -> vortex_array::array::ArrayRef - -impl vortex_array::vtable::validity::ValidityHelper for vortex_bytebool::ByteBoolArray - -pub fn vortex_bytebool::ByteBoolArray::validity(&self) -> vortex_array::validity::Validity diff --git a/encodings/bytebool/src/array.rs b/encodings/bytebool/src/array.rs index dd59ac06e93..5efa54d8f42 100644 --- a/encodings/bytebool/src/array.rs +++ b/encodings/bytebool/src/array.rs @@ -26,14 +26,13 @@ use vortex_array::vtable::Array; use vortex_array::vtable::ArrayId; use vortex_array::vtable::OperationsVTable; use vortex_array::vtable::VTable; -use vortex_array::vtable::ValidityHelper; -use vortex_array::vtable::ValidityVTableFromValidityHelper; +use vortex_array::vtable::ValidityVTable; +use vortex_array::vtable::child_to_validity; use vortex_array::vtable::validity_to_child; use vortex_buffer::BitBuffer; use vortex_buffer::ByteBuffer; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -46,7 +45,7 @@ impl VTable for ByteBool { type Metadata = EmptyMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromValidityHelper; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &ByteBool @@ -75,13 +74,13 @@ impl VTable for ByteBool { ) { array.dtype.hash(state); array.buffer.array_hash(state, precision); - array.validity.array_hash(state, precision); + array._validity().array_hash(state, precision); } fn array_eq(array: &ByteBoolArray, other: &ByteBoolArray, precision: Precision) -> bool { array.dtype == other.dtype && array.buffer.array_eq(&other.buffer, precision) - && array.validity.array_eq(&other.validity, precision) + && array._validity().array_eq(&other._validity(), precision) } fn nbuffers(_array: &ByteBoolArray) -> usize { @@ -152,19 +151,8 @@ impl VTable for ByteBool { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut ByteBoolArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ByteBoolArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.validity = match &slots[VALIDITY_SLOT] { - Some(arr) => Validity::Array(arr.clone()), - None => Validity::from(array.dtype.nullability()), - }; - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut ByteBoolArray) -> &mut [Option] { + &mut array.slots } fn reduce_parent( @@ -177,7 +165,7 @@ impl VTable for ByteBool { fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { let boolean_buffer = BitBuffer::from(array.as_slice()); - let validity = array.validity(); + let validity = array.validity()?; Ok(ExecutionResult::done( BoolArray::new(boolean_buffer, validity).into_array(), )) @@ -202,7 +190,6 @@ pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = ["validity"]; pub struct ByteBoolArray { dtype: DType, buffer: BufferHandle, - validity: Validity, pub(super) slots: Vec>, stats_set: ArrayStats, } @@ -230,11 +217,11 @@ impl ByteBoolArray { vlen ); } + let dtype = DType::Bool(validity.nullability()); let slots = Self::make_slots(&validity, length); Self { - dtype: DType::Bool(validity.nullability()), + dtype, buffer, - validity, slots, stats_set: Default::default(), } @@ -256,11 +243,16 @@ impl ByteBoolArray { // Safety: The internal buffer contains byte-sized bools unsafe { std::mem::transmute(self.buffer().as_host().as_slice()) } } + + /// Returns the validity derived from the validity slot. + pub(crate) fn _validity(&self) -> Validity { + child_to_validity(&self.slots[VALIDITY_SLOT], self.dtype.nullability()) + } } -impl ValidityHelper for ByteBoolArray { - fn validity(&self) -> Validity { - self.validity.clone() +impl ValidityVTable for ByteBool { + fn validity(array: &ByteBoolArray) -> VortexResult { + Ok(array._validity()) } } diff --git a/encodings/bytebool/src/compute.rs b/encodings/bytebool/src/compute.rs index ac7e6a23b61..e9e99566cd1 100644 --- a/encodings/bytebool/src/compute.rs +++ b/encodings/bytebool/src/compute.rs @@ -12,7 +12,6 @@ use vortex_array::match_each_integer_ptype; use vortex_array::scalar_fn::fns::cast::CastReduce; use vortex_array::scalar_fn::fns::mask::MaskReduce; use vortex_array::validity::Validity; -use vortex_array::vtable::ValidityHelper; use vortex_error::VortexResult; use super::ByteBool; @@ -27,7 +26,7 @@ impl CastReduce for ByteBool { // If just changing nullability, we can optimize if array.dtype().eq_ignore_nullability(dtype) { let new_validity = array - .validity() + ._validity() .cast_nullability(dtype.nullability(), array.len())?; return Ok(Some( @@ -45,7 +44,7 @@ impl MaskReduce for ByteBool { Ok(Some( ByteBoolArray::new( array.buffer().clone(), - array.validity().and(Validity::Array(mask.clone()))?, + array._validity().and(Validity::Array(mask.clone()))?, ) .into_array(), )) @@ -62,7 +61,7 @@ impl TakeExecute for ByteBool { let bools = array.as_slice(); // This handles combining validity from both source array and nullable indices - let validity = array.validity().take(&indices.clone().into_array())?; + let validity = array._validity().take(&indices.clone().into_array())?; let taken_bools = match_each_integer_ptype!(indices.ptype(), |I| { indices diff --git a/encodings/bytebool/src/slice.rs b/encodings/bytebool/src/slice.rs index c80be024fd1..16a5a027828 100644 --- a/encodings/bytebool/src/slice.rs +++ b/encodings/bytebool/src/slice.rs @@ -6,7 +6,6 @@ use std::ops::Range; use vortex_array::ArrayRef; use vortex_array::IntoArray; use vortex_array::arrays::slice::SliceReduce; -use vortex_array::vtable::ValidityHelper; use vortex_error::VortexResult; use crate::ByteBool; @@ -17,7 +16,7 @@ impl SliceReduce for ByteBool { Ok(Some( ByteBoolArray::new( array.buffer().slice(range.clone()), - array.validity().slice(range)?, + array._validity().slice(range)?, ) .into_array(), )) diff --git a/encodings/datetime-parts/public-api.lock b/encodings/datetime-parts/public-api.lock index 3c02c1f94a4..f65a057074c 100644 --- a/encodings/datetime-parts/public-api.lock +++ b/encodings/datetime-parts/public-api.lock @@ -82,12 +82,12 @@ pub fn vortex_datetime_parts::DateTimeParts::slot_name(_array: &vortex_datetime_ pub fn vortex_datetime_parts::DateTimeParts::slots(array: &vortex_datetime_parts::DateTimePartsArray) -> &[core::option::Option] +pub fn vortex_datetime_parts::DateTimeParts::slots_mut(array: &mut vortex_datetime_parts::DateTimePartsArray) -> &mut [core::option::Option] + pub fn vortex_datetime_parts::DateTimeParts::stats(array: &vortex_datetime_parts::DateTimePartsArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_datetime_parts::DateTimeParts::vtable(_array: &Self::Array) -> &Self -pub fn vortex_datetime_parts::DateTimeParts::with_slots(array: &mut vortex_datetime_parts::DateTimePartsArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_datetime_parts::DateTimeParts pub fn vortex_datetime_parts::DateTimeParts::scalar_at(array: &vortex_datetime_parts::DateTimePartsArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/datetime-parts/src/array.rs b/encodings/datetime-parts/src/array.rs index 3607c9abc07..6839c6273cf 100644 --- a/encodings/datetime-parts/src/array.rs +++ b/encodings/datetime-parts/src/array.rs @@ -32,7 +32,6 @@ use vortex_array::vtable::ValidityVTableFromChild; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -199,18 +198,8 @@ impl VTable for DateTimeParts { SLOT_NAMES[idx].to_string() } - fn with_slots( - array: &mut DateTimePartsArray, - slots: Vec>, - ) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "DateTimePartsArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut DateTimePartsArray) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/encodings/decimal-byte-parts/public-api.lock b/encodings/decimal-byte-parts/public-api.lock index 916f5349962..cd05fba535e 100644 --- a/encodings/decimal-byte-parts/public-api.lock +++ b/encodings/decimal-byte-parts/public-api.lock @@ -82,12 +82,12 @@ pub fn vortex_decimal_byte_parts::DecimalByteParts::slot_name(_array: &vortex_de pub fn vortex_decimal_byte_parts::DecimalByteParts::slots(array: &vortex_decimal_byte_parts::DecimalBytePartsArray) -> &[core::option::Option] +pub fn vortex_decimal_byte_parts::DecimalByteParts::slots_mut(array: &mut vortex_decimal_byte_parts::DecimalBytePartsArray) -> &mut [core::option::Option] + pub fn vortex_decimal_byte_parts::DecimalByteParts::stats(array: &vortex_decimal_byte_parts::DecimalBytePartsArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_decimal_byte_parts::DecimalByteParts::vtable(_array: &Self::Array) -> &Self -pub fn vortex_decimal_byte_parts::DecimalByteParts::with_slots(array: &mut vortex_decimal_byte_parts::DecimalBytePartsArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_decimal_byte_parts::DecimalByteParts pub fn vortex_decimal_byte_parts::DecimalByteParts::scalar_at(array: &vortex_decimal_byte_parts::DecimalBytePartsArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs b/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs index 7df75061673..731cd67fdc0 100644 --- a/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs +++ b/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs @@ -42,7 +42,6 @@ use vortex_array::vtable::ValidityVTableFromChild; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -167,18 +166,8 @@ impl VTable for DecimalByteParts { SLOT_NAMES[idx].to_string() } - fn with_slots( - array: &mut DecimalBytePartsArray, - slots: Vec>, - ) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "DecimalBytePartsArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut DecimalBytePartsArray) -> &mut [Option] { + &mut array.slots } fn reduce_parent( diff --git a/encodings/fastlanes/public-api.lock b/encodings/fastlanes/public-api.lock index e6638186cfd..cd7a040676a 100644 --- a/encodings/fastlanes/public-api.lock +++ b/encodings/fastlanes/public-api.lock @@ -192,12 +192,12 @@ pub fn vortex_fastlanes::BitPacked::slot_name(_array: &vortex_fastlanes::BitPack pub fn vortex_fastlanes::BitPacked::slots(array: &vortex_fastlanes::BitPackedArray) -> &[core::option::Option] +pub fn vortex_fastlanes::BitPacked::slots_mut(array: &mut vortex_fastlanes::BitPackedArray) -> &mut [core::option::Option] + pub fn vortex_fastlanes::BitPacked::stats(array: &vortex_fastlanes::BitPackedArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_fastlanes::BitPacked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_fastlanes::BitPacked::with_slots(array: &mut vortex_fastlanes::BitPackedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_fastlanes::BitPacked pub fn vortex_fastlanes::BitPacked::scalar_at(array: &vortex_fastlanes::BitPackedArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult @@ -344,12 +344,12 @@ pub fn vortex_fastlanes::Delta::slot_name(_array: &vortex_fastlanes::DeltaArray, pub fn vortex_fastlanes::Delta::slots(array: &vortex_fastlanes::DeltaArray) -> &[core::option::Option] +pub fn vortex_fastlanes::Delta::slots_mut(array: &mut vortex_fastlanes::DeltaArray) -> &mut [core::option::Option] + pub fn vortex_fastlanes::Delta::stats(array: &vortex_fastlanes::DeltaArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_fastlanes::Delta::vtable(_array: &Self::Array) -> &Self -pub fn vortex_fastlanes::Delta::with_slots(array: &mut vortex_fastlanes::DeltaArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_fastlanes::Delta pub fn vortex_fastlanes::Delta::scalar_at(array: &vortex_fastlanes::DeltaArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult @@ -486,12 +486,12 @@ pub fn vortex_fastlanes::FoR::slot_name(_array: &vortex_fastlanes::FoRArray, idx pub fn vortex_fastlanes::FoR::slots(array: &vortex_fastlanes::FoRArray) -> &[core::option::Option] +pub fn vortex_fastlanes::FoR::slots_mut(array: &mut vortex_fastlanes::FoRArray) -> &mut [core::option::Option] + pub fn vortex_fastlanes::FoR::stats(array: &vortex_fastlanes::FoRArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_fastlanes::FoR::vtable(_array: &Self::Array) -> &Self -pub fn vortex_fastlanes::FoR::with_slots(array: &mut vortex_fastlanes::FoRArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_fastlanes::FoR pub fn vortex_fastlanes::FoR::scalar_at(array: &vortex_fastlanes::FoRArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult @@ -612,12 +612,12 @@ pub fn vortex_fastlanes::RLE::slot_name(_array: &vortex_fastlanes::RLEArray, idx pub fn vortex_fastlanes::RLE::slots(array: &vortex_fastlanes::RLEArray) -> &[core::option::Option] +pub fn vortex_fastlanes::RLE::slots_mut(array: &mut vortex_fastlanes::RLEArray) -> &mut [core::option::Option] + pub fn vortex_fastlanes::RLE::stats(array: &vortex_fastlanes::RLEArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_fastlanes::RLE::vtable(_array: &Self::Array) -> &Self -pub fn vortex_fastlanes::RLE::with_slots(array: &mut vortex_fastlanes::RLEArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_fastlanes::RLE pub fn vortex_fastlanes::RLE::scalar_at(array: &vortex_fastlanes::RLEArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/fastlanes/src/bitpacking/vtable/mod.rs b/encodings/fastlanes/src/bitpacking/vtable/mod.rs index 6e096f84223..e78a9dba8b1 100644 --- a/encodings/fastlanes/src/bitpacking/vtable/mod.rs +++ b/encodings/fastlanes/src/bitpacking/vtable/mod.rs @@ -34,7 +34,6 @@ use vortex_array::vtable::VTable; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -42,7 +41,6 @@ use vortex_session::VortexSession; use crate::BitPackedArray; use crate::bitpack_decompress::unpack_array; use crate::bitpack_decompress::unpack_into_primitive_builder; -use crate::bitpacking::array::NUM_SLOTS; use crate::bitpacking::array::PATCH_CHUNK_OFFSETS_SLOT; use crate::bitpacking::array::PATCH_INDICES_SLOT; use crate::bitpacking::array::PATCH_VALUES_SLOT; @@ -153,22 +151,8 @@ impl VTable for BitPacked { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut BitPackedArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "BitPackedArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - - // If patch slots are being cleared, clear the metadata too - if slots[PATCH_INDICES_SLOT].is_none() || slots[PATCH_VALUES_SLOT].is_none() { - array.patch_offset = None; - array.patch_offset_within_chunk = None; - } - - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut BitPackedArray) -> &mut [Option] { + &mut array.slots } fn metadata(array: &BitPackedArray) -> VortexResult { diff --git a/encodings/fastlanes/src/delta/vtable/mod.rs b/encodings/fastlanes/src/delta/vtable/mod.rs index 9626d59b282..1c8dc8dbde0 100644 --- a/encodings/fastlanes/src/delta/vtable/mod.rs +++ b/encodings/fastlanes/src/delta/vtable/mod.rs @@ -25,13 +25,11 @@ use vortex_array::vtable::Array; use vortex_array::vtable::ArrayId; use vortex_array::vtable::VTable; use vortex_error::VortexResult; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; use crate::DeltaArray; -use crate::delta::array::NUM_SLOTS; use crate::delta::array::SLOT_NAMES; use crate::delta::array::delta_decompress::delta_decompress; @@ -123,15 +121,8 @@ impl VTable for Delta { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut DeltaArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "DeltaArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut DeltaArray) -> &mut [Option] { + &mut array.slots } fn metadata(array: &DeltaArray) -> VortexResult { diff --git a/encodings/fastlanes/src/for/vtable/mod.rs b/encodings/fastlanes/src/for/vtable/mod.rs index 59189042046..3364be61086 100644 --- a/encodings/fastlanes/src/for/vtable/mod.rs +++ b/encodings/fastlanes/src/for/vtable/mod.rs @@ -25,12 +25,10 @@ use vortex_array::vtable::VTable; use vortex_array::vtable::ValidityVTableFromChild; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; use crate::FoRArray; -use crate::r#for::array::NUM_SLOTS; use crate::r#for::array::SLOT_NAMES; use crate::r#for::array::for_decompress::decompress; use crate::r#for::vtable::kernels::PARENT_KERNELS; @@ -102,15 +100,8 @@ impl VTable for FoR { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut FoRArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "FoRArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut FoRArray) -> &mut [Option] { + &mut array.slots } fn metadata(array: &FoRArray) -> VortexResult { diff --git a/encodings/fastlanes/src/rle/vtable/mod.rs b/encodings/fastlanes/src/rle/vtable/mod.rs index 12c83dcab48..546ac914dae 100644 --- a/encodings/fastlanes/src/rle/vtable/mod.rs +++ b/encodings/fastlanes/src/rle/vtable/mod.rs @@ -25,7 +25,6 @@ use vortex_array::vtable::ArrayId; use vortex_array::vtable::VTable; use vortex_array::vtable::ValidityVTableFromChildSliceHelper; use vortex_error::VortexResult; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -132,15 +131,8 @@ impl VTable for RLE { crate::rle::array::SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut RLEArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == crate::rle::array::NUM_SLOTS, - "RLEArray expects {} slots, got {}", - crate::rle::array::NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut RLEArray) -> &mut [Option] { + &mut array.slots } fn metadata(array: &RLEArray) -> VortexResult { diff --git a/encodings/fsst/public-api.lock b/encodings/fsst/public-api.lock index cfbbb51e0d6..d6d55d182cb 100644 --- a/encodings/fsst/public-api.lock +++ b/encodings/fsst/public-api.lock @@ -46,7 +46,7 @@ pub type vortex_fsst::FSST::Metadata = vortex_array::metadata::ProstMetadata vortex_error::VortexResult<()> @@ -84,27 +84,27 @@ pub fn vortex_fsst::FSST::slot_name(_array: &vortex_fsst::FSSTArray, idx: usize) pub fn vortex_fsst::FSST::slots(array: &vortex_fsst::FSSTArray) -> &[core::option::Option] +pub fn vortex_fsst::FSST::slots_mut(array: &mut vortex_fsst::FSSTArray) -> &mut [core::option::Option] + pub fn vortex_fsst::FSST::stats(array: &vortex_fsst::FSSTArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_fsst::FSST::vtable(_array: &Self::Array) -> &Self -pub fn vortex_fsst::FSST::with_slots(array: &mut vortex_fsst::FSSTArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_fsst::FSST pub fn vortex_fsst::FSST::scalar_at(array: &vortex_fsst::FSSTArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult -impl vortex_array::vtable::validity::ValidityChild for vortex_fsst::FSST +impl vortex_array::vtable::validity::ValidityVTable for vortex_fsst::FSST -pub fn vortex_fsst::FSST::validity_child(array: &vortex_fsst::FSSTArray) -> &vortex_array::array::ArrayRef +pub fn vortex_fsst::FSST::validity(array: &vortex_fsst::FSSTArray) -> vortex_error::VortexResult pub struct vortex_fsst::FSSTArray impl vortex_fsst::FSSTArray -pub fn vortex_fsst::FSSTArray::codes(&self) -> &vortex_array::arrays::varbin::array::VarBinArray +pub fn vortex_fsst::FSSTArray::codes(&self) -> vortex_array::arrays::varbin::array::VarBinArray -pub fn vortex_fsst::FSSTArray::codes_dtype(&self) -> &vortex_array::dtype::DType +pub fn vortex_fsst::FSSTArray::codes_dtype(&self) -> vortex_array::dtype::DType pub fn vortex_fsst::FSSTArray::compressor(&self) -> &fsst::Compressor diff --git a/encodings/fsst/src/array.rs b/encodings/fsst/src/array.rs index c716ebc68d2..e4cb4dce09a 100644 --- a/encodings/fsst/src/array.rs +++ b/encodings/fsst/src/array.rs @@ -38,15 +38,14 @@ use vortex_array::vtable; use vortex_array::vtable::Array; use vortex_array::vtable::ArrayId; use vortex_array::vtable::VTable; -use vortex_array::vtable::ValidityChild; -use vortex_array::vtable::ValidityVTableFromChild; +use vortex_array::vtable::ValidityVTable; +use vortex_array::vtable::child_to_validity; use vortex_array::vtable::validity_to_child; use vortex_buffer::Buffer; use vortex_buffer::ByteBuffer; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -79,7 +78,7 @@ impl VTable for FSST { type Metadata = ProstMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromChild; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &FSST @@ -105,7 +104,7 @@ impl VTable for FSST { array.dtype.hash(state); array.symbols.array_hash(state, precision); array.symbol_lengths.array_hash(state, precision); - array.codes.as_ref().array_hash(state, precision); + array.codes().as_ref().array_hash(state, precision); array.uncompressed_lengths().array_hash(state, precision); } @@ -116,9 +115,9 @@ impl VTable for FSST { .symbol_lengths .array_eq(&other.symbol_lengths, precision) && array - .codes + .codes() .as_ref() - .array_eq(other.codes.as_ref(), precision) + .array_eq(other.codes().as_ref(), precision) && array .uncompressed_lengths() .array_eq(other.uncompressed_lengths(), precision) @@ -132,7 +131,7 @@ impl VTable for FSST { match idx { 0 => BufferHandle::new_host(array.symbols().clone().into_byte_buffer()), 1 => BufferHandle::new_host(array.symbol_lengths().clone().into_byte_buffer()), - 2 => array.codes.bytes_handle().clone(), + 2 => array.codes_bytes.clone(), _ => vortex_panic!("FSSTArray buffer index {idx} out of bounds"), } } @@ -149,7 +148,7 @@ impl VTable for FSST { fn metadata(array: &FSSTArray) -> VortexResult { Ok(ProstMetadata(FSSTMetadata { uncompressed_lengths_ptype: array.uncompressed_lengths().dtype().as_ptype().into(), - codes_offsets_ptype: array.codes.offsets().dtype().as_ptype().into(), + codes_offsets_ptype: array.codes().offsets().dtype().as_ptype().into(), })) } @@ -297,31 +296,8 @@ impl VTable for FSST { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut FSSTArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "FSSTArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - - // Reconstruct codes VarBinArray from new offsets + existing bytes + new validity - let codes_offsets = slots[CODES_OFFSETS_SLOT] - .clone() - .vortex_expect("FSSTArray requires codes_offsets slot"); - let codes_validity = match &slots[CODES_VALIDITY_SLOT] { - Some(arr) => Validity::Array(arr.clone()), - None => Validity::from(array.codes.dtype().nullability()), - }; - array.codes = VarBinArray::try_new_from_handle( - codes_offsets, - array.codes.bytes_handle().clone(), - array.codes.dtype().clone(), - codes_validity, - )?; - array.codes_array = array.codes.clone().into_array(); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut FSSTArray) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { @@ -361,9 +337,7 @@ pub struct FSSTArray { dtype: DType, symbols: Buffer, symbol_lengths: Buffer, - codes: VarBinArray, - /// NOTE(ngates): this === codes, but is stored as an ArrayRef so we can return &ArrayRef! - codes_array: ArrayRef, + codes_bytes: BufferHandle, /// Lengths of the original values before compression, can be compressed. slots: Vec>, stats_set: ArrayStats, @@ -378,7 +352,6 @@ impl Debug for FSSTArray { .field("dtype", &self.dtype) .field("symbols", &self.symbols) .field("symbol_lengths", &self.symbol_lengths) - .field("codes", &self.codes) .field("uncompressed_lengths", self.uncompressed_lengths()) .finish() } @@ -453,7 +426,7 @@ impl FSSTArray { Compressor::rebuild_from(symbols2.as_slice(), symbol_lengths2.as_slice()) }) as Box Compressor + Send>)); - let codes_array = codes.clone().into_array(); + let codes_bytes = codes.bytes_handle().clone(); let codes_offsets_slot = Some(codes.offsets().clone()); let codes_validity_slot = validity_to_child(&codes.validity(), codes.len()); @@ -461,8 +434,7 @@ impl FSSTArray { dtype, symbols, symbol_lengths, - codes, - codes_array, + codes_bytes, slots: vec![ Some(uncompressed_lengths), codes_offsets_slot, @@ -483,15 +455,30 @@ impl FSSTArray { &self.symbol_lengths } - /// Access the codes array - pub fn codes(&self) -> &VarBinArray { - &self.codes + /// Access the codes array, reconstructed on demand from stored components. + pub fn codes(&self) -> VarBinArray { + let offsets = self.slots[CODES_OFFSETS_SLOT] + .clone() + .vortex_expect("FSSTArray codes_offsets slot must be present"); + let validity = + child_to_validity(&self.slots[CODES_VALIDITY_SLOT], self.dtype.nullability()); + // SAFETY: components were validated at FSSTArray construction time and bytes are + // immutable; only offsets/validity slots can change, but the executor preserves + // their invariants. + unsafe { + VarBinArray::new_unchecked_from_handle( + offsets, + self.codes_bytes.clone(), + DType::Binary(self.dtype.nullability()), + validity, + ) + } } /// Get the DType of the codes array #[inline] - pub fn codes_dtype(&self) -> &DType { - self.codes.dtype() + pub fn codes_dtype(&self) -> DType { + DType::Binary(self.dtype.nullability()) } /// Get the uncompressed length for each element in the array. @@ -519,9 +506,12 @@ impl FSSTArray { } } -impl ValidityChild for FSST { - fn validity_child(array: &FSSTArray) -> &ArrayRef { - &array.codes_array +impl ValidityVTable for FSST { + fn validity(array: &FSSTArray) -> VortexResult { + Ok(child_to_validity( + &array.slots[CODES_VALIDITY_SLOT], + array.dtype.nullability(), + )) } } @@ -584,7 +574,7 @@ mod test { &compressor, ); - let compressed_codes = fsst_array.codes().clone(); + let compressed_codes = fsst_array.codes(); // There were two buffers: // 1. The 8 byte symbols diff --git a/encodings/fsst/src/compute/cast.rs b/encodings/fsst/src/compute/cast.rs index e21934665c6..3535c3bfe4e 100644 --- a/encodings/fsst/src/compute/cast.rs +++ b/encodings/fsst/src/compute/cast.rs @@ -18,11 +18,10 @@ impl CastReduce for FSST { // For nullability changes, we can cast the codes and symbols arrays if array.dtype().eq_ignore_nullability(dtype) { // Cast codes array to handle nullability - let new_codes = array - .codes() - .clone() + let codes = array.codes(); + let new_codes = codes .into_array() - .cast(array.codes().dtype().with_nullability(dtype.nullability()))?; + .cast(array.codes_dtype().with_nullability(dtype.nullability()))?; Ok(Some( FSSTArray::try_new( diff --git a/encodings/fsst/src/compute/compare.rs b/encodings/fsst/src/compute/compare.rs index e6efbd075ed..0cbdfc89f75 100644 --- a/encodings/fsst/src/compute/compare.rs +++ b/encodings/fsst/src/compute/compare.rs @@ -116,7 +116,6 @@ fn compare_fsst_constant( let rhs = ConstantArray::new(encoded_scalar, left.len()); left.codes() - .clone() .into_array() .binary(rhs.into_array(), Operator::from(operator)) .map(Some) diff --git a/encodings/fsst/src/compute/filter.rs b/encodings/fsst/src/compute/filter.rs index b06f442addb..174aba776ec 100644 --- a/encodings/fsst/src/compute/filter.rs +++ b/encodings/fsst/src/compute/filter.rs @@ -20,7 +20,7 @@ impl FilterKernel for FSST { ctx: &mut ExecutionCtx, ) -> VortexResult> { // Directly invoke VarBin's FilterKernel to get a concrete VarBinArray back. - let filtered_codes = ::filter(array.codes(), mask, ctx)? + let filtered_codes = ::filter(&array.codes(), mask, ctx)? .vortex_expect("VarBin filter kernel always returns Some") .try_into::() .ok() diff --git a/encodings/fsst/src/compute/mod.rs b/encodings/fsst/src/compute/mod.rs index f49c2954a04..d8bc90ca6c0 100644 --- a/encodings/fsst/src/compute/mod.rs +++ b/encodings/fsst/src/compute/mod.rs @@ -35,7 +35,7 @@ impl TakeExecute for FSST { .union_nullability(indices.dtype().nullability()), array.symbols().clone(), array.symbol_lengths().clone(), - VarBin::take(array.codes(), indices, _ctx)? + VarBin::take(&array.codes(), indices, _ctx)? .vortex_expect("cannot fail") .try_into::() .map_err(|_| vortex_err!("take for codes must return varbin array"))?, diff --git a/encodings/parquet-variant/src/array.rs b/encodings/parquet-variant/src/array.rs index c886fddc660..547c1427348 100644 --- a/encodings/parquet-variant/src/array.rs +++ b/encodings/parquet-variant/src/array.rs @@ -17,6 +17,7 @@ use vortex_array::arrow::to_arrow_null_buffer; use vortex_array::dtype::DType; use vortex_array::stats::ArrayStats; use vortex_array::validity::Validity; +use vortex_array::vtable::child_to_validity; use vortex_array::vtable::validity_to_child; use vortex_buffer::BitBuffer; use vortex_error::VortexExpect; @@ -64,7 +65,6 @@ pub(crate) const SLOT_NAMES: [&str; NUM_SLOTS] = ["validity", "metadata", "value #[derive(Clone, Debug)] pub struct ParquetVariantArray { pub(crate) dtype: DType, - pub(crate) validity: Validity, pub(crate) slots: Vec>, pub(crate) stats_set: ArrayStats, } @@ -106,12 +106,16 @@ impl ParquetVariantArray { Ok(Self { dtype: DType::Variant(nullability), - validity, slots, stats_set: ArrayStats::default(), }) } + /// Computes validity on demand from the validity slot. + pub(crate) fn validity(&self) -> Validity { + child_to_validity(&self.slots[VALIDITY_SLOT], self.dtype.nullability()) + } + /// Returns a reference to the metadata child array. pub fn metadata_array(&self) -> &ArrayRef { self.slots[METADATA_SLOT] @@ -176,7 +180,7 @@ impl ParquetVariantArray { pub fn to_arrow(&self, ctx: &mut ExecutionCtx) -> VortexResult { let metadata = self.metadata_array(); let len = metadata.len(); - let nulls = to_arrow_null_buffer(self.validity.clone(), len, ctx)?; + let nulls = to_arrow_null_buffer(self.validity(), len, ctx)?; let mut fields = Vec::with_capacity(3); let mut arrays: Vec = Vec::with_capacity(3); diff --git a/encodings/parquet-variant/src/kernel.rs b/encodings/parquet-variant/src/kernel.rs index 08698b0f6b0..ad0e128448c 100644 --- a/encodings/parquet-variant/src/kernel.rs +++ b/encodings/parquet-variant/src/kernel.rs @@ -32,7 +32,7 @@ impl SliceKernel for ParquetVariant { range: Range, _ctx: &mut ExecutionCtx, ) -> VortexResult> { - let validity = array.validity.slice(range.clone())?; + let validity = array.validity().slice(range.clone())?; let metadata = array.metadata_array().slice(range.clone())?; let value = array .value_array() @@ -54,7 +54,7 @@ impl FilterKernel for ParquetVariant { mask: &Mask, _ctx: &mut ExecutionCtx, ) -> VortexResult> { - let validity = array.validity.filter(mask)?; + let validity = array.validity().filter(mask)?; let metadata = array.metadata_array().filter(mask.clone())?; let value = array .value_array() @@ -76,7 +76,7 @@ impl TakeExecute for ParquetVariant { indices: &ArrayRef, _ctx: &mut ExecutionCtx, ) -> VortexResult> { - let validity = array.validity.take(indices)?; + let validity = array.validity().take(indices)?; let metadata = array.metadata_array().take(indices.to_array())?; let value = array .value_array() diff --git a/encodings/parquet-variant/src/operations.rs b/encodings/parquet-variant/src/operations.rs index c11d1b370ab..d7f34b45abb 100644 --- a/encodings/parquet-variant/src/operations.rs +++ b/encodings/parquet-variant/src/operations.rs @@ -42,7 +42,7 @@ impl OperationsVTable for ParquetVariant { index: usize, _ctx: &mut ExecutionCtx, ) -> VortexResult { - if array.validity.is_null(index)? { + if array.validity().is_null(index)? { return Ok(Scalar::null(DType::Variant(Nullability::Nullable))); } diff --git a/encodings/parquet-variant/src/validity.rs b/encodings/parquet-variant/src/validity.rs index 7d163663517..31da396dd82 100644 --- a/encodings/parquet-variant/src/validity.rs +++ b/encodings/parquet-variant/src/validity.rs @@ -2,12 +2,14 @@ // SPDX-FileCopyrightText: Copyright the Vortex contributors use vortex_array::validity::Validity; -use vortex_array::vtable::ValidityHelper; +use vortex_array::vtable::ValidityVTable; +use vortex_error::VortexResult; use crate::array::ParquetVariantArray; +use crate::vtable::ParquetVariant; -impl ValidityHelper for ParquetVariantArray { - fn validity(&self) -> Validity { - self.validity.clone() +impl ValidityVTable for ParquetVariant { + fn validity(array: &ParquetVariantArray) -> VortexResult { + Ok(array.validity()) } } diff --git a/encodings/parquet-variant/src/vtable.rs b/encodings/parquet-variant/src/vtable.rs index 7023121313a..2e9bdf1c22f 100644 --- a/encodings/parquet-variant/src/vtable.rs +++ b/encodings/parquet-variant/src/vtable.rs @@ -24,7 +24,6 @@ use vortex_array::vtable; use vortex_array::vtable::Array; use vortex_array::vtable::ArrayId; use vortex_array::vtable::VTable; -use vortex_array::vtable::ValidityVTableFromValidityHelper; use vortex_error::VortexResult; use vortex_error::vortex_ensure; use vortex_error::vortex_err; @@ -32,10 +31,8 @@ use vortex_error::vortex_panic; use vortex_proto::dtype as pb; use vortex_session::VortexSession; -use crate::array::NUM_SLOTS; use crate::array::ParquetVariantArray; use crate::array::SLOT_NAMES; -use crate::array::VALIDITY_SLOT; use crate::kernel::PARENT_KERNELS; /// VTable for [`ParquetVariantArray`]. @@ -82,7 +79,7 @@ impl VTable for ParquetVariant { type Array = ParquetVariantArray; type Metadata = ParquetVariantMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromValidityHelper; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &ParquetVariant @@ -105,7 +102,7 @@ impl VTable for ParquetVariant { } fn array_hash(array: &ParquetVariantArray, state: &mut H, precision: Precision) { - array.validity.array_hash(state, precision); + array.validity().array_hash(state, precision); array.metadata_array().array_hash(state, precision); // Hash discriminators so that (value=Some, typed_value=None) and // (value=None, typed_value=Some) produce different hashes. @@ -124,7 +121,7 @@ impl VTable for ParquetVariant { other: &ParquetVariantArray, precision: Precision, ) -> bool { - if !array.validity.array_eq(&other.validity, precision) + if !array.validity().array_eq(&other.validity(), precision) || !array .metadata_array() .array_eq(other.metadata_array(), precision) @@ -269,19 +266,8 @@ impl VTable for ParquetVariant { ParquetVariantArray::try_new(validity, variant_metadata, value, typed_value) } - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ParquetVariantArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - // Update validity from the validity slot. - if let Some(validity_child) = &slots[VALIDITY_SLOT] { - array.validity = Validity::Array(validity_child.clone()); - } - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/encodings/pco/public-api.lock b/encodings/pco/public-api.lock index 207432082d8..b58e8fb9cba 100644 --- a/encodings/pco/public-api.lock +++ b/encodings/pco/public-api.lock @@ -30,7 +30,7 @@ pub type vortex_pco::Pco::Metadata = vortex_array::metadata::ProstMetadata bool @@ -64,16 +64,20 @@ pub fn vortex_pco::Pco::slot_name(_array: &vortex_pco::PcoArray, idx: usize) -> pub fn vortex_pco::Pco::slots(array: &vortex_pco::PcoArray) -> &[core::option::Option] +pub fn vortex_pco::Pco::slots_mut(array: &mut vortex_pco::PcoArray) -> &mut [core::option::Option] + pub fn vortex_pco::Pco::stats(array: &vortex_pco::PcoArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_pco::Pco::vtable(_array: &Self::Array) -> &Self -pub fn vortex_pco::Pco::with_slots(array: &mut vortex_pco::PcoArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_pco::Pco pub fn vortex_pco::Pco::scalar_at(array: &vortex_pco::PcoArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult +impl vortex_array::vtable::validity::ValidityVTable for vortex_pco::Pco + +pub fn vortex_pco::Pco::validity(array: &vortex_pco::PcoArray) -> vortex_error::VortexResult + pub struct vortex_pco::PcoArray impl vortex_pco::PcoArray @@ -116,10 +120,6 @@ impl vortex_array::array::IntoArray for vortex_pco::PcoArray pub fn vortex_pco::PcoArray::into_array(self) -> vortex_array::array::ArrayRef -impl vortex_array::vtable::validity::ValiditySliceHelper for vortex_pco::PcoArray - -pub fn vortex_pco::PcoArray::unsliced_validity_and_slice(&self) -> (&vortex_array::validity::Validity, usize, usize) - pub struct vortex_pco::PcoChunkInfo pub vortex_pco::PcoChunkInfo::pages: alloc::vec::Vec diff --git a/encodings/pco/src/array.rs b/encodings/pco/src/array.rs index 2859e878afb..b7f8756bef7 100644 --- a/encodings/pco/src/array.rs +++ b/encodings/pco/src/array.rs @@ -44,8 +44,8 @@ use vortex_array::vtable::Array; use vortex_array::vtable::ArrayId; use vortex_array::vtable::OperationsVTable; use vortex_array::vtable::VTable; -use vortex_array::vtable::ValiditySliceHelper; -use vortex_array::vtable::ValidityVTableFromValiditySliceHelper; +use vortex_array::vtable::ValidityVTable; +use vortex_array::vtable::child_to_validity; use vortex_array::vtable::validity_to_child; use vortex_buffer::BufferMut; use vortex_buffer::ByteBuffer; @@ -88,7 +88,7 @@ impl VTable for Pco { type Metadata = ProstMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromValiditySliceHelper; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &Pco @@ -112,7 +112,7 @@ impl VTable for Pco { fn array_hash(array: &PcoArray, state: &mut H, precision: Precision) { array.dtype.hash(state); - array.unsliced_validity.array_hash(state, precision); + array.unsliced_validity().array_hash(state, precision); array.unsliced_n_rows.hash(state); array.slice_start.hash(state); array.slice_stop.hash(state); @@ -128,8 +128,8 @@ impl VTable for Pco { fn array_eq(array: &PcoArray, other: &PcoArray, precision: Precision) -> bool { if array.dtype != other.dtype || !array - .unsliced_validity - .array_eq(&other.unsliced_validity, precision) + .unsliced_validity() + .array_eq(&other.unsliced_validity(), precision) || array.unsliced_n_rows != other.unsliced_n_rows || array.slice_start != other.slice_start || array.slice_stop != other.slice_stop @@ -242,19 +242,8 @@ impl VTable for Pco { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut PcoArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "PcoArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.unsliced_validity = match &slots[VALIDITY_SLOT] { - Some(arr) => Validity::Array(arr.clone()), - None => Validity::from(array.dtype.nullability()), - }; - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut PcoArray) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { @@ -318,7 +307,6 @@ pub struct PcoArray { pub(crate) pages: Vec, pub(crate) metadata: PcoMetadata, dtype: DType, - pub(crate) unsliced_validity: Validity, unsliced_n_rows: usize, pub(super) slots: Vec>, stats_set: ArrayStats, @@ -342,7 +330,6 @@ impl PcoArray { pages, metadata, dtype, - unsliced_validity: validity, unsliced_n_rows: len, slots: vec![validity_slot], stats_set: Default::default(), @@ -454,7 +441,7 @@ impl PcoArray { Ok(PrimitiveArray::from_values_byte_buffer( values_byte_buffer, self.dtype.as_ptype(), - self.unsliced_validity + self.unsliced_validity() .slice(self.slice_start..self.slice_stop)?, self.slice_stop - self.slice_start, )) @@ -466,7 +453,7 @@ impl PcoArray { ) -> VortexResult { // To start, we figure out what range of values we need to decompress. let slice_value_indices = self - .unsliced_validity + .unsliced_validity() .execute_mask(self.unsliced_n_rows, ctx)? .valid_counts_for_indices(&[self.slice_start, self.slice_stop]); let slice_value_start = slice_value_indices[0]; @@ -560,11 +547,18 @@ impl PcoArray { pub(crate) fn unsliced_n_rows(&self) -> usize { self.unsliced_n_rows } + + /// Returns the validity of the full (unsliced) array, derived from the validity slot. + pub(crate) fn unsliced_validity(&self) -> Validity { + child_to_validity(&self.slots[VALIDITY_SLOT], self.dtype.nullability()) + } } -impl ValiditySliceHelper for PcoArray { - fn unsliced_validity_and_slice(&self) -> (&Validity, usize, usize) { - (&self.unsliced_validity, self.slice_start, self.slice_stop) +impl ValidityVTable for Pco { + fn validity(array: &PcoArray) -> VortexResult { + array + .unsliced_validity() + .slice(array.slice_start..array.slice_stop) } } diff --git a/encodings/pco/src/compute/cast.rs b/encodings/pco/src/compute/cast.rs index 86dc4758977..f671ce3b50d 100644 --- a/encodings/pco/src/compute/cast.rs +++ b/encodings/pco/src/compute/cast.rs @@ -25,8 +25,7 @@ impl CastReduce for Pco { if array.dtype().eq_ignore_nullability(dtype) { // Create a new validity with the target nullability let new_validity = array - .unsliced_validity - .clone() + .unsliced_validity() .cast_nullability(dtype.nullability(), array.len())?; return Ok(Some( diff --git a/encodings/runend/public-api.lock b/encodings/runend/public-api.lock index e6647c92ece..77abb1e3e9d 100644 --- a/encodings/runend/public-api.lock +++ b/encodings/runend/public-api.lock @@ -94,12 +94,12 @@ pub fn vortex_runend::RunEnd::slot_name(_array: &vortex_runend::RunEndArray, idx pub fn vortex_runend::RunEnd::slots(array: &vortex_runend::RunEndArray) -> &[core::option::Option] +pub fn vortex_runend::RunEnd::slots_mut(array: &mut vortex_runend::RunEndArray) -> &mut [core::option::Option] + pub fn vortex_runend::RunEnd::stats(array: &vortex_runend::RunEndArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_runend::RunEnd::vtable(_array: &Self::Array) -> &Self -pub fn vortex_runend::RunEnd::with_slots(array: &mut vortex_runend::RunEndArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_runend::RunEnd pub fn vortex_runend::RunEnd::scalar_at(array: &vortex_runend::RunEndArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/runend/src/array.rs b/encodings/runend/src/array.rs index edba8a0f219..e97ee5d2335 100644 --- a/encodings/runend/src/array.rs +++ b/encodings/runend/src/array.rs @@ -166,15 +166,8 @@ impl VTable for RunEnd { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut RunEndArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "RunEndArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut RunEndArray) -> &mut [Option] { + &mut array.slots } fn reduce_parent( diff --git a/encodings/sequence/public-api.lock b/encodings/sequence/public-api.lock index 5fbfde94fb4..0ad7af2e4ac 100644 --- a/encodings/sequence/public-api.lock +++ b/encodings/sequence/public-api.lock @@ -82,12 +82,12 @@ pub fn vortex_sequence::Sequence::slot_name(_array: &vortex_sequence::SequenceAr pub fn vortex_sequence::Sequence::slots(array: &vortex_sequence::SequenceArray) -> &[core::option::Option] +pub fn vortex_sequence::Sequence::slots_mut(array: &mut vortex_sequence::SequenceArray) -> &mut [core::option::Option] + pub fn vortex_sequence::Sequence::stats(array: &vortex_sequence::SequenceArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_sequence::Sequence::vtable(_array: &Self::Array) -> &Self -pub fn vortex_sequence::Sequence::with_slots(array: &mut vortex_sequence::SequenceArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_sequence::Sequence pub fn vortex_sequence::Sequence::scalar_at(array: &vortex_sequence::SequenceArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/sequence/src/array.rs b/encodings/sequence/src/array.rs index ad50e0d1e93..56b0ab586c2 100644 --- a/encodings/sequence/src/array.rs +++ b/encodings/sequence/src/array.rs @@ -40,7 +40,6 @@ use vortex_array::vtable::ValidityVTable; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -379,14 +378,8 @@ impl VTable for Sequence { vortex_panic!("SequenceArray has no slots, requested index {idx}") } - fn with_slots(array: &mut SequenceArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.is_empty(), - "SequenceArray expects 0 slots, got {}", - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut SequenceArray) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/encodings/sparse/public-api.lock b/encodings/sparse/public-api.lock index 7eef7eeb184..71455f5010d 100644 --- a/encodings/sparse/public-api.lock +++ b/encodings/sparse/public-api.lock @@ -98,12 +98,12 @@ pub fn vortex_sparse::Sparse::slot_name(_array: &vortex_sparse::SparseArray, idx pub fn vortex_sparse::Sparse::slots(array: &vortex_sparse::SparseArray) -> &[core::option::Option] +pub fn vortex_sparse::Sparse::slots_mut(array: &mut vortex_sparse::SparseArray) -> &mut [core::option::Option] + pub fn vortex_sparse::Sparse::stats(array: &vortex_sparse::SparseArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_sparse::Sparse::vtable(_array: &Self::Array) -> &Self -pub fn vortex_sparse::Sparse::with_slots(array: &mut vortex_sparse::SparseArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_sparse::Sparse pub fn vortex_sparse::Sparse::scalar_at(array: &vortex_sparse::SparseArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/sparse/src/canonical.rs b/encodings/sparse/src/canonical.rs index 2e0f51843cd..5c488eb347f 100644 --- a/encodings/sparse/src/canonical.rs +++ b/encodings/sparse/src/canonical.rs @@ -40,7 +40,6 @@ use vortex_array::scalar::ListScalar; use vortex_array::scalar::Scalar; use vortex_array::scalar::StructScalar; use vortex_array::validity::Validity; -use vortex_array::vtable::ValidityHelper; use vortex_buffer::BitBuffer; use vortex_buffer::Buffer; use vortex_buffer::BufferString; diff --git a/encodings/sparse/src/lib.rs b/encodings/sparse/src/lib.rs index 52484cd9202..a360ff8220b 100644 --- a/encodings/sparse/src/lib.rs +++ b/encodings/sparse/src/lib.rs @@ -214,31 +214,8 @@ impl VTable for Sparse { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut SparseArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "SparseArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - - // Reconstruct patches from slots + existing metadata - let indices = slots[PATCH_INDICES_SLOT] - .clone() - .vortex_expect("SparseArray requires patch_indices slot"); - let values = slots[PATCH_VALUES_SLOT] - .clone() - .vortex_expect("SparseArray requires patch_values slot"); - - array.patches = Patches::new( - array.patches.array_len(), - array.patches.offset(), - indices, - values, - slots[PATCH_CHUNK_OFFSETS_SLOT].clone(), - )?; - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut SparseArray) -> &mut [Option] { + &mut array.slots } fn reduce_parent( @@ -264,10 +241,16 @@ impl VTable for Sparse { } /// The indices of non-fill values in the sparse array. +/// Will be used once iterative execution is implemented for sparse arrays. +#[expect(dead_code, reason = "needed once sparse has iterative execution")] pub(crate) const PATCH_INDICES_SLOT: usize = 0; /// The non-fill values at the corresponding patch indices. +/// Will be used once iterative execution is implemented for sparse arrays. +#[expect(dead_code, reason = "needed once sparse has iterative execution")] pub(crate) const PATCH_VALUES_SLOT: usize = 1; /// Chunk offsets for the patch indices/values. +/// Will be used once iterative execution is implemented for sparse arrays. +#[expect(dead_code, reason = "needed once sparse has iterative execution")] pub(crate) const PATCH_CHUNK_OFFSETS_SLOT: usize = 2; pub(crate) const NUM_SLOTS: usize = 3; pub(crate) const SLOT_NAMES: [&str; NUM_SLOTS] = diff --git a/encodings/zigzag/public-api.lock b/encodings/zigzag/public-api.lock index 4418feb629e..5efa926a0ab 100644 --- a/encodings/zigzag/public-api.lock +++ b/encodings/zigzag/public-api.lock @@ -78,12 +78,12 @@ pub fn vortex_zigzag::ZigZag::slot_name(_array: &vortex_zigzag::ZigZagArray, idx pub fn vortex_zigzag::ZigZag::slots(array: &vortex_zigzag::ZigZagArray) -> &[core::option::Option] +pub fn vortex_zigzag::ZigZag::slots_mut(array: &mut vortex_zigzag::ZigZagArray) -> &mut [core::option::Option] + pub fn vortex_zigzag::ZigZag::stats(array: &vortex_zigzag::ZigZagArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_zigzag::ZigZag::vtable(_array: &Self::Array) -> &Self -pub fn vortex_zigzag::ZigZag::with_slots(array: &mut vortex_zigzag::ZigZagArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_zigzag::ZigZag pub fn vortex_zigzag::ZigZag::scalar_at(array: &vortex_zigzag::ZigZagArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult diff --git a/encodings/zigzag/src/array.rs b/encodings/zigzag/src/array.rs index a417aae1af1..e4c317f1bb4 100644 --- a/encodings/zigzag/src/array.rs +++ b/encodings/zigzag/src/array.rs @@ -31,7 +31,6 @@ use vortex_array::vtable::ValidityVTableFromChild; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; use zigzag::ZigZag as ExternalZigZag; @@ -135,15 +134,8 @@ impl VTable for ZigZag { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut ZigZagArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ZigZagArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut ZigZagArray) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/encodings/zstd/public-api.lock b/encodings/zstd/public-api.lock index 7ed3514287b..9eeacff078f 100644 --- a/encodings/zstd/public-api.lock +++ b/encodings/zstd/public-api.lock @@ -30,7 +30,7 @@ pub type vortex_zstd::Zstd::Metadata = vortex_array::metadata::ProstMetadata bool @@ -64,16 +64,20 @@ pub fn vortex_zstd::Zstd::slot_name(_array: &vortex_zstd::ZstdArray, idx: usize) pub fn vortex_zstd::Zstd::slots(array: &vortex_zstd::ZstdArray) -> &[core::option::Option] +pub fn vortex_zstd::Zstd::slots_mut(array: &mut vortex_zstd::ZstdArray) -> &mut [core::option::Option] + pub fn vortex_zstd::Zstd::stats(array: &vortex_zstd::ZstdArray) -> vortex_array::stats::array::StatsSetRef<'_> pub fn vortex_zstd::Zstd::vtable(_array: &Self::Array) -> &Self -pub fn vortex_zstd::Zstd::with_slots(array: &mut vortex_zstd::ZstdArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::operations::OperationsVTable for vortex_zstd::Zstd pub fn vortex_zstd::Zstd::scalar_at(array: &vortex_zstd::ZstdArray, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult +impl vortex_array::vtable::validity::ValidityVTable for vortex_zstd::Zstd + +pub fn vortex_zstd::Zstd::validity(array: &vortex_zstd::ZstdArray) -> vortex_error::VortexResult + pub struct vortex_zstd::ZstdArray impl vortex_zstd::ZstdArray @@ -126,10 +130,6 @@ impl vortex_array::array::IntoArray for vortex_zstd::ZstdArray pub fn vortex_zstd::ZstdArray::into_array(self) -> vortex_array::array::ArrayRef -impl vortex_array::vtable::validity::ValiditySliceHelper for vortex_zstd::ZstdArray - -pub fn vortex_zstd::ZstdArray::unsliced_validity_and_slice(&self) -> (&vortex_array::validity::Validity, usize, usize) - pub struct vortex_zstd::ZstdArrayParts pub vortex_zstd::ZstdArrayParts::dictionary: core::option::Option diff --git a/encodings/zstd/src/array.rs b/encodings/zstd/src/array.rs index 200cffb0ff0..111effbd343 100644 --- a/encodings/zstd/src/array.rs +++ b/encodings/zstd/src/array.rs @@ -38,8 +38,8 @@ use vortex_array::vtable::Array; use vortex_array::vtable::ArrayId; use vortex_array::vtable::OperationsVTable; use vortex_array::vtable::VTable; -use vortex_array::vtable::ValiditySliceHelper; -use vortex_array::vtable::ValidityVTableFromValiditySliceHelper; +use vortex_array::vtable::ValidityVTable; +use vortex_array::vtable::child_to_validity; use vortex_array::vtable::validity_to_child; use vortex_buffer::Alignment; use vortex_buffer::Buffer; @@ -50,7 +50,6 @@ use vortex_error::VortexError; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_mask::AllOr; @@ -88,7 +87,7 @@ impl VTable for Zstd { type Metadata = ProstMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromValiditySliceHelper; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &Zstd @@ -124,7 +123,7 @@ impl VTable for Zstd { frame.array_hash(state, precision); } array.dtype.hash(state); - array.unsliced_validity.array_hash(state, precision); + array.unsliced_validity().array_hash(state, precision); array.unsliced_n_rows.hash(state); array.slice_start.hash(state); array.slice_stop.hash(state); @@ -148,8 +147,8 @@ impl VTable for Zstd { } array.dtype == other.dtype && array - .unsliced_validity - .array_eq(&other.unsliced_validity, precision) + .unsliced_validity() + .array_eq(&other.unsliced_validity(), precision) && array.unsliced_n_rows == other.unsliced_n_rows && array.slice_start == other.slice_start && array.slice_stop == other.slice_stop @@ -254,21 +253,8 @@ impl VTable for Zstd { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut ZstdArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ZstdArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - - array.unsliced_validity = match &slots[VALIDITY_SLOT] { - Some(arr) => Validity::Array(arr.clone()), - None => Validity::from(array.dtype.nullability()), - }; - - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut ZstdArray) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { @@ -305,7 +291,6 @@ pub struct ZstdArray { pub(crate) frames: Vec, pub(crate) metadata: ZstdMetadata, dtype: DType, - pub(crate) unsliced_validity: Validity, unsliced_n_rows: usize, pub(super) slots: Vec>, stats_set: ArrayStats, @@ -445,7 +430,6 @@ impl ZstdArray { frames, metadata, dtype, - unsliced_validity: validity, unsliced_n_rows: n_rows, slots: vec![validity_slot], stats_set: Default::default(), @@ -738,7 +722,7 @@ impl ZstdArray { let byte_width = self.byte_width(); let slice_n_rows = self.slice_stop - self.slice_start; let slice_value_indices = self - .unsliced_validity + .unsliced_validity() .execute_mask(self.unsliced_n_rows, ctx)? .valid_counts_for_indices(&[self.slice_start, self.slice_stop]); @@ -806,7 +790,7 @@ impl ZstdArray { let decompressed = decompressed.freeze(); // Last, we slice the exact values requested out of the decompressed data. let mut slice_validity = self - .unsliced_validity + .unsliced_validity() .slice(self.slice_start..self.slice_stop)?; // NOTE: this block handles setting the output type when the validity and DType disagree. @@ -926,18 +910,24 @@ impl ZstdArray { /// Consumes the array and returns its parts. pub fn into_parts(self) -> ZstdArrayParts { + let validity = self.unsliced_validity(); ZstdArrayParts { dictionary: self.dictionary, frames: self.frames, metadata: self.metadata, dtype: self.dtype, - validity: self.unsliced_validity, + validity, n_rows: self.unsliced_n_rows, slice_start: self.slice_start, slice_stop: self.slice_stop, } } + /// Returns the validity of the full (unsliced) array, derived from the validity slot. + pub(crate) fn unsliced_validity(&self) -> Validity { + child_to_validity(&self.slots[VALIDITY_SLOT], self.dtype.nullability()) + } + pub(crate) fn dtype(&self) -> &DType { &self.dtype } @@ -955,9 +945,11 @@ impl ZstdArray { } } -impl ValiditySliceHelper for ZstdArray { - fn unsliced_validity_and_slice(&self) -> (&Validity, usize, usize) { - (&self.unsliced_validity, self.slice_start, self.slice_stop) +impl ValidityVTable for Zstd { + fn validity(array: &ZstdArray) -> VortexResult { + array + .unsliced_validity() + .slice(array.slice_start..array.slice_stop) } } diff --git a/encodings/zstd/src/compute/cast.rs b/encodings/zstd/src/compute/cast.rs index f57637df88c..373fca8d7be 100644 --- a/encodings/zstd/src/compute/cast.rs +++ b/encodings/zstd/src/compute/cast.rs @@ -39,7 +39,7 @@ impl CastReduce for Zstd { dtype.clone(), array.metadata.clone(), array.unsliced_n_rows(), - array.unsliced_validity.clone(), + array.unsliced_validity(), ) .slice(array.slice_start()..array.slice_stop())?, )) @@ -64,7 +64,7 @@ impl CastReduce for Zstd { dtype.clone(), array.metadata.clone(), array.unsliced_n_rows(), - array.unsliced_validity.clone(), + array.unsliced_validity(), ) .slice(array.slice_start()..array.slice_stop())?, )) diff --git a/encodings/zstd/src/zstd_buffers.rs b/encodings/zstd/src/zstd_buffers.rs index 9ac127bcecd..bc55a599c0d 100644 --- a/encodings/zstd/src/zstd_buffers.rs +++ b/encodings/zstd/src/zstd_buffers.rs @@ -412,9 +412,8 @@ impl VTable for ZstdBuffers { format!("child_{idx}") } - fn with_slots(array: &mut ZstdBuffersArray, slots: Vec>) -> VortexResult<()> { - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut ZstdBuffersArray) -> &mut [Option] { + &mut array.slots } fn metadata(array: &ZstdBuffersArray) -> VortexResult { diff --git a/fuzz/src/array/mask.rs b/fuzz/src/array/mask.rs index 71049e8c748..1f9b11efe64 100644 --- a/fuzz/src/array/mask.rs +++ b/fuzz/src/array/mask.rs @@ -17,7 +17,6 @@ use vortex_array::arrays::VarBinViewArray; use vortex_array::dtype::Nullability; use vortex_array::match_each_decimal_value_type; use vortex_array::validity::Validity; -use vortex_array::vtable::ValidityHelper; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_mask::AllOr; diff --git a/vortex-array/public-api.lock b/vortex-array/public-api.lock index c193f10da92..f74f0081331 100644 --- a/vortex-array/public-api.lock +++ b/vortex-array/public-api.lock @@ -944,12 +944,12 @@ pub fn vortex_array::arrays::Bool::slot_name(_array: &vortex_array::arrays::Bool pub fn vortex_array::arrays::Bool::slots(array: &vortex_array::arrays::BoolArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Bool::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Bool::stats(array: &vortex_array::arrays::BoolArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Bool::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Bool::with_slots(array: &mut vortex_array::arrays::BoolArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Bool pub fn vortex_array::arrays::Bool::validity(array: &vortex_array::arrays::BoolArray) -> vortex_error::VortexResult @@ -1164,12 +1164,12 @@ pub fn vortex_array::arrays::Chunked::slot_name(_array: &vortex_array::arrays::C pub fn vortex_array::arrays::Chunked::slots(array: &vortex_array::arrays::ChunkedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Chunked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Chunked::stats(array: &vortex_array::arrays::ChunkedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Chunked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Chunked::with_slots(array: &mut vortex_array::arrays::ChunkedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Chunked pub fn vortex_array::arrays::Chunked::validity(array: &vortex_array::arrays::ChunkedArray) -> vortex_error::VortexResult @@ -1342,12 +1342,12 @@ pub fn vortex_array::arrays::Constant::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::Constant::slots(array: &vortex_array::arrays::ConstantArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Constant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Constant::stats(array: &vortex_array::arrays::ConstantArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Constant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Constant::with_slots(array: &mut vortex_array::arrays::ConstantArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Constant pub fn vortex_array::arrays::Constant::validity(array: &vortex_array::arrays::ConstantArray) -> vortex_error::VortexResult @@ -1558,12 +1558,12 @@ pub fn vortex_array::arrays::Decimal::slot_name(_array: &vortex_array::arrays::D pub fn vortex_array::arrays::Decimal::slots(array: &vortex_array::arrays::DecimalArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Decimal::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Decimal::stats(array: &vortex_array::arrays::DecimalArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Decimal::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Decimal::with_slots(array: &mut vortex_array::arrays::DecimalArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Decimal pub fn vortex_array::arrays::Decimal::validity(array: &vortex_array::arrays::DecimalArray) -> vortex_error::VortexResult @@ -1778,12 +1778,12 @@ pub fn vortex_array::arrays::dict::Dict::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::dict::Dict::slots(array: &vortex_array::arrays::dict::DictArray) -> &[core::option::Option] +pub fn vortex_array::arrays::dict::Dict::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::dict::Dict::stats(array: &vortex_array::arrays::dict::DictArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::dict::Dict::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::dict::Dict::with_slots(array: &mut vortex_array::arrays::dict::DictArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::dict::Dict pub fn vortex_array::arrays::dict::Dict::validity(array: &vortex_array::arrays::dict::DictArray) -> vortex_error::VortexResult @@ -1892,12 +1892,12 @@ pub fn vortex_array::arrays::dict::Dict::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::dict::Dict::slots(array: &vortex_array::arrays::dict::DictArray) -> &[core::option::Option] +pub fn vortex_array::arrays::dict::Dict::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::dict::Dict::stats(array: &vortex_array::arrays::dict::DictArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::dict::Dict::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::dict::Dict::with_slots(array: &mut vortex_array::arrays::dict::DictArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::dict::Dict pub fn vortex_array::arrays::dict::Dict::validity(array: &vortex_array::arrays::dict::DictArray) -> vortex_error::VortexResult @@ -2202,12 +2202,12 @@ pub fn vortex_array::arrays::Extension::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Extension::slots(array: &vortex_array::arrays::ExtensionArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Extension::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Extension::stats(array: &vortex_array::arrays::ExtensionArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Extension::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Extension::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityChild for vortex_array::arrays::Extension pub fn vortex_array::arrays::Extension::validity_child(array: &vortex_array::arrays::ExtensionArray) -> &vortex_array::ArrayRef @@ -2348,12 +2348,12 @@ pub fn vortex_array::arrays::Filter::slot_name(_array: &Self::Array, idx: usize) pub fn vortex_array::arrays::Filter::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Filter::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Filter::stats(array: &vortex_array::arrays::FilterArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Filter::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Filter::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Filter pub fn vortex_array::arrays::Filter::validity(array: &vortex_array::arrays::FilterArray) -> vortex_error::VortexResult @@ -2532,7 +2532,7 @@ pub type vortex_array::arrays::FixedSizeList::Metadata = vortex_array::EmptyMeta pub type vortex_array::arrays::FixedSizeList::OperationsVTable = vortex_array::arrays::FixedSizeList -pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::arrays::FixedSizeList pub fn vortex_array::arrays::FixedSizeList::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -2578,11 +2578,15 @@ pub fn vortex_array::arrays::FixedSizeList::slot_name(_array: &vortex_array::arr pub fn vortex_array::arrays::FixedSizeList::slots(array: &vortex_array::arrays::FixedSizeListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::FixedSizeList::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::FixedSizeList::stats(array: &vortex_array::arrays::FixedSizeListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::FixedSizeList::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::FixedSizeList::with_slots(array: &mut vortex_array::arrays::FixedSizeListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::FixedSizeList + +pub fn vortex_array::arrays::FixedSizeList::validity(array: &vortex_array::arrays::FixedSizeListArray) -> vortex_error::VortexResult pub struct vortex_array::arrays::fixed_size_list::FixedSizeListArray @@ -2604,6 +2608,8 @@ pub fn vortex_array::arrays::FixedSizeListArray::try_new(elements: vortex_array: pub fn vortex_array::arrays::FixedSizeListArray::validate(elements: &vortex_array::ArrayRef, len: usize, list_size: u32, validity: &vortex_array::validity::Validity) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::FixedSizeListArray::validity(&self) -> vortex_array::validity::Validity + impl vortex_array::arrays::FixedSizeListArray pub fn vortex_array::arrays::FixedSizeListArray::to_array(&self) -> vortex_array::ArrayRef @@ -2638,10 +2644,6 @@ impl vortex_array::IntoArray for vortex_array::arrays::FixedSizeListArray pub fn vortex_array::arrays::FixedSizeListArray::into_array(self) -> vortex_array::ArrayRef -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::FixedSizeListArray - -pub fn vortex_array::arrays::FixedSizeListArray::validity(&self) -> vortex_array::validity::Validity - pub mod vortex_array::arrays::list pub struct vortex_array::arrays::list::List @@ -2690,7 +2692,7 @@ pub type vortex_array::arrays::List::Metadata = vortex_array::ProstMetadata vortex_error::VortexResult<()> @@ -2736,11 +2738,15 @@ pub fn vortex_array::arrays::List::slot_name(_array: &vortex_array::arrays::List pub fn vortex_array::arrays::List::slots(array: &vortex_array::arrays::ListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::List::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::List::stats(array: &vortex_array::arrays::ListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::List::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::List::with_slots(array: &mut vortex_array::arrays::ListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::List + +pub fn vortex_array::arrays::List::validity(array: &vortex_array::arrays::ListArray) -> vortex_error::VortexResult pub struct vortex_array::arrays::list::ListArray @@ -2770,6 +2776,8 @@ pub fn vortex_array::arrays::ListArray::try_new(elements: vortex_array::ArrayRef pub fn vortex_array::arrays::ListArray::validate(elements: &vortex_array::ArrayRef, offsets: &vortex_array::ArrayRef, validity: &vortex_array::validity::Validity) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::ListArray::validity(&self) -> vortex_array::validity::Validity + impl vortex_array::arrays::ListArray pub fn vortex_array::arrays::ListArray::to_array(&self) -> vortex_array::ArrayRef @@ -2800,10 +2808,6 @@ impl vortex_array::IntoArray for vortex_array::arrays::ListArray pub fn vortex_array::arrays::ListArray::into_array(self) -> vortex_array::ArrayRef -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::ListArray - -pub fn vortex_array::arrays::ListArray::validity(&self) -> vortex_array::validity::Validity - pub struct vortex_array::arrays::list::ListArrayParts pub vortex_array::arrays::list::ListArrayParts::dtype: vortex_array::dtype::DType @@ -2868,7 +2872,7 @@ pub type vortex_array::arrays::ListView::Metadata = vortex_array::ProstMetadata< pub type vortex_array::arrays::ListView::OperationsVTable = vortex_array::arrays::ListView -pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::arrays::ListView pub fn vortex_array::arrays::ListView::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -2914,11 +2918,15 @@ pub fn vortex_array::arrays::ListView::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::ListView::slots(array: &vortex_array::arrays::ListViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::ListView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::ListView::stats(array: &vortex_array::arrays::ListViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::ListView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::ListView::with_slots(array: &mut vortex_array::arrays::ListViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::ListView + +pub fn vortex_array::arrays::ListView::validity(array: &vortex_array::arrays::ListViewArray) -> vortex_error::VortexResult pub struct vortex_array::arrays::listview::ListViewArray @@ -2948,6 +2956,8 @@ pub fn vortex_array::arrays::ListViewArray::try_new(elements: vortex_array::Arra pub fn vortex_array::arrays::ListViewArray::validate(elements: &vortex_array::ArrayRef, offsets: &vortex_array::ArrayRef, sizes: &vortex_array::ArrayRef, validity: &vortex_array::validity::Validity) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::ListViewArray::validity(&self) -> vortex_array::validity::Validity + pub fn vortex_array::arrays::ListViewArray::verify_is_zero_copy_to_list(&self) -> bool pub unsafe fn vortex_array::arrays::ListViewArray::with_zero_copy_to_list(self, is_zctl: bool) -> Self @@ -2990,10 +3000,6 @@ impl vortex_array::IntoArray for vortex_array::arrays::ListViewArray pub fn vortex_array::arrays::ListViewArray::into_array(self) -> vortex_array::ArrayRef -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::ListViewArray - -pub fn vortex_array::arrays::ListViewArray::validity(&self) -> vortex_array::validity::Validity - pub struct vortex_array::arrays::listview::ListViewArrayParts pub vortex_array::arrays::listview::ListViewArrayParts::elements: vortex_array::ArrayRef @@ -3102,12 +3108,12 @@ pub fn vortex_array::arrays::Masked::slot_name(_array: &vortex_array::arrays::Ma pub fn vortex_array::arrays::Masked::slots(array: &vortex_array::arrays::MaskedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Masked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Masked::stats(array: &vortex_array::arrays::MaskedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Masked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Masked::with_slots(array: &mut vortex_array::arrays::MaskedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Masked pub fn vortex_array::arrays::Masked::validity(array: &vortex_array::arrays::MaskedArray) -> vortex_error::VortexResult @@ -3252,12 +3258,12 @@ pub fn vortex_array::arrays::null::Null::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::null::Null::slots(array: &vortex_array::arrays::null::NullArray) -> &[core::option::Option] +pub fn vortex_array::arrays::null::Null::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::null::Null::stats(array: &vortex_array::arrays::null::NullArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::null::Null::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::null::Null::with_slots(array: &mut vortex_array::arrays::null::NullArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::null::Null pub fn vortex_array::arrays::null::Null::validity(_array: &vortex_array::arrays::null::NullArray) -> vortex_error::VortexResult @@ -3388,12 +3394,12 @@ pub fn vortex_array::arrays::patched::Patched::slot_name(_array: &Self::Array, i pub fn vortex_array::arrays::patched::Patched::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::patched::Patched::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::patched::Patched::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::patched::Patched::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::patched::Patched::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityChild for vortex_array::arrays::patched::Patched pub fn vortex_array::arrays::patched::Patched::validity_child(array: &vortex_array::arrays::patched::PatchedArray) -> &vortex_array::ArrayRef @@ -3634,12 +3640,12 @@ pub fn vortex_array::arrays::Primitive::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Primitive::slots(array: &vortex_array::arrays::PrimitiveArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Primitive::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Primitive::stats(array: &vortex_array::arrays::PrimitiveArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Primitive::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Primitive::with_slots(array: &mut vortex_array::arrays::PrimitiveArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Primitive pub fn vortex_array::arrays::Primitive::validity(array: &vortex_array::arrays::PrimitiveArray) -> vortex_error::VortexResult @@ -3952,12 +3958,12 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: &vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> &[core::option::Option] +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::stats(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::vtable(array: &Self::Array) -> &Self -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::with_slots(array: &mut vortex_array::arrays::scalar_fn::ScalarFnArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::scalar_fn::ScalarFnVTable pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validity(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> vortex_error::VortexResult @@ -4044,12 +4050,12 @@ pub fn vortex_array::arrays::Shared::slot_name(_array: &vortex_array::arrays::Sh pub fn vortex_array::arrays::Shared::slots(array: &vortex_array::arrays::SharedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Shared::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Shared::stats(array: &vortex_array::arrays::SharedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Shared::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Shared::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Shared pub fn vortex_array::arrays::Shared::validity(array: &vortex_array::arrays::SharedArray) -> vortex_error::VortexResult @@ -4172,12 +4178,12 @@ pub fn vortex_array::arrays::slice::Slice::slot_name(_array: &Self::Array, idx: pub fn vortex_array::arrays::slice::Slice::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::slice::Slice::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::slice::Slice::stats(array: &vortex_array::arrays::slice::SliceArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::slice::Slice::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::slice::Slice::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::slice::Slice pub fn vortex_array::arrays::slice::Slice::validity(array: &vortex_array::arrays::slice::SliceArray) -> vortex_error::VortexResult @@ -4440,12 +4446,12 @@ pub fn vortex_array::arrays::Struct::slot_name(array: &vortex_array::arrays::Str pub fn vortex_array::arrays::Struct::slots(array: &vortex_array::arrays::StructArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Struct::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Struct::stats(array: &vortex_array::arrays::StructArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Struct::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Struct::with_slots(array: &mut vortex_array::arrays::StructArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Struct pub fn vortex_array::arrays::Struct::validity(array: &vortex_array::arrays::StructArray) -> vortex_error::VortexResult @@ -4672,12 +4678,12 @@ pub fn vortex_array::arrays::VarBin::slot_name(_array: &vortex_array::arrays::Va pub fn vortex_array::arrays::VarBin::slots(array: &vortex_array::arrays::VarBinArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBin::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBin::stats(array: &vortex_array::arrays::VarBinArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBin::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBin::with_slots(array: &mut vortex_array::arrays::VarBinArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::VarBin pub fn vortex_array::arrays::VarBin::validity(array: &vortex_array::arrays::VarBinArray) -> vortex_error::VortexResult @@ -5086,12 +5092,12 @@ pub fn vortex_array::arrays::VarBinView::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::VarBinView::slots(array: &vortex_array::arrays::VarBinViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBinView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBinView::stats(array: &vortex_array::arrays::VarBinViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBinView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBinView::with_slots(array: &mut vortex_array::arrays::VarBinViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::VarBinView pub fn vortex_array::arrays::VarBinView::validity(array: &vortex_array::arrays::VarBinViewArray) -> vortex_error::VortexResult @@ -5288,12 +5294,12 @@ pub fn vortex_array::arrays::Variant::slot_name(_array: &Self::Array, idx: usize pub fn vortex_array::arrays::Variant::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Variant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Variant::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Variant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Variant::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Variant pub fn vortex_array::arrays::Variant::validity(array: &::Array) -> vortex_error::VortexResult @@ -5438,12 +5444,12 @@ pub fn vortex_array::arrays::Bool::slot_name(_array: &vortex_array::arrays::Bool pub fn vortex_array::arrays::Bool::slots(array: &vortex_array::arrays::BoolArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Bool::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Bool::stats(array: &vortex_array::arrays::BoolArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Bool::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Bool::with_slots(array: &mut vortex_array::arrays::BoolArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Bool pub fn vortex_array::arrays::Bool::validity(array: &vortex_array::arrays::BoolArray) -> vortex_error::VortexResult @@ -5630,12 +5636,12 @@ pub fn vortex_array::arrays::Chunked::slot_name(_array: &vortex_array::arrays::C pub fn vortex_array::arrays::Chunked::slots(array: &vortex_array::arrays::ChunkedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Chunked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Chunked::stats(array: &vortex_array::arrays::ChunkedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Chunked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Chunked::with_slots(array: &mut vortex_array::arrays::ChunkedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Chunked pub fn vortex_array::arrays::Chunked::validity(array: &vortex_array::arrays::ChunkedArray) -> vortex_error::VortexResult @@ -5806,12 +5812,12 @@ pub fn vortex_array::arrays::Constant::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::Constant::slots(array: &vortex_array::arrays::ConstantArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Constant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Constant::stats(array: &vortex_array::arrays::ConstantArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Constant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Constant::with_slots(array: &mut vortex_array::arrays::ConstantArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Constant pub fn vortex_array::arrays::Constant::validity(array: &vortex_array::arrays::ConstantArray) -> vortex_error::VortexResult @@ -5958,12 +5964,12 @@ pub fn vortex_array::arrays::Decimal::slot_name(_array: &vortex_array::arrays::D pub fn vortex_array::arrays::Decimal::slots(array: &vortex_array::arrays::DecimalArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Decimal::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Decimal::stats(array: &vortex_array::arrays::DecimalArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Decimal::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Decimal::with_slots(array: &mut vortex_array::arrays::DecimalArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Decimal pub fn vortex_array::arrays::Decimal::validity(array: &vortex_array::arrays::DecimalArray) -> vortex_error::VortexResult @@ -6146,12 +6152,12 @@ pub fn vortex_array::arrays::dict::Dict::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::dict::Dict::slots(array: &vortex_array::arrays::dict::DictArray) -> &[core::option::Option] +pub fn vortex_array::arrays::dict::Dict::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::dict::Dict::stats(array: &vortex_array::arrays::dict::DictArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::dict::Dict::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::dict::Dict::with_slots(array: &mut vortex_array::arrays::dict::DictArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::dict::Dict pub fn vortex_array::arrays::dict::Dict::validity(array: &vortex_array::arrays::dict::DictArray) -> vortex_error::VortexResult @@ -6310,12 +6316,12 @@ pub fn vortex_array::arrays::Extension::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Extension::slots(array: &vortex_array::arrays::ExtensionArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Extension::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Extension::stats(array: &vortex_array::arrays::ExtensionArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Extension::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Extension::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityChild for vortex_array::arrays::Extension pub fn vortex_array::arrays::Extension::validity_child(array: &vortex_array::arrays::ExtensionArray) -> &vortex_array::ArrayRef @@ -6454,12 +6460,12 @@ pub fn vortex_array::arrays::Filter::slot_name(_array: &Self::Array, idx: usize) pub fn vortex_array::arrays::Filter::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Filter::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Filter::stats(array: &vortex_array::arrays::FilterArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Filter::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Filter::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Filter pub fn vortex_array::arrays::Filter::validity(array: &vortex_array::arrays::FilterArray) -> vortex_error::VortexResult @@ -6550,7 +6556,7 @@ pub type vortex_array::arrays::FixedSizeList::Metadata = vortex_array::EmptyMeta pub type vortex_array::arrays::FixedSizeList::OperationsVTable = vortex_array::arrays::FixedSizeList -pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::arrays::FixedSizeList pub fn vortex_array::arrays::FixedSizeList::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -6596,11 +6602,15 @@ pub fn vortex_array::arrays::FixedSizeList::slot_name(_array: &vortex_array::arr pub fn vortex_array::arrays::FixedSizeList::slots(array: &vortex_array::arrays::FixedSizeListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::FixedSizeList::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::FixedSizeList::stats(array: &vortex_array::arrays::FixedSizeListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::FixedSizeList::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::FixedSizeList::with_slots(array: &mut vortex_array::arrays::FixedSizeListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::FixedSizeList + +pub fn vortex_array::arrays::FixedSizeList::validity(array: &vortex_array::arrays::FixedSizeListArray) -> vortex_error::VortexResult pub struct vortex_array::arrays::FixedSizeListArray @@ -6622,6 +6632,8 @@ pub fn vortex_array::arrays::FixedSizeListArray::try_new(elements: vortex_array: pub fn vortex_array::arrays::FixedSizeListArray::validate(elements: &vortex_array::ArrayRef, len: usize, list_size: u32, validity: &vortex_array::validity::Validity) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::FixedSizeListArray::validity(&self) -> vortex_array::validity::Validity + impl vortex_array::arrays::FixedSizeListArray pub fn vortex_array::arrays::FixedSizeListArray::to_array(&self) -> vortex_array::ArrayRef @@ -6656,10 +6668,6 @@ impl vortex_array::IntoArray for vortex_array::arrays::FixedSizeListArray pub fn vortex_array::arrays::FixedSizeListArray::into_array(self) -> vortex_array::ArrayRef -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::FixedSizeListArray - -pub fn vortex_array::arrays::FixedSizeListArray::validity(&self) -> vortex_array::validity::Validity - pub struct vortex_array::arrays::List impl vortex_array::arrays::List @@ -6706,7 +6714,7 @@ pub type vortex_array::arrays::List::Metadata = vortex_array::ProstMetadata vortex_error::VortexResult<()> @@ -6752,11 +6760,15 @@ pub fn vortex_array::arrays::List::slot_name(_array: &vortex_array::arrays::List pub fn vortex_array::arrays::List::slots(array: &vortex_array::arrays::ListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::List::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::List::stats(array: &vortex_array::arrays::ListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::List::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::List::with_slots(array: &mut vortex_array::arrays::ListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::List + +pub fn vortex_array::arrays::List::validity(array: &vortex_array::arrays::ListArray) -> vortex_error::VortexResult pub struct vortex_array::arrays::ListArray @@ -6786,6 +6798,8 @@ pub fn vortex_array::arrays::ListArray::try_new(elements: vortex_array::ArrayRef pub fn vortex_array::arrays::ListArray::validate(elements: &vortex_array::ArrayRef, offsets: &vortex_array::ArrayRef, validity: &vortex_array::validity::Validity) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::ListArray::validity(&self) -> vortex_array::validity::Validity + impl vortex_array::arrays::ListArray pub fn vortex_array::arrays::ListArray::to_array(&self) -> vortex_array::ArrayRef @@ -6816,10 +6830,6 @@ impl vortex_array::IntoArray for vortex_array::arrays::ListArray pub fn vortex_array::arrays::ListArray::into_array(self) -> vortex_array::ArrayRef -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::ListArray - -pub fn vortex_array::arrays::ListArray::validity(&self) -> vortex_array::validity::Validity - pub struct vortex_array::arrays::ListView impl vortex_array::arrays::ListView @@ -6862,7 +6872,7 @@ pub type vortex_array::arrays::ListView::Metadata = vortex_array::ProstMetadata< pub type vortex_array::arrays::ListView::OperationsVTable = vortex_array::arrays::ListView -pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::arrays::ListView pub fn vortex_array::arrays::ListView::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -6908,11 +6918,15 @@ pub fn vortex_array::arrays::ListView::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::ListView::slots(array: &vortex_array::arrays::ListViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::ListView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::ListView::stats(array: &vortex_array::arrays::ListViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::ListView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::ListView::with_slots(array: &mut vortex_array::arrays::ListViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::ListView + +pub fn vortex_array::arrays::ListView::validity(array: &vortex_array::arrays::ListViewArray) -> vortex_error::VortexResult pub struct vortex_array::arrays::ListViewArray @@ -6942,6 +6956,8 @@ pub fn vortex_array::arrays::ListViewArray::try_new(elements: vortex_array::Arra pub fn vortex_array::arrays::ListViewArray::validate(elements: &vortex_array::ArrayRef, offsets: &vortex_array::ArrayRef, sizes: &vortex_array::ArrayRef, validity: &vortex_array::validity::Validity) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::ListViewArray::validity(&self) -> vortex_array::validity::Validity + pub fn vortex_array::arrays::ListViewArray::verify_is_zero_copy_to_list(&self) -> bool pub unsafe fn vortex_array::arrays::ListViewArray::with_zero_copy_to_list(self, is_zctl: bool) -> Self @@ -6984,10 +7000,6 @@ impl vortex_array::IntoArray for vortex_array::arrays::ListViewArray pub fn vortex_array::arrays::ListViewArray::into_array(self) -> vortex_array::ArrayRef -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::ListViewArray - -pub fn vortex_array::arrays::ListViewArray::validity(&self) -> vortex_array::validity::Validity - pub struct vortex_array::arrays::Masked impl vortex_array::arrays::Masked @@ -7076,12 +7088,12 @@ pub fn vortex_array::arrays::Masked::slot_name(_array: &vortex_array::arrays::Ma pub fn vortex_array::arrays::Masked::slots(array: &vortex_array::arrays::MaskedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Masked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Masked::stats(array: &vortex_array::arrays::MaskedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Masked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Masked::with_slots(array: &mut vortex_array::arrays::MaskedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Masked pub fn vortex_array::arrays::Masked::validity(array: &vortex_array::arrays::MaskedArray) -> vortex_error::VortexResult @@ -7222,12 +7234,12 @@ pub fn vortex_array::arrays::null::Null::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::null::Null::slots(array: &vortex_array::arrays::null::NullArray) -> &[core::option::Option] +pub fn vortex_array::arrays::null::Null::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::null::Null::stats(array: &vortex_array::arrays::null::NullArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::null::Null::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::null::Null::with_slots(array: &mut vortex_array::arrays::null::NullArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::null::Null pub fn vortex_array::arrays::null::Null::validity(_array: &vortex_array::arrays::null::NullArray) -> vortex_error::VortexResult @@ -7356,12 +7368,12 @@ pub fn vortex_array::arrays::patched::Patched::slot_name(_array: &Self::Array, i pub fn vortex_array::arrays::patched::Patched::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::patched::Patched::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::patched::Patched::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::patched::Patched::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::patched::Patched::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityChild for vortex_array::arrays::patched::Patched pub fn vortex_array::arrays::patched::Patched::validity_child(array: &vortex_array::arrays::patched::PatchedArray) -> &vortex_array::ArrayRef @@ -7514,12 +7526,12 @@ pub fn vortex_array::arrays::Primitive::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Primitive::slots(array: &vortex_array::arrays::PrimitiveArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Primitive::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Primitive::stats(array: &vortex_array::arrays::PrimitiveArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Primitive::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Primitive::with_slots(array: &mut vortex_array::arrays::PrimitiveArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Primitive pub fn vortex_array::arrays::Primitive::validity(array: &vortex_array::arrays::PrimitiveArray) -> vortex_error::VortexResult @@ -7758,12 +7770,12 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: &vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> &[core::option::Option] +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::stats(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::vtable(array: &Self::Array) -> &Self -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::with_slots(array: &mut vortex_array::arrays::scalar_fn::ScalarFnArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::scalar_fn::ScalarFnVTable pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validity(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> vortex_error::VortexResult @@ -7840,12 +7852,12 @@ pub fn vortex_array::arrays::Shared::slot_name(_array: &vortex_array::arrays::Sh pub fn vortex_array::arrays::Shared::slots(array: &vortex_array::arrays::SharedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Shared::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Shared::stats(array: &vortex_array::arrays::SharedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Shared::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Shared::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Shared pub fn vortex_array::arrays::Shared::validity(array: &vortex_array::arrays::SharedArray) -> vortex_error::VortexResult @@ -7966,12 +7978,12 @@ pub fn vortex_array::arrays::slice::Slice::slot_name(_array: &Self::Array, idx: pub fn vortex_array::arrays::slice::Slice::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::slice::Slice::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::slice::Slice::stats(array: &vortex_array::arrays::slice::SliceArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::slice::Slice::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::slice::Slice::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::slice::Slice pub fn vortex_array::arrays::slice::Slice::validity(array: &vortex_array::arrays::slice::SliceArray) -> vortex_error::VortexResult @@ -8112,12 +8124,12 @@ pub fn vortex_array::arrays::Struct::slot_name(array: &vortex_array::arrays::Str pub fn vortex_array::arrays::Struct::slots(array: &vortex_array::arrays::StructArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Struct::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Struct::stats(array: &vortex_array::arrays::StructArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Struct::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Struct::with_slots(array: &mut vortex_array::arrays::StructArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Struct pub fn vortex_array::arrays::Struct::validity(array: &vortex_array::arrays::StructArray) -> vortex_error::VortexResult @@ -8368,12 +8380,12 @@ pub fn vortex_array::arrays::VarBin::slot_name(_array: &vortex_array::arrays::Va pub fn vortex_array::arrays::VarBin::slots(array: &vortex_array::arrays::VarBinArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBin::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBin::stats(array: &vortex_array::arrays::VarBinArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBin::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBin::with_slots(array: &mut vortex_array::arrays::VarBinArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::VarBin pub fn vortex_array::arrays::VarBin::validity(array: &vortex_array::arrays::VarBinArray) -> vortex_error::VortexResult @@ -8596,12 +8608,12 @@ pub fn vortex_array::arrays::VarBinView::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::VarBinView::slots(array: &vortex_array::arrays::VarBinViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBinView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBinView::stats(array: &vortex_array::arrays::VarBinViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBinView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBinView::with_slots(array: &mut vortex_array::arrays::VarBinViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::VarBinView pub fn vortex_array::arrays::VarBinView::validity(array: &vortex_array::arrays::VarBinViewArray) -> vortex_error::VortexResult @@ -8786,12 +8798,12 @@ pub fn vortex_array::arrays::Variant::slot_name(_array: &Self::Array, idx: usize pub fn vortex_array::arrays::Variant::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Variant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Variant::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Variant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Variant::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Variant pub fn vortex_array::arrays::Variant::validity(array: &::Array) -> vortex_error::VortexResult @@ -21208,12 +21220,12 @@ pub fn vortex_array::vtable::ArrayVTable::slot_name(array: &Self::Array, idx: us pub fn vortex_array::vtable::ArrayVTable::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::vtable::ArrayVTable::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::vtable::ArrayVTable::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::vtable::ArrayVTable::vtable(array: &Self::Array) -> &Self -pub fn vortex_array::vtable::ArrayVTable::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Bool pub type vortex_array::arrays::Bool::Array = vortex_array::arrays::BoolArray @@ -21268,12 +21280,12 @@ pub fn vortex_array::arrays::Bool::slot_name(_array: &vortex_array::arrays::Bool pub fn vortex_array::arrays::Bool::slots(array: &vortex_array::arrays::BoolArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Bool::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Bool::stats(array: &vortex_array::arrays::BoolArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Bool::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Bool::with_slots(array: &mut vortex_array::arrays::BoolArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Chunked pub type vortex_array::arrays::Chunked::Array = vortex_array::arrays::ChunkedArray @@ -21328,12 +21340,12 @@ pub fn vortex_array::arrays::Chunked::slot_name(_array: &vortex_array::arrays::C pub fn vortex_array::arrays::Chunked::slots(array: &vortex_array::arrays::ChunkedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Chunked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Chunked::stats(array: &vortex_array::arrays::ChunkedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Chunked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Chunked::with_slots(array: &mut vortex_array::arrays::ChunkedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Constant pub type vortex_array::arrays::Constant::Array = vortex_array::arrays::ConstantArray @@ -21388,12 +21400,12 @@ pub fn vortex_array::arrays::Constant::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::Constant::slots(array: &vortex_array::arrays::ConstantArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Constant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Constant::stats(array: &vortex_array::arrays::ConstantArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Constant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Constant::with_slots(array: &mut vortex_array::arrays::ConstantArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Decimal pub type vortex_array::arrays::Decimal::Array = vortex_array::arrays::DecimalArray @@ -21448,12 +21460,12 @@ pub fn vortex_array::arrays::Decimal::slot_name(_array: &vortex_array::arrays::D pub fn vortex_array::arrays::Decimal::slots(array: &vortex_array::arrays::DecimalArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Decimal::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Decimal::stats(array: &vortex_array::arrays::DecimalArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Decimal::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Decimal::with_slots(array: &mut vortex_array::arrays::DecimalArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Extension pub type vortex_array::arrays::Extension::Array = vortex_array::arrays::ExtensionArray @@ -21508,12 +21520,12 @@ pub fn vortex_array::arrays::Extension::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Extension::slots(array: &vortex_array::arrays::ExtensionArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Extension::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Extension::stats(array: &vortex_array::arrays::ExtensionArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Extension::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Extension::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Filter pub type vortex_array::arrays::Filter::Array = vortex_array::arrays::FilterArray @@ -21568,12 +21580,12 @@ pub fn vortex_array::arrays::Filter::slot_name(_array: &Self::Array, idx: usize) pub fn vortex_array::arrays::Filter::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Filter::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Filter::stats(array: &vortex_array::arrays::FilterArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Filter::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Filter::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::FixedSizeList pub type vortex_array::arrays::FixedSizeList::Array = vortex_array::arrays::FixedSizeListArray @@ -21582,7 +21594,7 @@ pub type vortex_array::arrays::FixedSizeList::Metadata = vortex_array::EmptyMeta pub type vortex_array::arrays::FixedSizeList::OperationsVTable = vortex_array::arrays::FixedSizeList -pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::arrays::FixedSizeList pub fn vortex_array::arrays::FixedSizeList::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -21628,12 +21640,12 @@ pub fn vortex_array::arrays::FixedSizeList::slot_name(_array: &vortex_array::arr pub fn vortex_array::arrays::FixedSizeList::slots(array: &vortex_array::arrays::FixedSizeListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::FixedSizeList::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::FixedSizeList::stats(array: &vortex_array::arrays::FixedSizeListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::FixedSizeList::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::FixedSizeList::with_slots(array: &mut vortex_array::arrays::FixedSizeListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::List pub type vortex_array::arrays::List::Array = vortex_array::arrays::ListArray @@ -21642,7 +21654,7 @@ pub type vortex_array::arrays::List::Metadata = vortex_array::ProstMetadata vortex_error::VortexResult<()> @@ -21688,12 +21700,12 @@ pub fn vortex_array::arrays::List::slot_name(_array: &vortex_array::arrays::List pub fn vortex_array::arrays::List::slots(array: &vortex_array::arrays::ListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::List::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::List::stats(array: &vortex_array::arrays::ListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::List::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::List::with_slots(array: &mut vortex_array::arrays::ListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::ListView pub type vortex_array::arrays::ListView::Array = vortex_array::arrays::ListViewArray @@ -21702,7 +21714,7 @@ pub type vortex_array::arrays::ListView::Metadata = vortex_array::ProstMetadata< pub type vortex_array::arrays::ListView::OperationsVTable = vortex_array::arrays::ListView -pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::arrays::ListView pub fn vortex_array::arrays::ListView::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -21748,12 +21760,12 @@ pub fn vortex_array::arrays::ListView::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::ListView::slots(array: &vortex_array::arrays::ListViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::ListView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::ListView::stats(array: &vortex_array::arrays::ListViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::ListView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::ListView::with_slots(array: &mut vortex_array::arrays::ListViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Masked pub type vortex_array::arrays::Masked::Array = vortex_array::arrays::MaskedArray @@ -21808,12 +21820,12 @@ pub fn vortex_array::arrays::Masked::slot_name(_array: &vortex_array::arrays::Ma pub fn vortex_array::arrays::Masked::slots(array: &vortex_array::arrays::MaskedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Masked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Masked::stats(array: &vortex_array::arrays::MaskedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Masked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Masked::with_slots(array: &mut vortex_array::arrays::MaskedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Primitive pub type vortex_array::arrays::Primitive::Array = vortex_array::arrays::PrimitiveArray @@ -21868,12 +21880,12 @@ pub fn vortex_array::arrays::Primitive::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Primitive::slots(array: &vortex_array::arrays::PrimitiveArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Primitive::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Primitive::stats(array: &vortex_array::arrays::PrimitiveArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Primitive::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Primitive::with_slots(array: &mut vortex_array::arrays::PrimitiveArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Shared pub type vortex_array::arrays::Shared::Array = vortex_array::arrays::SharedArray @@ -21928,12 +21940,12 @@ pub fn vortex_array::arrays::Shared::slot_name(_array: &vortex_array::arrays::Sh pub fn vortex_array::arrays::Shared::slots(array: &vortex_array::arrays::SharedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Shared::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Shared::stats(array: &vortex_array::arrays::SharedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Shared::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Shared::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Struct pub type vortex_array::arrays::Struct::Array = vortex_array::arrays::StructArray @@ -21988,12 +22000,12 @@ pub fn vortex_array::arrays::Struct::slot_name(array: &vortex_array::arrays::Str pub fn vortex_array::arrays::Struct::slots(array: &vortex_array::arrays::StructArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Struct::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Struct::stats(array: &vortex_array::arrays::StructArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Struct::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Struct::with_slots(array: &mut vortex_array::arrays::StructArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::VarBin pub type vortex_array::arrays::VarBin::Array = vortex_array::arrays::VarBinArray @@ -22048,12 +22060,12 @@ pub fn vortex_array::arrays::VarBin::slot_name(_array: &vortex_array::arrays::Va pub fn vortex_array::arrays::VarBin::slots(array: &vortex_array::arrays::VarBinArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBin::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBin::stats(array: &vortex_array::arrays::VarBinArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBin::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBin::with_slots(array: &mut vortex_array::arrays::VarBinArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::VarBinView pub type vortex_array::arrays::VarBinView::Array = vortex_array::arrays::VarBinViewArray @@ -22108,12 +22120,12 @@ pub fn vortex_array::arrays::VarBinView::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::VarBinView::slots(array: &vortex_array::arrays::VarBinViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBinView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBinView::stats(array: &vortex_array::arrays::VarBinViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBinView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBinView::with_slots(array: &mut vortex_array::arrays::VarBinViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Variant pub type vortex_array::arrays::Variant::Array = vortex_array::arrays::variant::VariantArray @@ -22168,12 +22180,12 @@ pub fn vortex_array::arrays::Variant::slot_name(_array: &Self::Array, idx: usize pub fn vortex_array::arrays::Variant::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Variant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Variant::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Variant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Variant::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::dict::Dict pub type vortex_array::arrays::dict::Dict::Array = vortex_array::arrays::dict::DictArray @@ -22228,12 +22240,12 @@ pub fn vortex_array::arrays::dict::Dict::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::dict::Dict::slots(array: &vortex_array::arrays::dict::DictArray) -> &[core::option::Option] +pub fn vortex_array::arrays::dict::Dict::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::dict::Dict::stats(array: &vortex_array::arrays::dict::DictArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::dict::Dict::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::dict::Dict::with_slots(array: &mut vortex_array::arrays::dict::DictArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::null::Null pub type vortex_array::arrays::null::Null::Array = vortex_array::arrays::null::NullArray @@ -22288,12 +22300,12 @@ pub fn vortex_array::arrays::null::Null::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::null::Null::slots(array: &vortex_array::arrays::null::NullArray) -> &[core::option::Option] +pub fn vortex_array::arrays::null::Null::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::null::Null::stats(array: &vortex_array::arrays::null::NullArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::null::Null::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::null::Null::with_slots(array: &mut vortex_array::arrays::null::NullArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::patched::Patched pub type vortex_array::arrays::patched::Patched::Array = vortex_array::arrays::patched::PatchedArray @@ -22348,12 +22360,12 @@ pub fn vortex_array::arrays::patched::Patched::slot_name(_array: &Self::Array, i pub fn vortex_array::arrays::patched::Patched::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::patched::Patched::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::patched::Patched::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::patched::Patched::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::patched::Patched::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::Array = vortex_array::arrays::scalar_fn::ScalarFnArray @@ -22408,12 +22420,12 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: &vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> &[core::option::Option] +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::stats(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::vtable(array: &Self::Array) -> &Self -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::with_slots(array: &mut vortex_array::arrays::scalar_fn::ScalarFnArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::slice::Slice pub type vortex_array::arrays::slice::Slice::Array = vortex_array::arrays::slice::SliceArray @@ -22468,12 +22480,12 @@ pub fn vortex_array::arrays::slice::Slice::slot_name(_array: &Self::Array, idx: pub fn vortex_array::arrays::slice::Slice::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::slice::Slice::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::slice::Slice::stats(array: &vortex_array::arrays::slice::SliceArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::slice::Slice::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::slice::Slice::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - pub trait vortex_array::vtable::DynVTable: 'static + core::marker::Send + core::marker::Sync + core::fmt::Debug pub fn vortex_array::vtable::DynVTable::build(&self, id: vortex_array::vtable::ArrayId, dtype: &vortex_array::dtype::DType, len: usize, metadata: &[u8], buffers: &[vortex_array::buffer::BufferHandle], children: &dyn vortex_array::serde::ArrayChildren, session: &vortex_session::VortexSession) -> vortex_error::VortexResult @@ -22484,11 +22496,13 @@ pub fn vortex_array::vtable::DynVTable::execute(&self, array: vortex_array::Arra pub fn vortex_array::vtable::DynVTable::execute_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult> +pub fn vortex_array::vtable::DynVTable::put_slot(&self, array: &mut vortex_array::ArrayRef, slot_idx: usize, value: vortex_array::ArrayRef) + pub fn vortex_array::vtable::DynVTable::reduce(&self, array: &vortex_array::ArrayRef) -> vortex_error::VortexResult> pub fn vortex_array::vtable::DynVTable::reduce_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize) -> vortex_error::VortexResult> -pub fn vortex_array::vtable::DynVTable::with_slots(&self, array: vortex_array::ArrayRef, slots: alloc::vec::Vec>) -> vortex_error::VortexResult +pub fn vortex_array::vtable::DynVTable::take_slot(&self, array: &mut vortex_array::ArrayRef, slot_idx: usize) -> core::option::Option impl vortex_array::vtable::DynVTable for V @@ -22500,11 +22514,13 @@ pub fn V::execute(&self, array: vortex_array::ArrayRef, ctx: &mut vortex_array:: pub fn V::execute_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult> +pub fn V::put_slot(&self, array: &mut vortex_array::ArrayRef, slot_idx: usize, value: vortex_array::ArrayRef) + pub fn V::reduce(&self, array: &vortex_array::ArrayRef) -> vortex_error::VortexResult> pub fn V::reduce_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize) -> vortex_error::VortexResult> -pub fn V::with_slots(&self, array: vortex_array::ArrayRef, slots: alloc::vec::Vec>) -> vortex_error::VortexResult +pub fn V::take_slot(&self, array: &mut vortex_array::ArrayRef, slot_idx: usize) -> core::option::Option pub trait vortex_array::vtable::OperationsVTable @@ -22652,12 +22668,12 @@ pub fn vortex_array::vtable::VTable::slot_name(array: &Self::Array, idx: usize) pub fn vortex_array::vtable::VTable::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::vtable::VTable::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::vtable::VTable::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::vtable::VTable::vtable(array: &Self::Array) -> &Self -pub fn vortex_array::vtable::VTable::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Bool pub type vortex_array::arrays::Bool::Array = vortex_array::arrays::BoolArray @@ -22712,12 +22728,12 @@ pub fn vortex_array::arrays::Bool::slot_name(_array: &vortex_array::arrays::Bool pub fn vortex_array::arrays::Bool::slots(array: &vortex_array::arrays::BoolArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Bool::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Bool::stats(array: &vortex_array::arrays::BoolArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Bool::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Bool::with_slots(array: &mut vortex_array::arrays::BoolArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Chunked pub type vortex_array::arrays::Chunked::Array = vortex_array::arrays::ChunkedArray @@ -22772,12 +22788,12 @@ pub fn vortex_array::arrays::Chunked::slot_name(_array: &vortex_array::arrays::C pub fn vortex_array::arrays::Chunked::slots(array: &vortex_array::arrays::ChunkedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Chunked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Chunked::stats(array: &vortex_array::arrays::ChunkedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Chunked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Chunked::with_slots(array: &mut vortex_array::arrays::ChunkedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Constant pub type vortex_array::arrays::Constant::Array = vortex_array::arrays::ConstantArray @@ -22832,12 +22848,12 @@ pub fn vortex_array::arrays::Constant::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::Constant::slots(array: &vortex_array::arrays::ConstantArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Constant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Constant::stats(array: &vortex_array::arrays::ConstantArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Constant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Constant::with_slots(array: &mut vortex_array::arrays::ConstantArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Decimal pub type vortex_array::arrays::Decimal::Array = vortex_array::arrays::DecimalArray @@ -22892,12 +22908,12 @@ pub fn vortex_array::arrays::Decimal::slot_name(_array: &vortex_array::arrays::D pub fn vortex_array::arrays::Decimal::slots(array: &vortex_array::arrays::DecimalArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Decimal::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Decimal::stats(array: &vortex_array::arrays::DecimalArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Decimal::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Decimal::with_slots(array: &mut vortex_array::arrays::DecimalArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Extension pub type vortex_array::arrays::Extension::Array = vortex_array::arrays::ExtensionArray @@ -22952,12 +22968,12 @@ pub fn vortex_array::arrays::Extension::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Extension::slots(array: &vortex_array::arrays::ExtensionArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Extension::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Extension::stats(array: &vortex_array::arrays::ExtensionArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Extension::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Extension::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Filter pub type vortex_array::arrays::Filter::Array = vortex_array::arrays::FilterArray @@ -23012,12 +23028,12 @@ pub fn vortex_array::arrays::Filter::slot_name(_array: &Self::Array, idx: usize) pub fn vortex_array::arrays::Filter::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Filter::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Filter::stats(array: &vortex_array::arrays::FilterArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Filter::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Filter::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::FixedSizeList pub type vortex_array::arrays::FixedSizeList::Array = vortex_array::arrays::FixedSizeListArray @@ -23026,7 +23042,7 @@ pub type vortex_array::arrays::FixedSizeList::Metadata = vortex_array::EmptyMeta pub type vortex_array::arrays::FixedSizeList::OperationsVTable = vortex_array::arrays::FixedSizeList -pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::FixedSizeList::ValidityVTable = vortex_array::arrays::FixedSizeList pub fn vortex_array::arrays::FixedSizeList::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -23072,12 +23088,12 @@ pub fn vortex_array::arrays::FixedSizeList::slot_name(_array: &vortex_array::arr pub fn vortex_array::arrays::FixedSizeList::slots(array: &vortex_array::arrays::FixedSizeListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::FixedSizeList::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::FixedSizeList::stats(array: &vortex_array::arrays::FixedSizeListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::FixedSizeList::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::FixedSizeList::with_slots(array: &mut vortex_array::arrays::FixedSizeListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::List pub type vortex_array::arrays::List::Array = vortex_array::arrays::ListArray @@ -23086,7 +23102,7 @@ pub type vortex_array::arrays::List::Metadata = vortex_array::ProstMetadata vortex_error::VortexResult<()> @@ -23132,12 +23148,12 @@ pub fn vortex_array::arrays::List::slot_name(_array: &vortex_array::arrays::List pub fn vortex_array::arrays::List::slots(array: &vortex_array::arrays::ListArray) -> &[core::option::Option] +pub fn vortex_array::arrays::List::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::List::stats(array: &vortex_array::arrays::ListArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::List::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::List::with_slots(array: &mut vortex_array::arrays::ListArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::ListView pub type vortex_array::arrays::ListView::Array = vortex_array::arrays::ListViewArray @@ -23146,7 +23162,7 @@ pub type vortex_array::arrays::ListView::Metadata = vortex_array::ProstMetadata< pub type vortex_array::arrays::ListView::OperationsVTable = vortex_array::arrays::ListView -pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::vtable::ValidityVTableFromValidityHelper +pub type vortex_array::arrays::ListView::ValidityVTable = vortex_array::arrays::ListView pub fn vortex_array::arrays::ListView::append_to_builder(array: &Self::Array, builder: &mut dyn vortex_array::builders::ArrayBuilder, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<()> @@ -23192,12 +23208,12 @@ pub fn vortex_array::arrays::ListView::slot_name(_array: &vortex_array::arrays:: pub fn vortex_array::arrays::ListView::slots(array: &vortex_array::arrays::ListViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::ListView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::ListView::stats(array: &vortex_array::arrays::ListViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::ListView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::ListView::with_slots(array: &mut vortex_array::arrays::ListViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Masked pub type vortex_array::arrays::Masked::Array = vortex_array::arrays::MaskedArray @@ -23252,12 +23268,12 @@ pub fn vortex_array::arrays::Masked::slot_name(_array: &vortex_array::arrays::Ma pub fn vortex_array::arrays::Masked::slots(array: &vortex_array::arrays::MaskedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Masked::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Masked::stats(array: &vortex_array::arrays::MaskedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Masked::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Masked::with_slots(array: &mut vortex_array::arrays::MaskedArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Primitive pub type vortex_array::arrays::Primitive::Array = vortex_array::arrays::PrimitiveArray @@ -23312,12 +23328,12 @@ pub fn vortex_array::arrays::Primitive::slot_name(_array: &vortex_array::arrays: pub fn vortex_array::arrays::Primitive::slots(array: &vortex_array::arrays::PrimitiveArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Primitive::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Primitive::stats(array: &vortex_array::arrays::PrimitiveArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Primitive::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Primitive::with_slots(array: &mut vortex_array::arrays::PrimitiveArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Shared pub type vortex_array::arrays::Shared::Array = vortex_array::arrays::SharedArray @@ -23372,12 +23388,12 @@ pub fn vortex_array::arrays::Shared::slot_name(_array: &vortex_array::arrays::Sh pub fn vortex_array::arrays::Shared::slots(array: &vortex_array::arrays::SharedArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Shared::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Shared::stats(array: &vortex_array::arrays::SharedArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Shared::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Shared::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Struct pub type vortex_array::arrays::Struct::Array = vortex_array::arrays::StructArray @@ -23432,12 +23448,12 @@ pub fn vortex_array::arrays::Struct::slot_name(array: &vortex_array::arrays::Str pub fn vortex_array::arrays::Struct::slots(array: &vortex_array::arrays::StructArray) -> &[core::option::Option] +pub fn vortex_array::arrays::Struct::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Struct::stats(array: &vortex_array::arrays::StructArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Struct::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Struct::with_slots(array: &mut vortex_array::arrays::StructArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::VarBin pub type vortex_array::arrays::VarBin::Array = vortex_array::arrays::VarBinArray @@ -23492,12 +23508,12 @@ pub fn vortex_array::arrays::VarBin::slot_name(_array: &vortex_array::arrays::Va pub fn vortex_array::arrays::VarBin::slots(array: &vortex_array::arrays::VarBinArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBin::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBin::stats(array: &vortex_array::arrays::VarBinArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBin::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBin::with_slots(array: &mut vortex_array::arrays::VarBinArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::VarBinView pub type vortex_array::arrays::VarBinView::Array = vortex_array::arrays::VarBinViewArray @@ -23552,12 +23568,12 @@ pub fn vortex_array::arrays::VarBinView::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::VarBinView::slots(array: &vortex_array::arrays::VarBinViewArray) -> &[core::option::Option] +pub fn vortex_array::arrays::VarBinView::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::VarBinView::stats(array: &vortex_array::arrays::VarBinViewArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::VarBinView::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::VarBinView::with_slots(array: &mut vortex_array::arrays::VarBinViewArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::Variant pub type vortex_array::arrays::Variant::Array = vortex_array::arrays::variant::VariantArray @@ -23612,12 +23628,12 @@ pub fn vortex_array::arrays::Variant::slot_name(_array: &Self::Array, idx: usize pub fn vortex_array::arrays::Variant::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::Variant::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::Variant::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::Variant::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::Variant::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::dict::Dict pub type vortex_array::arrays::dict::Dict::Array = vortex_array::arrays::dict::DictArray @@ -23672,12 +23688,12 @@ pub fn vortex_array::arrays::dict::Dict::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::dict::Dict::slots(array: &vortex_array::arrays::dict::DictArray) -> &[core::option::Option] +pub fn vortex_array::arrays::dict::Dict::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::dict::Dict::stats(array: &vortex_array::arrays::dict::DictArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::dict::Dict::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::dict::Dict::with_slots(array: &mut vortex_array::arrays::dict::DictArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::null::Null pub type vortex_array::arrays::null::Null::Array = vortex_array::arrays::null::NullArray @@ -23732,12 +23748,12 @@ pub fn vortex_array::arrays::null::Null::slot_name(_array: &vortex_array::arrays pub fn vortex_array::arrays::null::Null::slots(array: &vortex_array::arrays::null::NullArray) -> &[core::option::Option] +pub fn vortex_array::arrays::null::Null::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::null::Null::stats(array: &vortex_array::arrays::null::NullArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::null::Null::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::null::Null::with_slots(array: &mut vortex_array::arrays::null::NullArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::patched::Patched pub type vortex_array::arrays::patched::Patched::Array = vortex_array::arrays::patched::PatchedArray @@ -23792,12 +23808,12 @@ pub fn vortex_array::arrays::patched::Patched::slot_name(_array: &Self::Array, i pub fn vortex_array::arrays::patched::Patched::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::patched::Patched::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::patched::Patched::stats(array: &Self::Array) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::patched::Patched::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::patched::Patched::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::Array = vortex_array::arrays::scalar_fn::ScalarFnArray @@ -23852,12 +23868,12 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: &vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> &[core::option::Option] +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::stats(array: &vortex_array::arrays::scalar_fn::ScalarFnArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::vtable(array: &Self::Array) -> &Self -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::with_slots(array: &mut vortex_array::arrays::scalar_fn::ScalarFnArray, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - impl vortex_array::vtable::VTable for vortex_array::arrays::slice::Slice pub type vortex_array::arrays::slice::Slice::Array = vortex_array::arrays::slice::SliceArray @@ -23912,12 +23928,12 @@ pub fn vortex_array::arrays::slice::Slice::slot_name(_array: &Self::Array, idx: pub fn vortex_array::arrays::slice::Slice::slots(array: &Self::Array) -> &[core::option::Option] +pub fn vortex_array::arrays::slice::Slice::slots_mut(array: &mut Self::Array) -> &mut [core::option::Option] + pub fn vortex_array::arrays::slice::Slice::stats(array: &vortex_array::arrays::slice::SliceArray) -> vortex_array::stats::StatsSetRef<'_> pub fn vortex_array::arrays::slice::Slice::vtable(_array: &Self::Array) -> &Self -pub fn vortex_array::arrays::slice::Slice::with_slots(array: &mut Self::Array, slots: alloc::vec::Vec>) -> vortex_error::VortexResult<()> - pub trait vortex_array::vtable::ValidityChild pub fn vortex_array::vtable::ValidityChild::validity_child(array: &::Array) -> &vortex_array::ArrayRef @@ -23940,18 +23956,6 @@ pub trait vortex_array::vtable::ValidityHelper pub fn vortex_array::vtable::ValidityHelper::validity(&self) -> vortex_array::validity::Validity -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::FixedSizeListArray - -pub fn vortex_array::arrays::FixedSizeListArray::validity(&self) -> vortex_array::validity::Validity - -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::ListArray - -pub fn vortex_array::arrays::ListArray::validity(&self) -> vortex_array::validity::Validity - -impl vortex_array::vtable::ValidityHelper for vortex_array::arrays::ListViewArray - -pub fn vortex_array::arrays::ListViewArray::validity(&self) -> vortex_array::validity::Validity - pub trait vortex_array::vtable::ValiditySliceHelper pub fn vortex_array::vtable::ValiditySliceHelper::sliced_validity(&self) -> vortex_error::VortexResult @@ -23982,6 +23986,18 @@ impl vortex_array::vtable::ValidityVTable for vort pub fn vortex_array::arrays::Filter::validity(array: &vortex_array::arrays::FilterArray) -> vortex_error::VortexResult +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::FixedSizeList + +pub fn vortex_array::arrays::FixedSizeList::validity(array: &vortex_array::arrays::FixedSizeListArray) -> vortex_error::VortexResult + +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::List + +pub fn vortex_array::arrays::List::validity(array: &vortex_array::arrays::ListArray) -> vortex_error::VortexResult + +impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::ListView + +pub fn vortex_array::arrays::ListView::validity(array: &vortex_array::arrays::ListViewArray) -> vortex_error::VortexResult + impl vortex_array::vtable::ValidityVTable for vortex_array::arrays::Masked pub fn vortex_array::arrays::Masked::validity(array: &vortex_array::arrays::MaskedArray) -> vortex_error::VortexResult diff --git a/vortex-array/src/aggregate_fn/accumulator_grouped.rs b/vortex-array/src/aggregate_fn/accumulator_grouped.rs index 83b945708b2..5d67df36263 100644 --- a/vortex-array/src/aggregate_fn/accumulator_grouped.rs +++ b/vortex-array/src/aggregate_fn/accumulator_grouped.rs @@ -33,7 +33,6 @@ use crate::dtype::DType; use crate::dtype::IntegerPType; use crate::executor::MAX_ITERATIONS; use crate::match_each_integer_ptype; -use crate::vtable::ValidityHelper; /// Reference-counted type-erased grouped accumulator. pub type GroupedAccumulatorRef = Box; diff --git a/vortex-array/src/array/mod.rs b/vortex-array/src/array/mod.rs index 95643eff95d..4100bec4f45 100644 --- a/vortex-array/src/array/mod.rs +++ b/vortex-array/src/array/mod.rs @@ -345,25 +345,20 @@ impl dyn DynArray + '_ { self.is::() } - /// Returns a new array with the slot at `slot_idx` replaced by `replacement`. + /// Take a child out of a slot, setting it to `None`. /// - /// Takes ownership to allow in-place mutation when the refcount is 1. - pub fn with_slot( - self: ArrayRef, - slot_idx: usize, - replacement: ArrayRef, - ) -> VortexResult { - let nslots = self.slots().len(); - vortex_ensure!( - slot_idx < nslots, - "slot index {} out of bounds for array with {} slots", - slot_idx, - nslots - ); - let mut slots = self.slots().to_vec(); - slots[slot_idx] = Some(replacement); + /// Requires unique ownership of the `ArrayRef` (panics if Arc refcount > 1). + pub fn take_slot(self: &mut ArrayRef, slot_idx: usize) -> Option { + let vtable = self.vtable().clone_boxed(); + vtable.take_slot(self, slot_idx) + } + + /// Put a child into a slot, replacing whatever was there. + /// + /// Requires unique ownership of the `ArrayRef` (panics if Arc refcount > 1). + pub fn put_slot(self: &mut ArrayRef, slot_idx: usize, value: ArrayRef) { let vtable = self.vtable().clone_boxed(); - vtable.with_slots(self, slots) + vtable.put_slot(self, slot_idx, value); } } diff --git a/vortex-array/src/arrays/bool/vtable/mod.rs b/vortex-array/src/arrays/bool/vtable/mod.rs index 5fa24c02778..136033826ac 100644 --- a/vortex-array/src/arrays/bool/vtable/mod.rs +++ b/vortex-array/src/arrays/bool/vtable/mod.rs @@ -7,7 +7,6 @@ use kernel::PARENT_KERNELS; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -18,7 +17,6 @@ use crate::ExecutionResult; use crate::ProstMetadata; use crate::SerializeMetadata; use crate::arrays::BoolArray; -use crate::arrays::bool::array::NUM_SLOTS; use crate::arrays::bool::array::SLOT_NAMES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -166,15 +164,8 @@ impl VTable for Bool { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut BoolArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "BoolArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/chunked/tests.rs b/vortex-array/src/arrays/chunked/tests.rs index a4c169ad474..606fe8daf9e 100644 --- a/vortex-array/src/arrays/chunked/tests.rs +++ b/vortex-array/src/arrays/chunked/tests.rs @@ -198,31 +198,25 @@ pub fn pack_nested_lists() { } #[test] -fn with_slots_updates_nchunks_len_and_offsets() { +fn slots_mut_replaces_individual_chunk() { let mut array = chunked_array(); - let slots = vec![ - Some(buffer![0u64, 4, 9].into_array()), - Some(buffer![10u64, 11, 12, 13].into_array()), - Some(buffer![14u64, 15, 16, 17, 18].into_array()), - ]; - let expected_nchunks = slots.len() - 1; - let expected_len = array.len(); - - ::with_slots(&mut array, slots).unwrap(); - - assert_eq!(array.nchunks(), expected_nchunks); - assert_eq!(array.len(), expected_len); - assert_eq!(array.chunk_offsets(), buffer![0u64, 4, 9]); + // Replace the second chunk (slot index 2, after offsets at 0 and first chunk at 1) + let replacement = buffer![10u64, 11, 12].into_array(); + + let slots = ::slots_mut(&mut array); + slots[2] = Some(replacement); + assert_arrays_eq!( - array.chunk(0).clone(), - PrimitiveArray::from_iter([10u64, 11, 12, 13]) + array.chunk(1).clone(), + PrimitiveArray::from_iter([10u64, 11, 12]) ); + // Other chunks unchanged assert_arrays_eq!( - array.chunk(1).clone(), - PrimitiveArray::from_iter([14u64, 15, 16, 17, 18]) + array.chunk(0).clone(), + PrimitiveArray::from_iter([1u64, 2, 3]) ); assert_arrays_eq!( - array, - PrimitiveArray::from_iter([10u64, 11, 12, 13, 14, 15, 16, 17, 18]) + array.chunk(2).clone(), + PrimitiveArray::from_iter([7u64, 8, 9]) ); } diff --git a/vortex-array/src/arrays/chunked/vtable/mod.rs b/vortex-array/src/arrays/chunked/vtable/mod.rs index e110d2542cf..b2523cd29cd 100644 --- a/vortex-array/src/arrays/chunked/vtable/mod.rs +++ b/vortex-array/src/arrays/chunked/vtable/mod.rs @@ -7,7 +7,6 @@ use std::sync::Arc; use itertools::Itertools; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -218,69 +217,8 @@ impl VTable for Chunked { } } - fn with_slots(array: &mut ChunkedArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!(!slots.is_empty(), "Chunked array needs at least one slot"); - - let chunk_offsets = slots[0] - .as_ref() - .ok_or_else(|| vortex_err!("Chunked array chunk_offsets slot must be present"))?; - let chunk_offsets_dtype = DType::Primitive(PType::U64, Nullability::NonNullable); - vortex_ensure!( - chunk_offsets.dtype() == &chunk_offsets_dtype, - MismatchedTypes: &chunk_offsets_dtype, - chunk_offsets.dtype() - ); - - #[cfg(debug_assertions)] - { - let chunk_offsets = chunk_offsets - .as_opt::() - .unwrap_or_else(|| { - vortex_panic!("Chunked array chunk_offsets slot must be primitive") - }); - let chunk_offsets_buf = chunk_offsets.to_buffer::(); - debug_assert_eq!( - chunk_offsets_buf.len(), - slots.len(), - "Expected {} chunk offsets, found {}", - slots.len(), - chunk_offsets_buf.len(), - ); - debug_assert_eq!( - chunk_offsets_buf.last().copied().unwrap_or_default(), - array.len as u64, - "Chunked array replacement changed logical len: expected {}, got {}", - array.len, - chunk_offsets_buf.last().copied().unwrap_or_default(), - ); - - let mut total_len = 0usize; - - for (idx, chunk_slot) in slots[1..].iter().enumerate() { - let chunk = chunk_slot.as_ref().unwrap_or_else(|| { - vortex_panic!("Chunked array chunk slot {idx} must be present") - }); - debug_assert!( - chunk.dtype() == array.dtype(), - "Chunked array chunk slot {} has dtype {:?}, expected {:?}", - idx, - chunk.dtype(), - array.dtype(), - ); - total_len = total_len.checked_add(chunk.len()).unwrap_or_else(|| { - vortex_panic!("Chunked array chunk lengths exceed usize range") - }); - } - - debug_assert_eq!( - total_len, array.len, - "Chunked array replacement changed logical len: expected {}, got {}", - array.len, total_len, - ); - } - - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn reduce(array: &Array) -> VortexResult> { diff --git a/vortex-array/src/arrays/constant/array.rs b/vortex-array/src/arrays/constant/array.rs index b6c29077374..d8a3759bad0 100644 --- a/vortex-array/src/arrays/constant/array.rs +++ b/vortex-array/src/arrays/constant/array.rs @@ -5,8 +5,6 @@ use crate::ArrayRef; use crate::scalar::Scalar; use crate::stats::ArrayStats; -pub(super) const NUM_SLOTS: usize = 0; - #[derive(Clone, Debug)] pub struct ConstantArray { pub(super) scalar: Scalar, diff --git a/vortex-array/src/arrays/constant/vtable/canonical.rs b/vortex-array/src/arrays/constant/vtable/canonical.rs index 1b17c76054b..71f69ae51a9 100644 --- a/vortex-array/src/arrays/constant/vtable/canonical.rs +++ b/vortex-array/src/arrays/constant/vtable/canonical.rs @@ -335,7 +335,6 @@ mod tests { use crate::expr::stats::StatsProvider; use crate::scalar::Scalar; use crate::validity::Validity; - use crate::vtable::ValidityHelper; #[test] fn test_canonicalize_null() { diff --git a/vortex-array/src/arrays/constant/vtable/mod.rs b/vortex-array/src/arrays/constant/vtable/mod.rs index 11c9e9b96b7..0924f614d18 100644 --- a/vortex-array/src/arrays/constant/vtable/mod.rs +++ b/vortex-array/src/arrays/constant/vtable/mod.rs @@ -18,7 +18,6 @@ use crate::ExecutionResult; use crate::IntoArray; use crate::Precision; use crate::arrays::ConstantArray; -use crate::arrays::constant::array::NUM_SLOTS; use crate::arrays::constant::compute::rules::PARENT_RULES; use crate::arrays::constant::vtable::canonical::constant_canonicalize; use crate::buffer::BufferHandle; @@ -122,15 +121,8 @@ impl VTable for Constant { vortex_panic!("ConstantArray slot_name index {idx} out of bounds") } - fn with_slots(array: &mut ConstantArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ConstantArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn metadata(array: &ConstantArray) -> VortexResult { diff --git a/vortex-array/src/arrays/decimal/vtable/mod.rs b/vortex-array/src/arrays/decimal/vtable/mod.rs index 8125dd85ea9..2bd90f28d88 100644 --- a/vortex-array/src/arrays/decimal/vtable/mod.rs +++ b/vortex-array/src/arrays/decimal/vtable/mod.rs @@ -18,7 +18,6 @@ use crate::ExecutionResult; use crate::ProstMetadata; use crate::SerializeMetadata; use crate::arrays::DecimalArray; -use crate::arrays::decimal::array::NUM_SLOTS; use crate::arrays::decimal::array::SLOT_NAMES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -183,15 +182,8 @@ impl VTable for Decimal { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut DecimalArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "DecimalArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/dict/vtable/mod.rs b/vortex-array/src/arrays/dict/vtable/mod.rs index d9bfdcefc8c..7bcf046ed97 100644 --- a/vortex-array/src/arrays/dict/vtable/mod.rs +++ b/vortex-array/src/arrays/dict/vtable/mod.rs @@ -8,7 +8,6 @@ use kernel::PARENT_KERNELS; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -16,7 +15,6 @@ use vortex_session::VortexSession; use super::DictArray; use super::DictArrayParts; use super::DictMetadata; -use super::array::NUM_SLOTS; use super::array::SLOT_NAMES; use super::take_canonical; use crate::AnyCanonical; @@ -178,15 +176,8 @@ impl VTable for Dict { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut DictArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "DictArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/extension/vtable/mod.rs b/vortex-array/src/arrays/extension/vtable/mod.rs index 15fa12aae2e..c34e2e2acec 100644 --- a/vortex-array/src/arrays/extension/vtable/mod.rs +++ b/vortex-array/src/arrays/extension/vtable/mod.rs @@ -11,7 +11,6 @@ use std::sync::Arc; use kernel::PARENT_KERNELS; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -21,7 +20,6 @@ use crate::ExecutionCtx; use crate::ExecutionResult; use crate::Precision; use crate::arrays::ExtensionArray; -use crate::arrays::extension::array::NUM_SLOTS; use crate::arrays::extension::array::SLOT_NAMES; use crate::arrays::extension::compute::rules::PARENT_RULES; use crate::buffer::BufferHandle; @@ -136,15 +134,8 @@ impl VTable for Extension { Ok(ExtensionArray::new(ext_dtype.clone(), storage)) } - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ExtensionArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/filter/execute/fixed_size_list.rs b/vortex-array/src/arrays/filter/execute/fixed_size_list.rs index aede1ae550b..0d50f7b6e6a 100644 --- a/vortex-array/src/arrays/filter/execute/fixed_size_list.rs +++ b/vortex-array/src/arrays/filter/execute/fixed_size_list.rs @@ -10,7 +10,6 @@ use vortex_mask::MaskValues; use crate::arrays::FixedSizeListArray; use crate::arrays::filter::execute::filter_validity; -use crate::vtable::ValidityHelper; /// Density threshold for choosing between indices and slices representation when expanding masks. /// diff --git a/vortex-array/src/arrays/filter/execute/listview.rs b/vortex-array/src/arrays/filter/execute/listview.rs index 9459b710a72..35f02cecf58 100644 --- a/vortex-array/src/arrays/filter/execute/listview.rs +++ b/vortex-array/src/arrays/filter/execute/listview.rs @@ -10,7 +10,6 @@ use crate::arrays::ListViewArray; use crate::arrays::filter::execute::filter_validity; use crate::arrays::filter::execute::values_to_mask; use crate::arrays::listview::ListViewRebuildMode; -use crate::vtable::ValidityHelper; // TODO(connor)[ListView]: Make use of this threshold after we start migrating operators. /// The threshold for triggering a rebuild of the [`ListViewArray`]. diff --git a/vortex-array/src/arrays/filter/vtable.rs b/vortex-array/src/arrays/filter/vtable.rs index 618908b7301..f0e921b20c1 100644 --- a/vortex-array/src/arrays/filter/vtable.rs +++ b/vortex-array/src/arrays/filter/vtable.rs @@ -8,7 +8,6 @@ use std::sync::Arc; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_mask::Mask; use vortex_session::VortexSession; @@ -20,7 +19,6 @@ use crate::DynArray; use crate::IntoArray; use crate::Precision; use crate::arrays::filter::array::FilterArray; -use crate::arrays::filter::array::NUM_SLOTS; use crate::arrays::filter::array::SLOT_NAMES; use crate::arrays::filter::execute::execute_filter; use crate::arrays::filter::execute::execute_filter_fast_paths; @@ -136,15 +134,8 @@ impl VTable for Filter { FilterArray::try_new(child, metadata.0.clone()) } - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "FilterArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/fixed_size_list/array.rs b/vortex-array/src/arrays/fixed_size_list/array.rs index ff3a8d73db3..fd227e281e5 100644 --- a/vortex-array/src/arrays/fixed_size_list/array.rs +++ b/vortex-array/src/arrays/fixed_size_list/array.rs @@ -12,6 +12,7 @@ use crate::DynArray; use crate::dtype::DType; use crate::stats::ArrayStats; use crate::validity::Validity; +use crate::vtable::child_to_validity; use crate::vtable::validity_to_child; /// The `elements` data array, where each fixed-size list scalar is a _slice_ of the `elements` @@ -91,13 +92,6 @@ pub struct FixedSizeListArray { /// We store the size of each fixed-size list in the array as a field for convenience. list_size: u32, - /// The validity / null map of the array. - /// - /// Note that this null map refers to which fixed-size list scalars are null, **not** which - /// sub-elements of fixed-size list scalars are null. The `elements` array will track individual - /// value nullability. - pub(super) validity: Validity, - /// The length of the array. /// /// Note that this is different from the size of each fixed-size list scalar (`list_size`). @@ -176,18 +170,19 @@ impl FixedSizeListArray { dtype: DType::FixedSizeList(Arc::new(elements.dtype().clone()), list_size, nullability), slots: vec![Some(elements), validity_slot], list_size, - validity, len, stats_set: Default::default(), } } + /// Returns the parts of this array. pub fn into_parts(mut self) -> (ArrayRef, Validity, DType) { + let validity = self.validity(); ( self.slots[ELEMENTS_SLOT] .take() .vortex_expect("FixedSizeListArray elements slot"), - self.validity, + validity, self.dtype, ) } @@ -228,6 +223,11 @@ impl FixedSizeListArray { Ok(()) } + /// Returns the [`Validity`] of the array, computed on demand from the validity slot. + pub fn validity(&self) -> Validity { + child_to_validity(&self.slots[VALIDITY_SLOT], self.dtype.nullability()) + } + /// Returns the elements array. pub fn elements(&self) -> &ArrayRef { self.slots[ELEMENTS_SLOT] @@ -252,7 +252,7 @@ impl FixedSizeListArray { index, self.len, ); - debug_assert!(self.validity.is_valid(index).unwrap_or(false)); + debug_assert!(self.validity().is_valid(index).unwrap_or(false)); let start = self.list_size as usize * index; let end = self.list_size as usize * (index + 1); diff --git a/vortex-array/src/arrays/fixed_size_list/compute/cast.rs b/vortex-array/src/arrays/fixed_size_list/compute/cast.rs index 1fce99ad918..f6fc6ac774f 100644 --- a/vortex-array/src/arrays/fixed_size_list/compute/cast.rs +++ b/vortex-array/src/arrays/fixed_size_list/compute/cast.rs @@ -10,7 +10,6 @@ use crate::arrays::FixedSizeListArray; use crate::builtins::ArrayBuiltins; use crate::dtype::DType; use crate::scalar_fn::fns::cast::CastReduce; -use crate::vtable::ValidityHelper; /// Cast implementation for [`FixedSizeListArray`]. /// diff --git a/vortex-array/src/arrays/fixed_size_list/compute/mask.rs b/vortex-array/src/arrays/fixed_size_list/compute/mask.rs index bc4f44f75de..8c0624bfe5e 100644 --- a/vortex-array/src/arrays/fixed_size_list/compute/mask.rs +++ b/vortex-array/src/arrays/fixed_size_list/compute/mask.rs @@ -9,7 +9,6 @@ use crate::arrays::FixedSizeList; use crate::arrays::FixedSizeListArray; use crate::scalar_fn::fns::mask::MaskReduce; use crate::validity::Validity; -use crate::vtable::ValidityHelper; impl MaskReduce for FixedSizeList { fn mask(array: &FixedSizeListArray, mask: &ArrayRef) -> VortexResult> { diff --git a/vortex-array/src/arrays/fixed_size_list/compute/slice.rs b/vortex-array/src/arrays/fixed_size_list/compute/slice.rs index 9db5d8a7c08..f749da0efad 100644 --- a/vortex-array/src/arrays/fixed_size_list/compute/slice.rs +++ b/vortex-array/src/arrays/fixed_size_list/compute/slice.rs @@ -10,7 +10,6 @@ use crate::IntoArray; use crate::arrays::FixedSizeList; use crate::arrays::FixedSizeListArray; use crate::arrays::slice::SliceReduce; -use crate::vtable::ValidityHelper; impl SliceReduce for FixedSizeList { fn slice(array: &Self::Array, range: Range) -> VortexResult> { diff --git a/vortex-array/src/arrays/fixed_size_list/compute/take.rs b/vortex-array/src/arrays/fixed_size_list/compute/take.rs index b38d10fc2bb..91d2a41dcaa 100644 --- a/vortex-array/src/arrays/fixed_size_list/compute/take.rs +++ b/vortex-array/src/arrays/fixed_size_list/compute/take.rs @@ -19,7 +19,6 @@ use crate::executor::ExecutionCtx; use crate::match_each_integer_ptype; use crate::match_smallest_offset_type; use crate::validity::Validity; -use crate::vtable::ValidityHelper; /// Take implementation for [`FixedSizeListArray`]. /// diff --git a/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs b/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs index c8b7030505d..d058117f743 100644 --- a/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs +++ b/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs @@ -16,9 +16,7 @@ use crate::ExecutionCtx; use crate::ExecutionResult; use crate::Precision; use crate::arrays::FixedSizeListArray; -use crate::arrays::fixed_size_list::array::NUM_SLOTS; use crate::arrays::fixed_size_list::array::SLOT_NAMES; -use crate::arrays::fixed_size_list::array::VALIDITY_SLOT; use crate::arrays::fixed_size_list::compute::rules::PARENT_RULES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -31,7 +29,6 @@ use crate::vtable; use crate::vtable::Array; use crate::vtable::ArrayId; use crate::vtable::VTable; -use crate::vtable::ValidityVTableFromValidityHelper; mod kernel; mod operations; mod validity; @@ -50,7 +47,7 @@ impl VTable for FixedSizeList { type Metadata = EmptyMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromValidityHelper; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &FixedSizeList } @@ -79,7 +76,7 @@ impl VTable for FixedSizeList { array.dtype.hash(state); array.elements().array_hash(state, precision); array.list_size().hash(state); - array.validity.array_hash(state, precision); + array.validity().array_hash(state, precision); array.len.hash(state); } @@ -91,7 +88,7 @@ impl VTable for FixedSizeList { array.dtype == other.dtype && array.elements().array_eq(other.elements(), precision) && array.list_size() == other.list_size() - && array.validity.array_eq(&other.validity, precision) + && array.validity().array_eq(&other.validity(), precision) && array.len == other.len } @@ -189,22 +186,8 @@ impl VTable for FixedSizeList { SLOT_NAMES[idx].to_string() } - fn with_slots( - array: &mut FixedSizeListArray, - slots: Vec>, - ) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "FixedSizeListArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.validity = match &slots[VALIDITY_SLOT] { - Some(arr) => Validity::Array(arr.clone()), - None => Validity::from(array.dtype.nullability()), - }; - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/fixed_size_list/vtable/validity.rs b/vortex-array/src/arrays/fixed_size_list/vtable/validity.rs index 75f84728eac..991488ced02 100644 --- a/vortex-array/src/arrays/fixed_size_list/vtable/validity.rs +++ b/vortex-array/src/arrays/fixed_size_list/vtable/validity.rs @@ -1,12 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +use vortex_error::VortexResult; + +use crate::arrays::fixed_size_list::vtable::FixedSizeList; use crate::arrays::fixed_size_list::vtable::FixedSizeListArray; use crate::validity::Validity; -use crate::vtable::ValidityHelper; +use crate::vtable::ValidityVTable; -impl ValidityHelper for FixedSizeListArray { - fn validity(&self) -> Validity { - self.validity.clone() +impl ValidityVTable for FixedSizeList { + fn validity(array: &FixedSizeListArray) -> VortexResult { + Ok(array.validity()) } } diff --git a/vortex-array/src/arrays/list/array.rs b/vortex-array/src/arrays/list/array.rs index c9bed8c7012..c8a48a2ae59 100644 --- a/vortex-array/src/arrays/list/array.rs +++ b/vortex-array/src/arrays/list/array.rs @@ -27,6 +27,7 @@ use crate::match_each_native_ptype; use crate::scalar_fn::fns::operators::Operator; use crate::stats::ArrayStats; use crate::validity::Validity; +use crate::vtable::child_to_validity; use crate::vtable::validity_to_child; /// The elements data array containing all list elements concatenated together. @@ -94,7 +95,6 @@ pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = ["elements", "offsets", "validi pub struct ListArray { pub(super) dtype: DType, pub(super) slots: Vec>, - pub(super) validity: Validity, pub(super) stats_set: ArrayStats, } @@ -162,7 +162,6 @@ impl ListArray { Self { dtype: DType::List(Arc::new(elements.dtype().clone()), validity.nullability()), slots: vec![Some(elements), Some(offsets), validity_slot], - validity, stats_set: Default::default(), } } @@ -254,6 +253,7 @@ impl ListArray { /// Splits an array into its parts pub fn into_parts(mut self) -> ListArrayParts { + let validity = self.validity(); ListArrayParts { dtype: self.dtype, elements: self.slots[ELEMENTS_SLOT] @@ -262,7 +262,7 @@ impl ListArray { offsets: self.slots[OFFSETS_SLOT] .take() .vortex_expect("ListArray offsets slot"), - validity: self.validity, + validity, } } @@ -321,6 +321,11 @@ impl ListArray { } } + /// Returns the validity of the list array, computed on demand from the validity slot. + pub fn validity(&self) -> Validity { + child_to_validity(&self.slots[VALIDITY_SLOT], self.dtype.nullability()) + } + /// Returns the elements array. pub fn elements(&self) -> &ArrayRef { self.slots[ELEMENTS_SLOT] @@ -350,6 +355,6 @@ impl ListArray { Operator::Sub, )?; - Self::try_new(elements, adjusted_offsets, self.validity.clone()) + Self::try_new(elements, adjusted_offsets, self.validity()) } } diff --git a/vortex-array/src/arrays/list/compute/cast.rs b/vortex-array/src/arrays/list/compute/cast.rs index e0879c2e906..f050f726289 100644 --- a/vortex-array/src/arrays/list/compute/cast.rs +++ b/vortex-array/src/arrays/list/compute/cast.rs @@ -10,7 +10,6 @@ use crate::arrays::ListArray; use crate::builtins::ArrayBuiltins; use crate::dtype::DType; use crate::scalar_fn::fns::cast::CastReduce; -use crate::vtable::ValidityHelper; impl CastReduce for List { fn cast(array: &ListArray, dtype: &DType) -> VortexResult> { diff --git a/vortex-array/src/arrays/list/compute/filter.rs b/vortex-array/src/arrays/list/compute/filter.rs index e2691c0e82e..726225726fb 100644 --- a/vortex-array/src/arrays/list/compute/filter.rs +++ b/vortex-array/src/arrays/list/compute/filter.rs @@ -23,7 +23,6 @@ use crate::arrays::filter::FilterKernel; use crate::dtype::IntegerPType; use crate::match_each_integer_ptype; use crate::validity::Validity; -use crate::vtable::ValidityHelper; /// Density threshold for choosing between indices and slices representation when expanding masks. /// diff --git a/vortex-array/src/arrays/list/compute/mask.rs b/vortex-array/src/arrays/list/compute/mask.rs index 565540dd7db..ebda15d605e 100644 --- a/vortex-array/src/arrays/list/compute/mask.rs +++ b/vortex-array/src/arrays/list/compute/mask.rs @@ -9,7 +9,6 @@ use crate::arrays::List; use crate::arrays::ListArray; use crate::scalar_fn::fns::mask::MaskReduce; use crate::validity::Validity; -use crate::vtable::ValidityHelper; impl MaskReduce for List { fn mask(array: &ListArray, mask: &ArrayRef) -> VortexResult> { diff --git a/vortex-array/src/arrays/list/compute/slice.rs b/vortex-array/src/arrays/list/compute/slice.rs index 46c571773ef..47d1589290e 100644 --- a/vortex-array/src/arrays/list/compute/slice.rs +++ b/vortex-array/src/arrays/list/compute/slice.rs @@ -10,7 +10,6 @@ use crate::IntoArray; use crate::arrays::List; use crate::arrays::ListArray; use crate::arrays::slice::SliceReduce; -use crate::vtable::ValidityHelper; impl SliceReduce for List { fn slice(array: &Self::Array, range: Range) -> VortexResult> { diff --git a/vortex-array/src/arrays/list/compute/take.rs b/vortex-array/src/arrays/list/compute/take.rs index e6094bd4ef3..ff2b857f1e3 100644 --- a/vortex-array/src/arrays/list/compute/take.rs +++ b/vortex-array/src/arrays/list/compute/take.rs @@ -18,7 +18,6 @@ use crate::dtype::Nullability; use crate::executor::ExecutionCtx; use crate::match_each_integer_ptype; use crate::match_smallest_offset_type; -use crate::vtable::ValidityHelper; // TODO(connor)[ListView]: Re-revert to the version where we simply convert to a `ListView` and call // the `ListView::take` compute function once `ListView` is more stable. diff --git a/vortex-array/src/arrays/list/vtable/mod.rs b/vortex-array/src/arrays/list/vtable/mod.rs index 114579a4bab..1936f275531 100644 --- a/vortex-array/src/arrays/list/vtable/mod.rs +++ b/vortex-array/src/arrays/list/vtable/mod.rs @@ -6,7 +6,6 @@ use std::sync::Arc; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -18,9 +17,7 @@ use crate::IntoArray; use crate::Precision; use crate::ProstMetadata; use crate::arrays::ListArray; -use crate::arrays::list::array::NUM_SLOTS; use crate::arrays::list::array::SLOT_NAMES; -use crate::arrays::list::array::VALIDITY_SLOT; use crate::arrays::list::compute::PARENT_KERNELS; use crate::arrays::list::compute::rules::PARENT_RULES; use crate::arrays::listview::list_view_from_list; @@ -39,7 +36,6 @@ use crate::vtable; use crate::vtable::Array; use crate::vtable::ArrayId; use crate::vtable::VTable; -use crate::vtable::ValidityVTableFromValidityHelper; mod operations; mod validity; vtable!(List); @@ -57,7 +53,7 @@ impl VTable for List { type Metadata = ProstMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromValidityHelper; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &List } @@ -82,14 +78,14 @@ impl VTable for List { array.dtype.hash(state); array.elements().array_hash(state, precision); array.offsets().array_hash(state, precision); - array.validity.array_hash(state, precision); + array.validity().array_hash(state, precision); } fn array_eq(array: &ListArray, other: &ListArray, precision: Precision) -> bool { array.dtype == other.dtype && array.elements().array_eq(other.elements(), precision) && array.offsets().array_eq(other.offsets(), precision) - && array.validity.array_eq(&other.validity, precision) + && array.validity().array_eq(&other.validity(), precision) } fn nbuffers(_array: &ListArray) -> usize { @@ -177,19 +173,8 @@ impl VTable for List { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut ListArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ListArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.validity = match &slots[VALIDITY_SLOT] { - Some(arr) => Validity::Array(arr.clone()), - None => Validity::from(array.dtype.nullability()), - }; - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/list/vtable/validity.rs b/vortex-array/src/arrays/list/vtable/validity.rs index c258cdb9d26..ce7a715abb3 100644 --- a/vortex-array/src/arrays/list/vtable/validity.rs +++ b/vortex-array/src/arrays/list/vtable/validity.rs @@ -1,12 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +use vortex_error::VortexResult; + +use crate::arrays::List; use crate::arrays::list::vtable::ListArray; use crate::validity::Validity; -use crate::vtable::ValidityHelper; +use crate::vtable::ValidityVTable; -impl ValidityHelper for ListArray { - fn validity(&self) -> Validity { - self.validity.clone() +impl ValidityVTable for List { + fn validity(array: &ListArray) -> VortexResult { + Ok(array.validity()) } } diff --git a/vortex-array/src/arrays/listview/array.rs b/vortex-array/src/arrays/listview/array.rs index 9e785135c8c..7e145cc84eb 100644 --- a/vortex-array/src/arrays/listview/array.rs +++ b/vortex-array/src/arrays/listview/array.rs @@ -21,6 +21,7 @@ use crate::dtype::IntegerPType; use crate::match_each_integer_ptype; use crate::stats::ArrayStats; use crate::validity::Validity; +use crate::vtable::child_to_validity; use crate::vtable::validity_to_child; /// The `elements` data array, where each list scalar is a _slice_ of the `elements` array, and @@ -123,12 +124,6 @@ pub struct ListViewArray { /// process which must rebuild the array from scratch. is_zero_copy_to_list: bool, - /// The validity / null map of the array. - /// - /// Note that this null map refers to which list scalars are null, **not** which sub-elements of - /// list scalars are null. The `elements` array will track individual value nullability. - pub(super) validity: Validity, - /// The stats for this array. pub(super) stats_set: ArrayStats, } @@ -181,7 +176,6 @@ impl ListViewArray { Ok(Self { dtype: DType::List(Arc::new(elements.dtype().clone()), validity.nullability()), slots: vec![Some(elements), Some(offsets), Some(sizes), validity_slot], - validity, is_zero_copy_to_list: false, stats_set: Default::default(), }) @@ -223,7 +217,6 @@ impl ListViewArray { Self { dtype: DType::List(Arc::new(elements.dtype().clone()), validity.nullability()), slots: vec![Some(elements), Some(offsets), Some(sizes), validity_slot], - validity, is_zero_copy_to_list: false, stats_set: Default::default(), } @@ -350,6 +343,7 @@ impl ListViewArray { } pub fn into_parts(mut self) -> ListViewArrayParts { + let validity = self.validity(); let dtype = self.dtype.into_list_element_opt().vortex_expect("is list"); ListViewArrayParts { elements_dtype: dtype, @@ -362,10 +356,15 @@ impl ListViewArray { sizes: self.slots[SIZES_SLOT] .take() .vortex_expect("ListViewArray sizes slot"), - validity: self.validity, + validity, } } + /// Returns the validity of this array, computed on demand from the validity slot. + pub fn validity(&self) -> Validity { + child_to_validity(&self.slots[VALIDITY_SLOT], self.dtype.nullability()) + } + /// Returns the offset at the given index. /// /// Note that it is possible the corresponding list view is null (which is only defined by the diff --git a/vortex-array/src/arrays/listview/compute/cast.rs b/vortex-array/src/arrays/listview/compute/cast.rs index 6b662827220..fcd386d897e 100644 --- a/vortex-array/src/arrays/listview/compute/cast.rs +++ b/vortex-array/src/arrays/listview/compute/cast.rs @@ -10,7 +10,6 @@ use crate::arrays::ListViewArray; use crate::builtins::ArrayBuiltins; use crate::dtype::DType; use crate::scalar_fn::fns::cast::CastReduce; -use crate::vtable::ValidityHelper; impl CastReduce for ListView { fn cast(array: &ListViewArray, dtype: &DType) -> VortexResult> { diff --git a/vortex-array/src/arrays/listview/compute/mask.rs b/vortex-array/src/arrays/listview/compute/mask.rs index 6732fc25f66..1473444a1d8 100644 --- a/vortex-array/src/arrays/listview/compute/mask.rs +++ b/vortex-array/src/arrays/listview/compute/mask.rs @@ -9,7 +9,6 @@ use crate::arrays::ListView; use crate::arrays::ListViewArray; use crate::scalar_fn::fns::mask::MaskReduce; use crate::validity::Validity; -use crate::vtable::ValidityHelper; impl MaskReduce for ListView { fn mask(array: &ListViewArray, mask: &ArrayRef) -> VortexResult> { diff --git a/vortex-array/src/arrays/listview/compute/rules.rs b/vortex-array/src/arrays/listview/compute/rules.rs index 6eedee9d8f9..dee58af80ba 100644 --- a/vortex-array/src/arrays/listview/compute/rules.rs +++ b/vortex-array/src/arrays/listview/compute/rules.rs @@ -16,7 +16,6 @@ use crate::optimizer::rules::ArrayParentReduceRule; use crate::optimizer::rules::ParentRuleSet; use crate::scalar_fn::fns::cast::CastReduceAdaptor; use crate::scalar_fn::fns::mask::MaskReduceAdaptor; -use crate::vtable::ValidityHelper; pub(crate) const PARENT_RULES: ParentRuleSet = ParentRuleSet::new(&[ ParentRuleSet::lift(&ListViewFilterPushDown), diff --git a/vortex-array/src/arrays/listview/compute/slice.rs b/vortex-array/src/arrays/listview/compute/slice.rs index be5855ce473..0a70df6d7db 100644 --- a/vortex-array/src/arrays/listview/compute/slice.rs +++ b/vortex-array/src/arrays/listview/compute/slice.rs @@ -19,7 +19,7 @@ impl SliceReduce for ListView { array.elements().clone(), array.offsets().slice(range.clone())?, array.sizes().slice(range.clone())?, - array.validity()?.slice(range)?, + array.validity().slice(range)?, ) .with_zero_copy_to_list(array.is_zero_copy_to_list()) } diff --git a/vortex-array/src/arrays/listview/compute/take.rs b/vortex-array/src/arrays/listview/compute/take.rs index 0e6e7289579..b262c881fdf 100644 --- a/vortex-array/src/arrays/listview/compute/take.rs +++ b/vortex-array/src/arrays/listview/compute/take.rs @@ -15,8 +15,6 @@ use crate::builtins::ArrayBuiltins; use crate::dtype::Nullability; use crate::match_each_integer_ptype; use crate::scalar::Scalar; -use crate::vtable::ValidityHelper; - // TODO(connor)[ListView]: Make use of this threshold after we start migrating operators. /// The threshold for triggering a rebuild of the [`ListViewArray`]. /// diff --git a/vortex-array/src/arrays/listview/conversion.rs b/vortex-array/src/arrays/listview/conversion.rs index fb34d9b45e8..3b00c7cca4f 100644 --- a/vortex-array/src/arrays/listview/conversion.rs +++ b/vortex-array/src/arrays/listview/conversion.rs @@ -23,7 +23,6 @@ use crate::builders::PrimitiveBuilder; use crate::dtype::IntegerPType; use crate::dtype::Nullability; use crate::match_each_integer_ptype; -use crate::vtable::ValidityHelper; /// Creates a [`ListViewArray`] from a [`ListArray`] by computing `sizes` from `offsets`. /// @@ -304,7 +303,6 @@ mod tests { use crate::assert_arrays_eq; use crate::dtype::FieldNames; use crate::validity::Validity; - use crate::vtable::ValidityHelper; #[test] fn test_list_to_listview_basic() -> VortexResult<()> { diff --git a/vortex-array/src/arrays/listview/rebuild.rs b/vortex-array/src/arrays/listview/rebuild.rs index cf2725e5c68..e687ad8e9f3 100644 --- a/vortex-array/src/arrays/listview/rebuild.rs +++ b/vortex-array/src/arrays/listview/rebuild.rs @@ -23,7 +23,6 @@ use crate::dtype::PType; use crate::match_each_integer_ptype; use crate::scalar::Scalar; use crate::scalar_fn::fns::operators::Operator; -use crate::vtable::ValidityHelper; /// Modes for rebuilding a [`ListViewArray`]. pub enum ListViewRebuildMode { @@ -188,7 +187,7 @@ impl ListViewArray { // non-overlapping, all (offset, size) pairs reference valid elements, and the validity // array is preserved from the original. Ok(unsafe { - ListViewArray::new_unchecked(elements, offsets, sizes, self.validity.clone()) + ListViewArray::new_unchecked(elements, offsets, sizes, self.validity()) .with_zero_copy_to_list(true) }) } @@ -271,7 +270,7 @@ impl ListViewArray { // - The array satisfies the zero-copy-to-list property by having sorted offsets, no gaps, // and no overlaps. Ok(unsafe { - ListViewArray::new_unchecked(elements, offsets, sizes, self.validity.clone()) + ListViewArray::new_unchecked(elements, offsets, sizes, self.validity()) .with_zero_copy_to_list(true) }) } @@ -382,7 +381,6 @@ mod tests { use crate::assert_arrays_eq; use crate::dtype::Nullability; use crate::validity::Validity; - use crate::vtable::ValidityHelper; #[test] fn test_rebuild_flatten_removes_overlaps() -> VortexResult<()> { diff --git a/vortex-array/src/arrays/listview/vtable/mod.rs b/vortex-array/src/arrays/listview/vtable/mod.rs index d69d1ce8f18..6c0cd40769a 100644 --- a/vortex-array/src/arrays/listview/vtable/mod.rs +++ b/vortex-array/src/arrays/listview/vtable/mod.rs @@ -18,9 +18,7 @@ use crate::Precision; use crate::ProstMetadata; use crate::SerializeMetadata; use crate::arrays::ListViewArray; -use crate::arrays::listview::array::NUM_SLOTS; use crate::arrays::listview::array::SLOT_NAMES; -use crate::arrays::listview::array::VALIDITY_SLOT; use crate::arrays::listview::compute::rules::PARENT_RULES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -35,7 +33,6 @@ use crate::vtable; use crate::vtable::Array; use crate::vtable::ArrayId; use crate::vtable::VTable; -use crate::vtable::ValidityVTableFromValidityHelper; mod operations; mod validity; vtable!(ListView); @@ -62,7 +59,7 @@ impl VTable for ListView { type Metadata = ProstMetadata; type OperationsVTable = Self; - type ValidityVTable = ValidityVTableFromValidityHelper; + type ValidityVTable = Self; fn vtable(_array: &Self::Array) -> &Self { &ListView } @@ -93,7 +90,7 @@ impl VTable for ListView { array.elements().array_hash(state, precision); array.offsets().array_hash(state, precision); array.sizes().array_hash(state, precision); - array.validity.array_hash(state, precision); + array.validity().array_hash(state, precision); } fn array_eq(array: &ListViewArray, other: &ListViewArray, precision: Precision) -> bool { @@ -101,7 +98,7 @@ impl VTable for ListView { && array.elements().array_eq(other.elements(), precision) && array.offsets().array_eq(other.offsets(), precision) && array.sizes().array_eq(other.sizes(), precision) - && array.validity.array_eq(&other.validity, precision) + && array.validity().array_eq(&other.validity(), precision) } fn nbuffers(_array: &ListViewArray) -> usize { @@ -199,19 +196,8 @@ impl VTable for ListView { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut ListViewArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "ListViewArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.validity = match &slots[VALIDITY_SLOT] { - Some(arr) => Validity::Array(arr.clone()), - None => Validity::from(array.dtype.nullability()), - }; - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/listview/vtable/validity.rs b/vortex-array/src/arrays/listview/vtable/validity.rs index b0ed6ec6a1a..c1d2216c91a 100644 --- a/vortex-array/src/arrays/listview/vtable/validity.rs +++ b/vortex-array/src/arrays/listview/vtable/validity.rs @@ -1,12 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +use vortex_error::VortexResult; + +use crate::arrays::listview::vtable::ListView; use crate::arrays::listview::vtable::ListViewArray; use crate::validity::Validity; -use crate::vtable::ValidityHelper; +use crate::vtable::ValidityVTable; -impl ValidityHelper for ListViewArray { - fn validity(&self) -> Validity { - self.validity.clone() +impl ValidityVTable for ListView { + fn validity(array: &ListViewArray) -> VortexResult { + Ok(array.validity()) } } diff --git a/vortex-array/src/arrays/masked/execute.rs b/vortex-array/src/arrays/masked/execute.rs index 3d100338895..3344e7dc36a 100644 --- a/vortex-array/src/arrays/masked/execute.rs +++ b/vortex-array/src/arrays/masked/execute.rs @@ -143,7 +143,7 @@ fn mask_validity_listview( ctx: &mut ExecutionCtx, ) -> VortexResult { let len = array.len(); - let new_validity = combine_validity(&array.validity()?, mask, len, ctx)?; + let new_validity = combine_validity(&array.validity(), mask, len, ctx)?; // SAFETY: We're only changing validity, not the data structure Ok(unsafe { ListViewArray::new_unchecked( @@ -162,7 +162,7 @@ fn mask_validity_fixed_size_list( ) -> VortexResult { let len = array.len(); let list_size = array.list_size(); - let new_validity = combine_validity(&array.validity()?, mask, len, ctx)?; + let new_validity = combine_validity(&array.validity(), mask, len, ctx)?; // SAFETY: We're only changing validity, not the data structure Ok(unsafe { FixedSizeListArray::new_unchecked(array.elements().clone(), list_size, new_validity, len) @@ -204,7 +204,7 @@ fn mask_validity_variant( mask: &Mask, ctx: &mut ExecutionCtx, ) -> VortexResult { - let child = array.child().clone(); + let mut child = array.child().clone(); let len = child.len(); let child_validity = child.validity()?; @@ -223,8 +223,8 @@ fn mask_validity_variant( // Child has an array-backed validity stored as its first child. // Combine with the mask and replace that child via with_children. let combined = combine_validity(&child_validity, mask, len, ctx)?; - let new_child = child.with_slot(0, combined.to_array(len))?; - Ok(VariantArray::new(new_child)) + child.put_slot(0, combined.to_array(len)); + Ok(VariantArray::new(child)) } } } diff --git a/vortex-array/src/arrays/masked/vtable/mod.rs b/vortex-array/src/arrays/masked/vtable/mod.rs index 3b8b3b792f8..b8eb4390960 100644 --- a/vortex-array/src/arrays/masked/vtable/mod.rs +++ b/vortex-array/src/arrays/masked/vtable/mod.rs @@ -20,7 +20,6 @@ use crate::IntoArray; use crate::Precision; use crate::arrays::ConstantArray; use crate::arrays::MaskedArray; -use crate::arrays::masked::array::NUM_SLOTS; use crate::arrays::masked::array::SLOT_NAMES; use crate::arrays::masked::compute::rules::PARENT_RULES; use crate::arrays::masked::mask_validity_canonical; @@ -184,15 +183,8 @@ impl VTable for Masked { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut MaskedArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "MaskedArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } } diff --git a/vortex-array/src/arrays/null/mod.rs b/vortex-array/src/arrays/null/mod.rs index 2728f519c4d..c5935fb71cb 100644 --- a/vortex-array/src/arrays/null/mod.rs +++ b/vortex-array/src/arrays/null/mod.rs @@ -5,7 +5,6 @@ use std::hash::Hash; use std::sync::Arc; use vortex_error::VortexResult; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -29,8 +28,6 @@ use crate::vtable::OperationsVTable; use crate::vtable::VTable; use crate::vtable::ValidityVTable; -const NUM_SLOTS: usize = 0; - pub(crate) mod compute; vtable!(Null); @@ -90,15 +87,8 @@ impl VTable for Null { vortex_panic!("NullArray slot_name index {idx} out of bounds") } - fn with_slots(array: &mut NullArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "NullArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn metadata(_array: &NullArray) -> VortexResult { diff --git a/vortex-array/src/arrays/patched/vtable/mod.rs b/vortex-array/src/arrays/patched/vtable/mod.rs index e015af1b352..daae84d74b8 100644 --- a/vortex-array/src/arrays/patched/vtable/mod.rs +++ b/vortex-array/src/arrays/patched/vtable/mod.rs @@ -12,7 +12,6 @@ use std::sync::Arc; use vortex_buffer::Buffer; use vortex_error::VortexExpect; use vortex_error::VortexResult; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -30,7 +29,6 @@ use crate::ProstMetadata; use crate::SerializeMetadata; use crate::arrays::PrimitiveArray; use crate::arrays::patched::PatchedArray; -use crate::arrays::patched::array::NUM_SLOTS; use crate::arrays::patched::array::SLOT_NAMES; use crate::arrays::patched::compute::rules::PARENT_RULES; use crate::arrays::patched::vtable::kernels::PARENT_KERNELS; @@ -277,15 +275,8 @@ impl VTable for Patched { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "PatchedArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { @@ -664,13 +655,13 @@ mod tests { let indices = array.patch_indices().clone(); let values = array.patch_values().clone(); - // Create new PatchedArray with same children using with_slots - let array_ref = array.clone().into_array(); - let vtable = array_ref.vtable().clone_boxed(); - let new_array = vtable.with_slots( - array_ref, - vec![Some(inner), Some(lane_offsets), Some(indices), Some(values)], - )?; + // Create new PatchedArray with same children using put_slot + let mut new_array = array.clone().into_array(); + let vtable = new_array.vtable().clone_boxed(); + vtable.put_slot(&mut new_array, 0, inner.clone()); + vtable.put_slot(&mut new_array, 1, lane_offsets.clone()); + vtable.put_slot(&mut new_array, 2, indices.clone()); + vtable.put_slot(&mut new_array, 3, values.clone()); assert!(new_array.is::()); assert_eq!(array.len(), new_array.len()); @@ -699,17 +690,12 @@ mod tests { let indices = array.patch_indices().clone(); let values = array.patch_values().clone(); - let array_ref = array.into_array(); - let vtable = array_ref.vtable().clone_boxed(); - let new_array = vtable.with_slots( - array_ref, - vec![ - Some(new_inner), - Some(lane_offsets), - Some(indices), - Some(values), - ], - )?; + let mut new_array = array.into_array(); + let vtable = new_array.vtable().clone_boxed(); + vtable.put_slot(&mut new_array, 0, new_inner.clone()); + vtable.put_slot(&mut new_array, 1, lane_offsets.clone()); + vtable.put_slot(&mut new_array, 2, indices.clone()); + vtable.put_slot(&mut new_array, 3, values.clone()); // Execute and verify the inner values changed (except at patch positions) let mut ctx = ExecutionCtx::new(VortexSession::empty()); diff --git a/vortex-array/src/arrays/primitive/vtable/mod.rs b/vortex-array/src/arrays/primitive/vtable/mod.rs index 0fed78614e2..692ac742b56 100644 --- a/vortex-array/src/arrays/primitive/vtable/mod.rs +++ b/vortex-array/src/arrays/primitive/vtable/mod.rs @@ -14,7 +14,6 @@ use crate::EmptyMetadata; use crate::ExecutionCtx; use crate::ExecutionResult; use crate::arrays::PrimitiveArray; -use crate::arrays::primitive::array::NUM_SLOTS; use crate::arrays::primitive::array::SLOT_NAMES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -179,15 +178,8 @@ impl VTable for Primitive { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut PrimitiveArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "PrimitiveArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs index d6eb44f9e65..8a2ef24fa04 100644 --- a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs +++ b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs @@ -190,9 +190,8 @@ impl VTable for ScalarFnVTable { .to_string() } - fn with_slots(array: &mut ScalarFnArray, slots: Vec>) -> VortexResult<()> { - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/shared/vtable.rs b/vortex-array/src/arrays/shared/vtable.rs index fbbfeb31316..84549bd614f 100644 --- a/vortex-array/src/arrays/shared/vtable.rs +++ b/vortex-array/src/arrays/shared/vtable.rs @@ -3,11 +3,8 @@ use std::hash::Hash; use std::sync::Arc; -use std::sync::OnceLock; -use async_lock::Mutex as AsyncMutex; use vortex_error::VortexResult; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -18,7 +15,6 @@ use crate::ExecutionCtx; use crate::ExecutionResult; use crate::Precision; use crate::arrays::SharedArray; -use crate::arrays::shared::array::NUM_SLOTS; use crate::arrays::shared::array::SLOT_NAMES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -102,17 +98,8 @@ impl VTable for Shared { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "SharedArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - array.cached = Arc::new(OnceLock::new()); - array.async_compute_lock = Arc::new(AsyncMutex::new(())); - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn metadata(_array: &Self::Array) -> VortexResult { diff --git a/vortex-array/src/arrays/slice/vtable.rs b/vortex-array/src/arrays/slice/vtable.rs index 01aba68bd46..e126b4b035b 100644 --- a/vortex-array/src/arrays/slice/vtable.rs +++ b/vortex-array/src/arrays/slice/vtable.rs @@ -10,7 +10,6 @@ use std::sync::Arc; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -21,7 +20,6 @@ use crate::ArrayRef; use crate::Canonical; use crate::DynArray; use crate::Precision; -use crate::arrays::slice::array::NUM_SLOTS; use crate::arrays::slice::array::SLOT_NAMES; use crate::arrays::slice::array::SliceArray; use crate::arrays::slice::rules::PARENT_RULES; @@ -135,15 +133,8 @@ impl VTable for Slice { SliceArray::try_new(child, metadata.0.clone()) } - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "SliceArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/struct_/vtable/mod.rs b/vortex-array/src/arrays/struct_/vtable/mod.rs index 2ace423d534..8c4e2738e12 100644 --- a/vortex-array/src/arrays/struct_/vtable/mod.rs +++ b/vortex-array/src/arrays/struct_/vtable/mod.rs @@ -164,9 +164,8 @@ impl VTable for Struct { } } - fn with_slots(array: &mut StructArray, slots: Vec>) -> VortexResult<()> { - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { diff --git a/vortex-array/src/arrays/varbin/vtable/mod.rs b/vortex-array/src/arrays/varbin/vtable/mod.rs index 0ed565a2587..6ede615b500 100644 --- a/vortex-array/src/arrays/varbin/vtable/mod.rs +++ b/vortex-array/src/arrays/varbin/vtable/mod.rs @@ -6,7 +6,6 @@ use std::sync::Arc; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_panic; use crate::ArrayRef; @@ -17,7 +16,6 @@ use crate::IntoArray; use crate::ProstMetadata; use crate::SerializeMetadata; use crate::arrays::VarBinArray; -use crate::arrays::varbin::array::NUM_SLOTS; use crate::arrays::varbin::array::SLOT_NAMES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -172,15 +170,8 @@ impl VTable for VarBin { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut VarBinArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "VarBinArray expects exactly {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn reduce_parent( diff --git a/vortex-array/src/arrays/varbinview/vtable/mod.rs b/vortex-array/src/arrays/varbinview/vtable/mod.rs index 7c7f809f50d..9144173e933 100644 --- a/vortex-array/src/arrays/varbinview/vtable/mod.rs +++ b/vortex-array/src/arrays/varbinview/vtable/mod.rs @@ -9,7 +9,6 @@ use kernel::PARENT_KERNELS; use vortex_buffer::Buffer; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_error::vortex_ensure; use vortex_error::vortex_err; use vortex_error::vortex_panic; use vortex_session::VortexSession; @@ -21,7 +20,6 @@ use crate::ExecutionResult; use crate::Precision; use crate::arrays::VarBinViewArray; use crate::arrays::varbinview::BinaryView; -use crate::arrays::varbinview::array::NUM_SLOTS; use crate::arrays::varbinview::array::SLOT_NAMES; use crate::arrays::varbinview::compute::rules::PARENT_RULES; use crate::buffer::BufferHandle; @@ -201,15 +199,8 @@ impl VTable for VarBinView { SLOT_NAMES[idx].to_string() } - fn with_slots(array: &mut VarBinViewArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "VarBinViewArray expects {} slots, got {}", - NUM_SLOTS, - slots.len() - ); - array.slots = slots; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn reduce_parent( diff --git a/vortex-array/src/arrays/variant/vtable/mod.rs b/vortex-array/src/arrays/variant/vtable/mod.rs index f0001425977..561986b54fa 100644 --- a/vortex-array/src/arrays/variant/vtable/mod.rs +++ b/vortex-array/src/arrays/variant/vtable/mod.rs @@ -7,10 +7,8 @@ mod validity; use std::hash::Hasher; use std::sync::Arc; -use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_ensure; -use vortex_error::vortex_err; use vortex_error::vortex_panic; use crate::ArrayEq; @@ -21,7 +19,6 @@ use crate::ExecutionCtx; use crate::ExecutionResult; use crate::Precision; use crate::arrays::VariantArray; -use crate::arrays::variant::NUM_SLOTS; use crate::arrays::variant::SLOT_NAMES; use crate::buffer::BufferHandle; use crate::dtype::DType; @@ -137,20 +134,8 @@ impl VTable for Variant { Ok(VariantArray::new(child)) } - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.len() == NUM_SLOTS, - "VariantArray expects exactly {} slot, got {}", - NUM_SLOTS, - slots.len() - ); - let child = slots - .into_iter() - .next() - .vortex_expect("VariantArray slot vector length was validated") - .ok_or_else(|| vortex_err!("VariantArray child slot must be present"))?; - array.slots = [Some(child)]; - Ok(()) + fn slots_mut(array: &mut Self::Array) -> &mut [Option] { + &mut array.slots } fn execute(array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult { @@ -165,11 +150,13 @@ mod tests { use crate::arrays::PrimitiveArray; #[test] - fn with_slots_rejects_missing_child() { + fn slots_mut_returns_mutable_slots() { let mut array = VariantArray::new(PrimitiveArray::from_iter([1u8, 2, 3]).into_array()); + let replacement = PrimitiveArray::from_iter([4u8, 5, 6]).into_array(); - let err = ::with_slots(&mut array, vec![None]).unwrap_err(); + let slots = ::slots_mut(&mut array); + slots[0] = Some(replacement); - assert!(err.to_string().contains("child slot must be present")); + assert_eq!(array.child().len(), 3); } } diff --git a/vortex-array/src/arrow/executor/fixed_size_list.rs b/vortex-array/src/arrow/executor/fixed_size_list.rs index 92546322cf6..70913cc0c79 100644 --- a/vortex-array/src/arrow/executor/fixed_size_list.rs +++ b/vortex-array/src/arrow/executor/fixed_size_list.rs @@ -13,7 +13,6 @@ use crate::arrays::FixedSizeList; use crate::arrays::FixedSizeListArray; use crate::arrow::ArrowArrayExecutor; use crate::arrow::executor::validity::to_arrow_null_buffer; -use crate::vtable::ValidityHelper; pub(super) fn to_arrow_fixed_list( array: ArrayRef, diff --git a/vortex-array/src/arrow/executor/list.rs b/vortex-array/src/arrow/executor/list.rs index a4996ce43bb..342f802c71f 100644 --- a/vortex-array/src/arrow/executor/list.rs +++ b/vortex-array/src/arrow/executor/list.rs @@ -30,7 +30,6 @@ use crate::builtins::ArrayBuiltins; use crate::dtype::DType; use crate::dtype::NativePType; use crate::dtype::Nullability; -use crate::vtable::ValidityHelper; /// Convert a Vortex VarBinArray into an Arrow [`GenericListArray`](arrow_array:array::GenericListArray). pub(super) fn to_arrow_list( diff --git a/vortex-array/src/builders/fixed_size_list.rs b/vortex-array/src/builders/fixed_size_list.rs index c7ecf0a59b4..cbe661d917b 100644 --- a/vortex-array/src/builders/fixed_size_list.rs +++ b/vortex-array/src/builders/fixed_size_list.rs @@ -287,7 +287,6 @@ mod tests { use crate::dtype::PType::I32; use crate::scalar::Scalar; use crate::validity::Validity; - use crate::vtable::ValidityHelper; #[test] fn test_empty() { diff --git a/vortex-array/src/builders/list.rs b/vortex-array/src/builders/list.rs index efdd44bd739..38b2d637c43 100644 --- a/vortex-array/src/builders/list.rs +++ b/vortex-array/src/builders/list.rs @@ -330,7 +330,6 @@ mod tests { use crate::executor::VortexSessionExecute; use crate::scalar::Scalar; use crate::validity::Validity; - use crate::vtable::ValidityHelper; #[test] fn test_empty() { diff --git a/vortex-array/src/builders/listview.rs b/vortex-array/src/builders/listview.rs index c8e4044c915..6a62275aa58 100644 --- a/vortex-array/src/builders/listview.rs +++ b/vortex-array/src/builders/listview.rs @@ -441,7 +441,6 @@ mod tests { use crate::dtype::Nullability::Nullable; use crate::dtype::PType::I32; use crate::scalar::Scalar; - use crate::vtable::ValidityHelper; #[test] fn test_empty() { diff --git a/vortex-array/src/executor.rs b/vortex-array/src/executor.rs index 1ff23890ca3..36ca5a8b368 100644 --- a/vortex-array/src/executor.rs +++ b/vortex-array/src/executor.rs @@ -58,6 +58,9 @@ pub(crate) static MAX_ITERATIONS: LazyLock = /// implementor type. /// /// Users should use the `Array::execute` or `Array::execute_as` methods +/// +/// Users should prefer to pass an ArrayRef with ref count == 1, then we can use an owned array +/// and owned buffer fast path to mutate in place. pub trait Executable: Sized { fn execute(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult; } @@ -123,9 +126,9 @@ impl dyn DynArray + '_ { ctx.log(format_args!("-> {}", current)); return Ok(current); } - Some((parent, slot_idx, _)) => { - current = parent.with_slot(slot_idx, current)?; - current = current.optimize()?; + Some((mut parent, slot_idx, _)) => { + parent.put_slot(slot_idx, current); + current = parent.optimize()?; continue; } } @@ -139,9 +142,9 @@ impl dyn DynArray + '_ { ctx.log(format_args!("-> canonical (unmatched) {}", current)); return Ok(current); } - Some((parent, slot_idx, _)) => { - current = parent.with_slot(slot_idx, current)?; - current = current.optimize()?; + Some((mut parent, slot_idx, _)) => { + parent.put_slot(slot_idx, current); + current = parent.optimize()?; continue; } } @@ -159,11 +162,11 @@ impl dyn DynArray + '_ { // Execute the array itself. let result = execute_step(current, ctx)?; - let (array, step) = result.into_parts(); + let (mut array, step) = result.into_parts(); match step { ExecutionStep::ExecuteSlot(i, done) => { - let child = array.slots()[i] - .clone() + let child = array + .take_slot(i) .vortex_expect("ExecuteSlot index in bounds"); ctx.log(format_args!( "ExecuteSlot({i}): pushing {}, focusing on {}", @@ -338,11 +341,13 @@ impl Executable for ArrayRef { Ok(array) } ExecutionStep::ExecuteSlot(i, _) => { - // For single-step execution, handle ExecuteSlot by executing the slot, - // replacing it, and returning the updated array. - let child = array.slots()[i].clone().vortex_expect("valid slot index"); + // Take the child out of the slot, execute it, and put the result back. + // This avoids cloning the child or the parent array. + let mut array = array; + let child = array.take_slot(i).vortex_expect("valid slot index"); let executed_child = child.execute::(ctx)?; - array.with_slot(i, executed_child) + array.put_slot(i, executed_child); + Ok(array) } } } diff --git a/vortex-array/src/optimizer/mod.rs b/vortex-array/src/optimizer/mod.rs index ee5cd6af210..96576b7b95a 100644 --- a/vortex-array/src/optimizer/mod.rs +++ b/vortex-array/src/optimizer/mod.rs @@ -26,17 +26,16 @@ pub trait ArrayOptimizer { impl ArrayOptimizer for ArrayRef { fn optimize(&self) -> VortexResult { - Ok(try_optimize(self)?.unwrap_or_else(|| self.clone())) + try_optimize(self.clone()) } fn optimize_recursive(&self) -> VortexResult { - Ok(try_optimize_recursive(self)?.unwrap_or_else(|| self.clone())) + try_optimize_recursive(self.clone()) } } -fn try_optimize(array: &ArrayRef) -> VortexResult> { - let mut current_array = array.clone(); - let mut any_optimizations = false; +fn try_optimize(array: ArrayRef) -> VortexResult { + let mut current_array = array; // Apply reduction rules to the current array until no more rules apply. let mut loop_counter = 0; @@ -48,7 +47,6 @@ fn try_optimize(array: &ArrayRef) -> VortexResult> { if let Some(new_array) = current_array.vtable().reduce(¤t_array)? { current_array = new_array; - any_optimizations = true; continue; } @@ -61,60 +59,28 @@ fn try_optimize(array: &ArrayRef) -> VortexResult> { .vtable() .reduce_parent(child, ¤t_array, slot_idx)? { - // If the parent was replaced, then we attempt to reduce it again. current_array = new_array; - any_optimizations = true; - - // Continue to the start of the outer loop continue 'outer; } } - // No more optimizations can be applied break; } - if any_optimizations { - Ok(Some(current_array)) - } else { - Ok(None) - } + Ok(current_array) } -fn try_optimize_recursive(array: &ArrayRef) -> VortexResult> { - let mut current_array = array.clone(); - let mut any_optimizations = false; - - if let Some(new_array) = try_optimize(¤t_array)? { - current_array = new_array; - any_optimizations = true; - } +fn try_optimize_recursive(array: ArrayRef) -> VortexResult { + let mut current_array = try_optimize(array)?; - let mut new_slots = Vec::with_capacity(current_array.slots().len()); - let mut any_slot_optimized = false; - for slot in current_array.slots() { - match slot { - Some(child) => { - if let Some(new_child) = try_optimize_recursive(child)? { - new_slots.push(Some(new_child)); - any_slot_optimized = true; - } else { - new_slots.push(Some(child.clone())); - } - } - None => new_slots.push(None), + // Optimize each child slot in-place. + let nslots = current_array.slots().len(); + for i in 0..nslots { + if let Some(child) = current_array.take_slot(i) { + let optimized = try_optimize_recursive(child)?; + current_array.put_slot(i, optimized); } } - if any_slot_optimized { - let vtable = current_array.vtable().clone_boxed(); - current_array = vtable.with_slots(current_array, new_slots)?; - any_optimizations = true; - } - - if any_optimizations { - Ok(Some(current_array)) - } else { - Ok(None) - } + Ok(current_array) } diff --git a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs index 3ed85bd7243..1d1e42c7536 100644 --- a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs +++ b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs @@ -51,7 +51,6 @@ use crate::scalar_fn::fns::binary::Binary; use crate::scalar_fn::fns::literal::Literal; use crate::scalar_fn::fns::operators::Operator; use crate::validity::Validity; -use crate::vtable::ValidityHelper; #[derive(Clone)] pub struct ListContains; diff --git a/vortex-array/src/vtable/dyn_.rs b/vortex-array/src/vtable/dyn_.rs index 67fd8d529cf..13b19cd2dcd 100644 --- a/vortex-array/src/vtable/dyn_.rs +++ b/vortex-array/src/vtable/dyn_.rs @@ -48,8 +48,21 @@ pub trait DynVTable: 'static + Send + Sync + Debug { children: &dyn ArrayChildren, session: &VortexSession, ) -> VortexResult; - /// See [`VTable::with_slots`] - fn with_slots(&self, array: ArrayRef, slots: Vec>) -> VortexResult; + /// Remove a child from a slot, returning it. + /// + /// With unique ownership (Arc refcount == 1), the slot is set to `None` in-place. + /// With shared ownership, the child is cloned out and the original array is unchanged. + /// + /// Callers must not read the slot after `take_slot` without a preceding `put_slot` — + /// the slot's state is undefined until a value is put back. + fn take_slot(&self, array: &mut ArrayRef, slot_idx: usize) -> Option; + + /// Put a child into a slot, replacing any existing value. + /// + /// With unique ownership (Arc refcount == 1), the slot is mutated in-place. + /// With shared ownership, the inner array is cloned, the slot is set on the clone, + /// and `*array` is replaced with the new copy. + fn put_slot(&self, array: &mut ArrayRef, slot_idx: usize, value: ArrayRef); /// See [`VTable::reduce`] fn reduce(&self, array: &ArrayRef) -> VortexResult>; @@ -113,11 +126,24 @@ impl DynVTable for V { Ok(array.into_array()) } - fn with_slots(&self, array: ArrayRef, slots: Vec>) -> VortexResult { - let arc = downcast_owned::(array); - let mut inner = Arc::try_unwrap(arc).unwrap_or_else(|arc| arc.as_ref().clone()); - V::with_slots(&mut inner.array, slots)?; - Ok(inner.into_array()) + fn take_slot(&self, array: &mut ArrayRef, slot_idx: usize) -> Option { + // If we have unique ownership, take in-place. Otherwise, clone the child. + if let Some(inner) = downcast_mut::(array) { + V::slots_mut(&mut inner.array)[slot_idx].take() + } else { + array.slots()[slot_idx].clone() + } + } + + fn put_slot(&self, array: &mut ArrayRef, slot_idx: usize, value: ArrayRef) { + // If we have unique ownership, put in-place. Otherwise, clone the inner and rebuild. + if let Some(inner) = downcast_mut::(array) { + V::slots_mut(&mut inner.array)[slot_idx] = Some(value); + } else { + let mut inner = downcast::(array).clone(); + V::slots_mut(&mut inner.array)[slot_idx] = Some(value); + *array = inner.into_array(); + } } fn reduce(&self, array: &ArrayRef) -> VortexResult> { @@ -229,6 +255,16 @@ fn downcast(array: &ArrayRef) -> &Array { .vortex_expect("Failed to downcast array to expected encoding type") } +/// Try to get `&mut Array` from an `ArrayRef` if the Arc is uniquely owned. +/// +/// Returns `None` if the Arc has other references or the type doesn't match. +fn downcast_mut(array: &mut ArrayRef) -> Option<&mut Array> { + let ptr = Arc::get_mut(array)? as *mut dyn DynArray as *mut Array; + // SAFETY: we verified unique ownership via Arc::get_mut, and the vtable on DynVTable + // guarantees the concrete type is Array. + Some(unsafe { &mut *ptr }) +} + /// Downcast an `ArrayRef` into an `Arc>`. fn downcast_owned(array: ArrayRef) -> Arc> { let any_arc = array.as_any_arc(); diff --git a/vortex-array/src/vtable/mod.rs b/vortex-array/src/vtable/mod.rs index 514d4ac2add..1371184858b 100644 --- a/vortex-array/src/vtable/mod.rs +++ b/vortex-array/src/vtable/mod.rs @@ -182,23 +182,19 @@ pub trait VTable: 'static + Clone + Sized + Send + Sync + Debug { /// The backing storage is a `Vec` (rather than a fixed-size array) so that it can be /// moved out of an `ArrayData` into the concrete `Array` type during deserialization /// without copying. - /// - /// TODO: once no encodings rely on side-effects in [`Self::with_slots`], replace the - /// `slots`/`with_slots` pair with a single `slots_mut` returning `&mut [Option]`. fn slots(array: &Self::Array) -> &[Option]; + /// Returns a mutable reference to the slots of the array. + /// + /// This allows callers to replace individual slots in-place without cloning all children. + fn slots_mut(array: &mut Self::Array) -> &mut [Option]; + /// Returns the name of the slot at the given index. /// /// # Panics /// Panics if `idx >= slots(array).len()`. fn slot_name(array: &Self::Array, idx: usize) -> String; - /// Replaces the slots in `array` with the given `slots` vec. - /// - /// Some encodings use this to perform side-effects (e.g. cache invalidation) when - /// slots change. Once those are removed, this will be replaced by `slots_mut`. - fn with_slots(array: &mut Self::Array, slots: Vec>) -> VortexResult<()>; - /// Execute this array by returning an [`ExecutionResult`]. /// /// Instead of recursively executing children, implementations should return diff --git a/vortex-compressor/src/compressor.rs b/vortex-compressor/src/compressor.rs index 5aff682fbad..ea11d56c813 100644 --- a/vortex-compressor/src/compressor.rs +++ b/vortex-compressor/src/compressor.rs @@ -26,7 +26,6 @@ use vortex_array::arrays::listview::list_from_list_view; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::scalar::Scalar; -use vortex_array::vtable::ValidityHelper; use vortex_error::VortexResult; use vortex_error::vortex_bail; diff --git a/vortex-python/src/arrays/py/vtable.rs b/vortex-python/src/arrays/py/vtable.rs index e3111eba17f..999d6125dc4 100644 --- a/vortex-python/src/arrays/py/vtable.rs +++ b/vortex-python/src/arrays/py/vtable.rs @@ -25,7 +25,6 @@ use vortex::array::vtable::VTable; use vortex::array::vtable::ValidityVTable; use vortex::dtype::DType; use vortex::error::VortexResult; -use vortex::error::vortex_ensure; use vortex::error::vortex_err; use vortex::error::vortex_panic; use vortex::scalar::Scalar; @@ -149,13 +148,8 @@ impl VTable for PythonVTable { vortex_panic!("PythonArray has no slots, requested index {idx}") } - fn with_slots(_array: &mut PythonArray, slots: Vec>) -> VortexResult<()> { - vortex_ensure!( - slots.is_empty(), - "PythonArray has no slots, got {}", - slots.len() - ); - Ok(()) + fn slots_mut(_array: &mut PythonArray) -> &mut [Option] { + &mut [] } fn execute(_array: Arc>, _ctx: &mut ExecutionCtx) -> VortexResult {