Skip to content

Commit de4eb39

Browse files
authored
ArrayPlugin (#7302)
Rename / clean up to match other VTable designs and make it easier to implement custom Array deserializers. --------- Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent cca6e9e commit de4eb39

File tree

19 files changed

+382
-397
lines changed

19 files changed

+382
-397
lines changed

docs/developer-guide/internals/session.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Plugins register with the session by accessing the relevant component and callin
4545

4646
```rust
4747
// Register a custom array encoding
48-
session.arrays().register(MyEncoding::ID, &MyEncoding);
48+
session.arrays().register(MyEncoding);
4949

5050
// Register a custom layout
5151
session.layouts().register(MyLayout::encoding());

encodings/fastlanes/src/bitpacking/compute/slice.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ mod tests {
6262

6363
let bitpacked_ref = bitpacked.into_array();
6464
let reduced = bitpacked_ref
65-
.vtable()
66-
.reduce_parent(&bitpacked_ref, &slice_array.into_array(), 0)?
65+
.reduce_parent(&slice_array.into_array(), 0)?
6766
.expect("expected slice kernel to execute");
6867

6968
assert!(reduced.is::<BitPacked>());

encodings/fastlanes/src/bitpacking/vtable/operations.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ mod test {
6363
let array_ref = array.clone().into_array();
6464
let slice_array = SliceArray::new(array_ref.clone(), range);
6565
let sliced = array_ref
66-
.vtable()
67-
.reduce_parent(&array_ref, &slice_array.into_array(), 0)
66+
.reduce_parent(&slice_array.into_array(), 0)
6867
.expect("execute_parent failed")
6968
.expect("expected slice kernel to execute");
7069
sliced.as_::<BitPacked>().into_owned()

encodings/fsst/src/array.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ mod test {
588588
use fsst::Compressor;
589589
use fsst::Symbol;
590590
use prost::Message;
591-
use vortex_array::DynVTable;
591+
use vortex_array::ArrayPlugin;
592592
use vortex_array::IntoArray;
593593
use vortex_array::LEGACY_SESSION;
594594
use vortex_array::VortexSessionExecute;
@@ -661,9 +661,8 @@ mod test {
661661
fsst_array.uncompressed_lengths().clone(),
662662
];
663663

664-
let fsst = DynVTable::build(
664+
let fsst = ArrayPlugin::deserialize(
665665
&FSST,
666-
FSST::ID,
667666
&DType::Utf8(Nullability::NonNullable),
668667
2,
669668
&FSSTMetadata {
@@ -683,7 +682,6 @@ mod test {
683682
.unwrap();
684683

685684
let decompressed = fsst
686-
.into_array()
687685
.execute::<VarBinViewArray>(&mut LEGACY_SESSION.create_execution_ctx())
688686
.unwrap();
689687
decompressed

encodings/zstd/src/zstd_buffers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ impl ZstdBuffers {
103103
})?;
104104

105105
let children: Vec<ArrayRef> = array.slots().iter().flatten().cloned().collect();
106-
inner_vtable.build(
107-
array.data().inner_encoding_id.clone(),
106+
inner_vtable.deserialize(
108107
array.dtype(),
109108
array.len(),
110109
&array.data().inner_metadata,

vortex-array/public-api.lock

Lines changed: 52 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -18350,7 +18350,7 @@ impl vortex_array::session::ArraySession
1835018350

1835118351
pub fn vortex_array::session::ArraySession::empty() -> vortex_array::session::ArraySession
1835218352

18353-
pub fn vortex_array::session::ArraySession::register<V: vortex_array::VTable>(&self, vtable: V)
18353+
pub fn vortex_array::session::ArraySession::register<P: vortex_array::ArrayPlugin>(&self, plugin: P)
1835418354

1835518355
pub fn vortex_array::session::ArraySession::registry(&self) -> &vortex_array::session::ArrayRegistry
1835618356

@@ -18370,7 +18370,7 @@ impl<S: vortex_session::SessionExt> vortex_array::session::ArraySessionExt for S
1837018370

1837118371
pub fn S::arrays(&self) -> vortex_session::Ref<'_, vortex_array::session::ArraySession>
1837218372

18373-
pub type vortex_array::session::ArrayRegistry = vortex_session::registry::Registry<vortex_array::DynVTableRef>
18373+
pub type vortex_array::session::ArrayRegistry = vortex_session::registry::Registry<vortex_array::ArrayPluginRef>
1837418374

1837518375
pub mod vortex_array::stats
1837618376

@@ -18860,6 +18860,18 @@ impl<V: vortex_array::VTable> vortex_array::ValidityVTable<V> for vortex_array::
1886018860

1886118861
pub fn vortex_array::ValidityVTableFromValiditySliceHelper::validity(array: vortex_array::ArrayView<'_, V>) -> vortex_error::VortexResult<vortex_array::validity::Validity>
1886218862

18863+
pub trait vortex_array::vtable::ArrayPlugin: 'static + core::marker::Send + core::marker::Sync
18864+
18865+
pub fn vortex_array::vtable::ArrayPlugin::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::ArrayRef>
18866+
18867+
pub fn vortex_array::vtable::ArrayPlugin::id(&self) -> vortex_array::ArrayId
18868+
18869+
impl<V: vortex_array::VTable> vortex_array::ArrayPlugin for V
18870+
18871+
pub fn V::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) -> core::result::Result<vortex_array::ArrayRef, vortex_error::VortexError>
18872+
18873+
pub fn V::id(&self) -> arcref::ArcRef<str>
18874+
1886318875
pub trait vortex_array::vtable::ArrayVTable: 'static + core::clone::Clone + core::marker::Sized + core::marker::Send + core::marker::Sync + core::fmt::Debug
1886418876

1886518877
pub type vortex_array::vtable::ArrayVTable::ArrayData: 'static + core::marker::Send + core::marker::Sync + core::clone::Clone + core::fmt::Debug + vortex_array::ArrayHash + vortex_array::ArrayEq
@@ -19784,38 +19796,6 @@ pub fn vortex_array::arrays::slice::Slice::slot_name(_array: vortex_array::Array
1978419796

1978519797
pub fn vortex_array::arrays::slice::Slice::validate(&self, data: &Self::ArrayData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option<vortex_array::ArrayRef>]) -> vortex_error::VortexResult<()>
1978619798

19787-
pub trait vortex_array::vtable::DynVTable: 'static + core::marker::Send + core::marker::Sync + core::fmt::Debug
19788-
19789-
pub fn vortex_array::vtable::DynVTable::build(&self, id: vortex_array::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<vortex_array::ArrayRef>
19790-
19791-
pub fn vortex_array::vtable::DynVTable::clone_boxed(&self) -> alloc::boxed::Box<dyn vortex_array::DynVTable>
19792-
19793-
pub fn vortex_array::vtable::DynVTable::execute(&self, array: vortex_array::ArrayRef, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ExecutionResult>
19794-
19795-
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<core::option::Option<vortex_array::ArrayRef>>
19796-
19797-
pub fn vortex_array::vtable::DynVTable::reduce(&self, array: &vortex_array::ArrayRef) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
19798-
19799-
pub fn vortex_array::vtable::DynVTable::reduce_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
19800-
19801-
pub fn vortex_array::vtable::DynVTable::with_slots(&self, array: vortex_array::ArrayRef, slots: alloc::vec::Vec<core::option::Option<vortex_array::ArrayRef>>) -> vortex_error::VortexResult<vortex_array::ArrayRef>
19802-
19803-
impl<V: vortex_array::VTable> vortex_array::DynVTable for V
19804-
19805-
pub fn V::build(&self, _id: arcref::ArcRef<str>, dtype: &vortex_array::dtype::DType, len: usize, metadata: &[u8], buffers: &[vortex_array::buffer::BufferHandle], children: &dyn vortex_array::serde::ArrayChildren, session: &vortex_session::VortexSession) -> core::result::Result<vortex_array::ArrayRef, vortex_error::VortexError>
19806-
19807-
pub fn V::clone_boxed(&self) -> alloc::boxed::Box<dyn vortex_array::DynVTable>
19808-
19809-
pub fn V::execute(&self, array: vortex_array::ArrayRef, ctx: &mut vortex_array::ExecutionCtx) -> core::result::Result<vortex_array::ExecutionResult, vortex_error::VortexError>
19810-
19811-
pub fn V::execute_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize, ctx: &mut vortex_array::ExecutionCtx) -> core::result::Result<core::option::Option<vortex_array::ArrayRef>, vortex_error::VortexError>
19812-
19813-
pub fn V::reduce(&self, array: &vortex_array::ArrayRef) -> core::result::Result<core::option::Option<vortex_array::ArrayRef>, vortex_error::VortexError>
19814-
19815-
pub fn V::reduce_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize) -> core::result::Result<core::option::Option<vortex_array::ArrayRef>, vortex_error::VortexError>
19816-
19817-
pub fn V::with_slots(&self, array: vortex_array::ArrayRef, slots: alloc::vec::Vec<core::option::Option<vortex_array::ArrayRef>>) -> core::result::Result<vortex_array::ArrayRef, vortex_error::VortexError>
19818-
1981919799
pub trait vortex_array::vtable::OperationsVTable<V: vortex_array::VTable>
1982019800

1982119801
pub fn vortex_array::vtable::OperationsVTable::scalar_at(array: vortex_array::ArrayView<'_, V>, index: usize, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::scalar::Scalar>
@@ -20960,7 +20940,7 @@ pub fn vortex_array::vtable::validity_nchildren(validity: &vortex_array::validit
2096020940

2096120941
pub fn vortex_array::vtable::validity_to_child(validity: &vortex_array::validity::Validity, len: usize) -> core::option::Option<vortex_array::ArrayRef>
2096220942

20963-
pub type vortex_array::vtable::DynVTableRef = alloc::sync::Arc<dyn vortex_array::DynVTable>
20943+
pub type vortex_array::vtable::ArrayPluginRef = alloc::sync::Arc<dyn vortex_array::ArrayPlugin>
2096420944

2096520945
pub macro vortex_array::field_path!
2096620946

@@ -21710,6 +21690,8 @@ pub fn vortex_array::ArrayRef::dtype(&self) -> &vortex_array::dtype::DType
2171021690

2171121691
pub fn vortex_array::ArrayRef::encoding_id(&self) -> vortex_array::ArrayId
2171221692

21693+
pub fn vortex_array::ArrayRef::execute_parent(&self, parent: &vortex_array::ArrayRef, child_idx: usize, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
21694+
2171321695
pub fn vortex_array::ArrayRef::filter(&self, mask: vortex_mask::Mask) -> vortex_error::VortexResult<vortex_array::ArrayRef>
2171421696

2171521697
pub fn vortex_array::ArrayRef::into_canonical(self) -> vortex_error::VortexResult<vortex_array::Canonical>
@@ -21750,6 +21732,10 @@ pub fn vortex_array::ArrayRef::nchildren(&self) -> usize
2175021732

2175121733
pub fn vortex_array::ArrayRef::nth_child(&self, idx: usize) -> core::option::Option<vortex_array::ArrayRef>
2175221734

21735+
pub fn vortex_array::ArrayRef::reduce(&self) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
21736+
21737+
pub fn vortex_array::ArrayRef::reduce_parent(&self, parent: &vortex_array::ArrayRef, child_idx: usize) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
21738+
2175321739
pub fn vortex_array::ArrayRef::scalar_at(&self, index: usize) -> vortex_error::VortexResult<vortex_array::scalar::Scalar>
2175421740

2175521741
pub fn vortex_array::ArrayRef::slice(&self, range: core::ops::range::Range<usize>) -> vortex_error::VortexResult<vortex_array::ArrayRef>
@@ -21772,10 +21758,10 @@ pub fn vortex_array::ArrayRef::validity(&self) -> vortex_error::VortexResult<vor
2177221758

2177321759
pub fn vortex_array::ArrayRef::validity_mask(&self) -> vortex_error::VortexResult<vortex_mask::Mask>
2177421760

21775-
pub fn vortex_array::ArrayRef::vtable(&self) -> &dyn vortex_array::DynVTable
21776-
2177721761
pub fn vortex_array::ArrayRef::with_slot(self, slot_idx: usize, replacement: vortex_array::ArrayRef) -> vortex_error::VortexResult<vortex_array::ArrayRef>
2177821762

21763+
pub fn vortex_array::ArrayRef::with_slots(self, slots: alloc::vec::Vec<core::option::Option<vortex_array::ArrayRef>>) -> vortex_error::VortexResult<vortex_array::ArrayRef>
21764+
2177921765
impl vortex_array::ArrayRef
2178021766

2178121767
pub fn vortex_array::ArrayRef::apply(self, expr: &vortex_array::expr::Expression) -> vortex_error::VortexResult<vortex_array::ArrayRef>
@@ -22600,6 +22586,30 @@ impl<T: vortex_array::ArrayHash> vortex_array::ArrayHash for core::option::Optio
2260022586

2260122587
pub fn core::option::Option<T>::array_hash<H: core::hash::Hasher>(&self, state: &mut H, precision: vortex_array::Precision)
2260222588

22589+
pub trait vortex_array::ArrayPlugin: 'static + core::marker::Send + core::marker::Sync
22590+
22591+
pub trait vortex_array::ArrayPlugin: 'static + core::marker::Send + core::marker::Sync
22592+
22593+
pub fn vortex_array::ArrayPlugin::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::ArrayRef>
22594+
22595+
pub fn vortex_array::ArrayPlugin::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::ArrayRef>
22596+
22597+
pub fn vortex_array::ArrayPlugin::id(&self) -> vortex_array::ArrayId
22598+
22599+
pub fn vortex_array::ArrayPlugin::id(&self) -> vortex_array::ArrayId
22600+
22601+
impl<V: vortex_array::VTable> vortex_array::ArrayPlugin for V
22602+
22603+
impl<V: vortex_array::VTable> vortex_array::ArrayPlugin for V
22604+
22605+
pub fn V::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) -> core::result::Result<vortex_array::ArrayRef, vortex_error::VortexError>
22606+
22607+
pub fn V::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) -> core::result::Result<vortex_array::ArrayRef, vortex_error::VortexError>
22608+
22609+
pub fn V::id(&self) -> arcref::ArcRef<str>
22610+
22611+
pub fn V::id(&self) -> arcref::ArcRef<str>
22612+
2260322613
pub trait vortex_array::ArrayVTable: 'static + core::clone::Clone + core::marker::Sized + core::marker::Send + core::marker::Sync + core::fmt::Debug
2260422614

2260522615
pub type vortex_array::ArrayVTable::ArrayData: 'static + core::marker::Send + core::marker::Sync + core::clone::Clone + core::fmt::Debug + vortex_array::ArrayHash + vortex_array::ArrayEq
@@ -23564,38 +23574,6 @@ impl<T: vortex_array::ArrayHash + ?core::marker::Sized> vortex_array::DynArrayHa
2356423574

2356523575
pub fn T::dyn_array_hash(&self, state: &mut dyn core::hash::Hasher, precision: vortex_array::Precision)
2356623576

23567-
pub trait vortex_array::DynVTable: 'static + core::marker::Send + core::marker::Sync + core::fmt::Debug
23568-
23569-
pub fn vortex_array::DynVTable::build(&self, id: vortex_array::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<vortex_array::ArrayRef>
23570-
23571-
pub fn vortex_array::DynVTable::clone_boxed(&self) -> alloc::boxed::Box<dyn vortex_array::DynVTable>
23572-
23573-
pub fn vortex_array::DynVTable::execute(&self, array: vortex_array::ArrayRef, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::ExecutionResult>
23574-
23575-
pub fn vortex_array::DynVTable::execute_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
23576-
23577-
pub fn vortex_array::DynVTable::reduce(&self, array: &vortex_array::ArrayRef) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
23578-
23579-
pub fn vortex_array::DynVTable::reduce_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
23580-
23581-
pub fn vortex_array::DynVTable::with_slots(&self, array: vortex_array::ArrayRef, slots: alloc::vec::Vec<core::option::Option<vortex_array::ArrayRef>>) -> vortex_error::VortexResult<vortex_array::ArrayRef>
23582-
23583-
impl<V: vortex_array::VTable> vortex_array::DynVTable for V
23584-
23585-
pub fn V::build(&self, _id: arcref::ArcRef<str>, dtype: &vortex_array::dtype::DType, len: usize, metadata: &[u8], buffers: &[vortex_array::buffer::BufferHandle], children: &dyn vortex_array::serde::ArrayChildren, session: &vortex_session::VortexSession) -> core::result::Result<vortex_array::ArrayRef, vortex_error::VortexError>
23586-
23587-
pub fn V::clone_boxed(&self) -> alloc::boxed::Box<dyn vortex_array::DynVTable>
23588-
23589-
pub fn V::execute(&self, array: vortex_array::ArrayRef, ctx: &mut vortex_array::ExecutionCtx) -> core::result::Result<vortex_array::ExecutionResult, vortex_error::VortexError>
23590-
23591-
pub fn V::execute_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize, ctx: &mut vortex_array::ExecutionCtx) -> core::result::Result<core::option::Option<vortex_array::ArrayRef>, vortex_error::VortexError>
23592-
23593-
pub fn V::reduce(&self, array: &vortex_array::ArrayRef) -> core::result::Result<core::option::Option<vortex_array::ArrayRef>, vortex_error::VortexError>
23594-
23595-
pub fn V::reduce_parent(&self, array: &vortex_array::ArrayRef, parent: &vortex_array::ArrayRef, child_idx: usize) -> core::result::Result<core::option::Option<vortex_array::ArrayRef>, vortex_error::VortexError>
23596-
23597-
pub fn V::with_slots(&self, array: vortex_array::ArrayRef, slots: alloc::vec::Vec<core::option::Option<vortex_array::ArrayRef>>) -> core::result::Result<vortex_array::ArrayRef, vortex_error::VortexError>
23598-
2359923577
pub trait vortex_array::Executable: core::marker::Sized
2360023578

2360123579
pub fn vortex_array::Executable::execute(array: vortex_array::ArrayRef, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<Self>
@@ -24956,10 +24934,12 @@ pub fn vortex_array::validity_nchildren(validity: &vortex_array::validity::Valid
2495624934

2495724935
pub fn vortex_array::validity_to_child(validity: &vortex_array::validity::Validity, len: usize) -> core::option::Option<vortex_array::ArrayRef>
2495824936

24959-
pub type vortex_array::ArrayContext = vortex_session::registry::Context<vortex_array::DynVTableRef>
24937+
pub type vortex_array::ArrayContext = vortex_session::registry::Context<vortex_array::ArrayPluginRef>
2496024938

2496124939
pub type vortex_array::ArrayId = arcref::ArcRef<str>
2496224940

24963-
pub type vortex_array::DonePredicate = fn(&vortex_array::ArrayRef) -> bool
24941+
pub type vortex_array::ArrayPluginRef = alloc::sync::Arc<dyn vortex_array::ArrayPlugin>
24942+
24943+
pub type vortex_array::ArrayPluginRef = alloc::sync::Arc<dyn vortex_array::ArrayPlugin>
2496424944

24965-
pub type vortex_array::DynVTableRef = alloc::sync::Arc<dyn vortex_array::DynVTable>
24945+
pub type vortex_array::DonePredicate = fn(&vortex_array::ArrayRef) -> bool

0 commit comments

Comments
 (0)