Skip to content

Commit 11d607e

Browse files
authored
Hoist Slots (#7287)
This PR continues the Array VTables refactor by hoisting the common "slots" field out of ArrayData structs and into the generic Array<V> struct. Supersedes #7240 --------- Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent 6eee669 commit 11d607e

File tree

495 files changed

+7699
-8346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

495 files changed

+7699
-8346
lines changed

benchmarks/compress-bench/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use std::sync::Arc;
55

66
use ::vortex::array::arrays::ChunkedArray;
7+
use ::vortex::array::arrays::chunked::ChunkedArrayExt;
78
use ::vortex::array::arrays::listview::recursive_list_from_list_view;
89
use arrow_array::RecordBatch;
910
use arrow_schema::Schema;

encodings/alp/public-api.lock

Lines changed: 81 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,11 @@ pub type vortex_alp::ALP::OperationsVTable = vortex_alp::ALP
3232

3333
pub type vortex_alp::ALP::ValidityVTable = vortex_array::array::vtable::validity::ValidityVTableFromChild
3434

35-
pub fn vortex_alp::ALP::array_eq(array: &vortex_alp::ALPData, other: &vortex_alp::ALPData, precision: vortex_array::hash::Precision) -> bool
36-
37-
pub fn vortex_alp::ALP::array_hash<H: core::hash::Hasher>(array: &vortex_alp::ALPData, state: &mut H, precision: vortex_array::hash::Precision)
38-
3935
pub fn vortex_alp::ALP::buffer(_array: vortex_array::array::view::ArrayView<'_, Self>, idx: usize) -> vortex_array::buffer::BufferHandle
4036

4137
pub fn vortex_alp::ALP::buffer_name(_array: vortex_array::array::view::ArrayView<'_, Self>, _idx: usize) -> core::option::Option<alloc::string::String>
4238

43-
pub fn vortex_alp::ALP::deserialize(&self, 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<vortex_alp::ALPData>
39+
pub fn vortex_alp::ALP::deserialize(&self, 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<vortex_array::array::typed::ArrayParts<Self>>
4440

4541
pub fn vortex_alp::ALP::execute(array: vortex_array::array::typed::Array<Self>, ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::executor::ExecutionResult>
4642

@@ -56,19 +52,15 @@ pub fn vortex_alp::ALP::serialize(array: vortex_array::array::view::ArrayView<'_
5652

5753
pub fn vortex_alp::ALP::slot_name(_array: vortex_array::array::view::ArrayView<'_, Self>, idx: usize) -> alloc::string::String
5854

59-
pub fn vortex_alp::ALP::slots(array: vortex_array::array::view::ArrayView<'_, Self>) -> &[core::option::Option<vortex_array::array::erased::ArrayRef>]
60-
61-
pub fn vortex_alp::ALP::validate(&self, data: &vortex_alp::ALPData, dtype: &vortex_array::dtype::DType, len: usize) -> vortex_error::VortexResult<()>
62-
63-
pub fn vortex_alp::ALP::with_slots(array: &mut Self::ArrayData, slots: alloc::vec::Vec<core::option::Option<vortex_array::array::erased::ArrayRef>>) -> vortex_error::VortexResult<()>
55+
pub fn vortex_alp::ALP::validate(&self, data: &vortex_alp::ALPData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option<vortex_array::array::erased::ArrayRef>]) -> vortex_error::VortexResult<()>
6456

6557
impl vortex_array::array::vtable::operations::OperationsVTable<vortex_alp::ALP> for vortex_alp::ALP
6658

6759
pub fn vortex_alp::ALP::scalar_at(array: vortex_array::array::view::ArrayView<'_, vortex_alp::ALP>, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::scalar::Scalar>
6860

6961
impl vortex_array::array::vtable::validity::ValidityChild<vortex_alp::ALP> for vortex_alp::ALP
7062

71-
pub fn vortex_alp::ALP::validity_child(array: &vortex_alp::ALPData) -> &vortex_array::array::erased::ArrayRef
63+
pub fn vortex_alp::ALP::validity_child(array: vortex_array::array::view::ArrayView<'_, vortex_alp::ALP>) -> vortex_array::array::erased::ArrayRef
7264

7365
impl vortex_array::arrays::dict::take::TakeExecute for vortex_alp::ALP
7466

@@ -106,19 +98,11 @@ pub struct vortex_alp::ALPData
10698

10799
impl vortex_alp::ALPData
108100

109-
pub fn vortex_alp::ALPData::encoded(&self) -> &vortex_array::array::erased::ArrayRef
110-
111101
pub fn vortex_alp::ALPData::exponents(&self) -> vortex_alp::Exponents
112102

113-
pub fn vortex_alp::ALPData::into_parts(self) -> (vortex_array::array::erased::ArrayRef, vortex_alp::Exponents, core::option::Option<vortex_array::patches::Patches>)
114-
115-
pub fn vortex_alp::ALPData::patches(&self) -> core::option::Option<vortex_array::patches::Patches>
116-
117103
impl vortex_alp::ALPData
118104

119-
pub fn vortex_alp::ALPData::new(encoded: vortex_array::array::erased::ArrayRef, exponents: vortex_alp::Exponents, patches: core::option::Option<vortex_array::patches::Patches>) -> Self
120-
121-
pub fn vortex_alp::ALPData::try_new(encoded: vortex_array::array::erased::ArrayRef, exponents: vortex_alp::Exponents, patches: core::option::Option<vortex_array::patches::Patches>) -> vortex_error::VortexResult<Self>
105+
pub fn vortex_alp::ALPData::new(exponents: vortex_alp::Exponents, patches: core::option::Option<vortex_array::patches::Patches>) -> Self
122106

123107
impl core::clone::Clone for vortex_alp::ALPData
124108

@@ -128,6 +112,14 @@ impl core::fmt::Debug for vortex_alp::ALPData
128112

129113
pub fn vortex_alp::ALPData::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
130114

115+
impl vortex_array::hash::ArrayEq for vortex_alp::ALPData
116+
117+
pub fn vortex_alp::ALPData::array_eq(&self, other: &Self, _precision: vortex_array::hash::Precision) -> bool
118+
119+
impl vortex_array::hash::ArrayHash for vortex_alp::ALPData
120+
121+
pub fn vortex_alp::ALPData::array_hash<H: core::hash::Hasher>(&self, state: &mut H, _precision: vortex_array::hash::Precision)
122+
131123
pub struct vortex_alp::ALPMetadata
132124

133125
impl core::clone::Clone for vortex_alp::ALPMetadata
@@ -174,15 +166,11 @@ pub type vortex_alp::ALPRD::OperationsVTable = vortex_alp::ALPRD
174166

175167
pub type vortex_alp::ALPRD::ValidityVTable = vortex_array::array::vtable::validity::ValidityVTableFromChild
176168

177-
pub fn vortex_alp::ALPRD::array_eq(array: &vortex_alp::ALPRDData, other: &vortex_alp::ALPRDData, precision: vortex_array::hash::Precision) -> bool
178-
179-
pub fn vortex_alp::ALPRD::array_hash<H: core::hash::Hasher>(array: &vortex_alp::ALPRDData, state: &mut H, precision: vortex_array::hash::Precision)
180-
181169
pub fn vortex_alp::ALPRD::buffer(_array: vortex_array::array::view::ArrayView<'_, Self>, idx: usize) -> vortex_array::buffer::BufferHandle
182170

183171
pub fn vortex_alp::ALPRD::buffer_name(_array: vortex_array::array::view::ArrayView<'_, Self>, _idx: usize) -> core::option::Option<alloc::string::String>
184172

185-
pub fn vortex_alp::ALPRD::deserialize(&self, 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<vortex_alp::ALPRDData>
173+
pub fn vortex_alp::ALPRD::deserialize(&self, 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<vortex_array::array::typed::ArrayParts<Self>>
186174

187175
pub fn vortex_alp::ALPRD::execute(array: vortex_array::array::typed::Array<Self>, ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::executor::ExecutionResult>
188176

@@ -198,19 +186,15 @@ pub fn vortex_alp::ALPRD::serialize(array: vortex_array::array::view::ArrayView<
198186

199187
pub fn vortex_alp::ALPRD::slot_name(_array: vortex_array::array::view::ArrayView<'_, Self>, idx: usize) -> alloc::string::String
200188

201-
pub fn vortex_alp::ALPRD::slots(array: vortex_array::array::view::ArrayView<'_, Self>) -> &[core::option::Option<vortex_array::array::erased::ArrayRef>]
202-
203-
pub fn vortex_alp::ALPRD::validate(&self, data: &vortex_alp::ALPRDData, dtype: &vortex_array::dtype::DType, len: usize) -> vortex_error::VortexResult<()>
204-
205-
pub fn vortex_alp::ALPRD::with_slots(array: &mut Self::ArrayData, slots: alloc::vec::Vec<core::option::Option<vortex_array::array::erased::ArrayRef>>) -> vortex_error::VortexResult<()>
189+
pub fn vortex_alp::ALPRD::validate(&self, data: &vortex_alp::ALPRDData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option<vortex_array::array::erased::ArrayRef>]) -> vortex_error::VortexResult<()>
206190

207191
impl vortex_array::array::vtable::operations::OperationsVTable<vortex_alp::ALPRD> for vortex_alp::ALPRD
208192

209193
pub fn vortex_alp::ALPRD::scalar_at(array: vortex_array::array::view::ArrayView<'_, vortex_alp::ALPRD>, index: usize, _ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::scalar::Scalar>
210194

211195
impl vortex_array::array::vtable::validity::ValidityChild<vortex_alp::ALPRD> for vortex_alp::ALPRD
212196

213-
pub fn vortex_alp::ALPRD::validity_child(array: &vortex_alp::ALPRDData) -> &vortex_array::array::erased::ArrayRef
197+
pub fn vortex_alp::ALPRD::validity_child(array: vortex_array::array::view::ArrayView<'_, vortex_alp::ALPRD>) -> vortex_array::array::erased::ArrayRef
214198

215199
impl vortex_array::arrays::dict::take::TakeExecute for vortex_alp::ALPRD
216200

@@ -236,22 +220,14 @@ pub struct vortex_alp::ALPRDData
236220

237221
impl vortex_alp::ALPRDData
238222

239-
pub fn vortex_alp::ALPRDData::into_parts(self) -> vortex_alp::ALPRDDataParts
240-
241-
pub fn vortex_alp::ALPRDData::left_parts(&self) -> &vortex_array::array::erased::ArrayRef
223+
pub fn vortex_alp::ALPRDData::into_parts(self, left_parts: vortex_array::array::erased::ArrayRef, right_parts: vortex_array::array::erased::ArrayRef) -> vortex_alp::ALPRDDataParts
242224

243225
pub fn vortex_alp::ALPRDData::left_parts_dictionary(&self) -> &vortex_buffer::buffer::Buffer<u16>
244226

245-
pub fn vortex_alp::ALPRDData::left_parts_patches(&self) -> core::option::Option<vortex_array::patches::Patches>
246-
247-
pub fn vortex_alp::ALPRDData::replace_left_parts_patches(&mut self, patches: core::option::Option<vortex_array::patches::Patches>)
227+
pub fn vortex_alp::ALPRDData::new(left_parts_dictionary: vortex_buffer::buffer::Buffer<u16>, right_bit_width: u8, left_parts_patches: core::option::Option<vortex_array::patches::Patches>) -> Self
248228

249229
pub fn vortex_alp::ALPRDData::right_bit_width(&self) -> u8
250230

251-
pub fn vortex_alp::ALPRDData::right_parts(&self) -> &vortex_array::array::erased::ArrayRef
252-
253-
pub fn vortex_alp::ALPRDData::try_new(dtype: vortex_array::dtype::DType, left_parts: vortex_array::array::erased::ArrayRef, left_parts_dictionary: vortex_buffer::buffer::Buffer<u16>, right_parts: vortex_array::array::erased::ArrayRef, right_bit_width: u8, left_parts_patches: core::option::Option<vortex_array::patches::Patches>) -> vortex_error::VortexResult<Self>
254-
255231
impl core::clone::Clone for vortex_alp::ALPRDData
256232

257233
pub fn vortex_alp::ALPRDData::clone(&self) -> vortex_alp::ALPRDData
@@ -260,6 +236,14 @@ impl core::fmt::Debug for vortex_alp::ALPRDData
260236

261237
pub fn vortex_alp::ALPRDData::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
262238

239+
impl vortex_array::hash::ArrayEq for vortex_alp::ALPRDData
240+
241+
pub fn vortex_alp::ALPRDData::array_eq(&self, other: &Self, precision: vortex_array::hash::Precision) -> bool
242+
243+
impl vortex_array::hash::ArrayHash for vortex_alp::ALPRDData
244+
245+
pub fn vortex_alp::ALPRDData::array_hash<H: core::hash::Hasher>(&self, state: &mut H, precision: vortex_array::hash::Precision)
246+
263247
pub struct vortex_alp::ALPRDDataParts
264248

265249
pub vortex_alp::ALPRDDataParts::left_parts: vortex_array::array::erased::ArrayRef
@@ -346,6 +330,30 @@ pub fn vortex_alp::RDEncoder::from_parts(right_bit_width: u8, codes: alloc::vec:
346330

347331
pub fn vortex_alp::RDEncoder::new<T>(sample: &[T]) -> Self where T: vortex_alp::ALPRDFloat + vortex_array::dtype::ptype::NativePType, <T as vortex_alp::ALPRDFloat>::UINT: vortex_array::dtype::ptype::NativePType
348332

333+
pub trait vortex_alp::ALPArrayExt: vortex_array::array::typed::TypedArrayRef<vortex_alp::ALP>
334+
335+
pub fn vortex_alp::ALPArrayExt::encoded(&self) -> &vortex_array::array::erased::ArrayRef
336+
337+
pub fn vortex_alp::ALPArrayExt::exponents(&self) -> vortex_alp::Exponents
338+
339+
pub fn vortex_alp::ALPArrayExt::patches(&self) -> core::option::Option<vortex_array::patches::Patches>
340+
341+
impl<T: vortex_array::array::typed::TypedArrayRef<vortex_alp::ALP>> vortex_alp::ALPArrayExt for T
342+
343+
pub fn T::encoded(&self) -> &vortex_array::array::erased::ArrayRef
344+
345+
pub fn T::exponents(&self) -> vortex_alp::Exponents
346+
347+
pub fn T::patches(&self) -> core::option::Option<vortex_array::patches::Patches>
348+
349+
pub trait vortex_alp::ALPArrayOwnedExt
350+
351+
pub fn vortex_alp::ALPArrayOwnedExt::into_parts(self) -> (vortex_array::array::erased::ArrayRef, vortex_alp::Exponents, core::option::Option<vortex_array::patches::Patches>)
352+
353+
impl vortex_alp::ALPArrayOwnedExt for vortex_array::array::typed::Array<vortex_alp::ALP>
354+
355+
pub fn vortex_array::array::typed::Array<vortex_alp::ALP>::into_parts(self) -> (vortex_array::array::erased::ArrayRef, vortex_alp::Exponents, core::option::Option<vortex_array::patches::Patches>)
356+
349357
pub trait vortex_alp::ALPFloat: vortex_alp::alp::private::Sealed + num_traits::float::Float + core::fmt::Display + vortex_array::dtype::ptype::NativePType
350358

351359
pub type vortex_alp::ALPFloat::ALPInt: num_traits::int::PrimInt + core::fmt::Display + num_traits::cast::ToPrimitive + core::marker::Copy + vortex_array::dtype::ptype::NativePType + core::convert::Into<vortex_array::scalar::typed_view::primitive::pvalue::PValue>
@@ -478,6 +486,38 @@ pub fn f64::find_best_exponents(values: &[Self]) -> vortex_alp::Exponents
478486

479487
pub fn f64::from_int(n: Self::ALPInt) -> Self
480488

489+
pub trait vortex_alp::ALPRDArrayExt: vortex_array::array::typed::TypedArrayRef<vortex_alp::ALPRD>
490+
491+
pub fn vortex_alp::ALPRDArrayExt::left_parts(&self) -> &vortex_array::array::erased::ArrayRef
492+
493+
pub fn vortex_alp::ALPRDArrayExt::left_parts_dictionary(&self) -> &vortex_buffer::buffer::Buffer<u16>
494+
495+
pub fn vortex_alp::ALPRDArrayExt::left_parts_patches(&self) -> core::option::Option<vortex_array::patches::Patches>
496+
497+
pub fn vortex_alp::ALPRDArrayExt::right_bit_width(&self) -> u8
498+
499+
pub fn vortex_alp::ALPRDArrayExt::right_parts(&self) -> &vortex_array::array::erased::ArrayRef
500+
501+
impl<T: vortex_array::array::typed::TypedArrayRef<vortex_alp::ALPRD>> vortex_alp::ALPRDArrayExt for T
502+
503+
pub fn T::left_parts(&self) -> &vortex_array::array::erased::ArrayRef
504+
505+
pub fn T::left_parts_dictionary(&self) -> &vortex_buffer::buffer::Buffer<u16>
506+
507+
pub fn T::left_parts_patches(&self) -> core::option::Option<vortex_array::patches::Patches>
508+
509+
pub fn T::right_bit_width(&self) -> u8
510+
511+
pub fn T::right_parts(&self) -> &vortex_array::array::erased::ArrayRef
512+
513+
pub trait vortex_alp::ALPRDArrayOwnedExt
514+
515+
pub fn vortex_alp::ALPRDArrayOwnedExt::into_data_parts(self) -> vortex_alp::ALPRDDataParts
516+
517+
impl vortex_alp::ALPRDArrayOwnedExt for vortex_array::array::typed::Array<vortex_alp::ALPRD>
518+
519+
pub fn vortex_array::array::typed::Array<vortex_alp::ALPRD>::into_data_parts(self) -> vortex_alp::ALPRDDataParts
520+
481521
pub trait vortex_alp::ALPRDFloat: vortex_alp::alp_rd::private::Sealed + num_traits::float::Float + core::marker::Copy + vortex_array::dtype::ptype::NativePType
482522

483523
pub type vortex_alp::ALPRDFloat::UINT: vortex_array::dtype::ptype::NativePType + num_traits::int::PrimInt + num_traits::identities::One + core::marker::Copy

0 commit comments

Comments
 (0)