diff --git a/vortex-array/public-api.lock b/vortex-array/public-api.lock index 629dcd50d4f..16ee5ff93c0 100644 --- a/vortex-array/public-api.lock +++ b/vortex-array/public-api.lock @@ -3878,6 +3878,34 @@ pub type vortex_array::arrays::primitive::PrimitiveArray = vortex_array::Array + +pub vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayParts::children: alloc::vec::Vec + +pub vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayParts::options: ::Options + +pub struct vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin(_) + +impl vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::new(vtable: V) -> Self + +impl vortex_array::ArrayPlugin for vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::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 + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::id(&self) -> vortex_array::ArrayId + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> vortex_error::VortexResult>> + +pub trait vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayVTable: vortex_array::scalar_fn::ScalarFnVTable + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayVTable::deserialize(&self, dtype: &vortex_array::dtype::DType, len: usize, metadata: &[u8], children: &dyn vortex_array::serde::ArrayChildren, session: &vortex_session::VortexSession) -> vortex_error::VortexResult> + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayVTable::serialize(&self, view: &vortex_array::arrays::scalar_fn::ScalarFnArrayView<'_, Self>, session: &vortex_session::VortexSession) -> vortex_error::VortexResult>> + pub struct vortex_array::arrays::scalar_fn::AnyScalarFn impl core::fmt::Debug for vortex_array::arrays::scalar_fn::AnyScalarFn @@ -3922,34 +3950,6 @@ pub type vortex_array::arrays::scalar_fn::ScalarFnArrayView<'_, F>::Target = vor pub fn vortex_array::arrays::scalar_fn::ScalarFnArrayView<'_, F>::deref(&self) -> &Self::Target -pub struct vortex_array::arrays::scalar_fn::ScalarFnData - -impl vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::build(scalar_fn: vortex_array::scalar_fn::ScalarFnRef, children: alloc::vec::Vec, len: usize) -> vortex_error::VortexResult - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::scalar_fn(&self) -> &vortex_array::scalar_fn::ScalarFnRef - -impl core::clone::Clone for vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::clone(&self) -> vortex_array::arrays::scalar_fn::ScalarFnData - -impl core::fmt::Debug for vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result - -impl core::fmt::Display for vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result - -impl vortex_array::ArrayEq for vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::array_eq(&self, other: &Self, _precision: vortex_array::Precision) -> bool - -impl vortex_array::ArrayHash for vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::array_hash(&self, state: &mut H, _precision: vortex_array::Precision) - pub struct vortex_array::arrays::scalar_fn::ScalarFnVTable impl core::clone::Clone for vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -3966,7 +3966,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::scalar_at(array: vortex_ impl vortex_array::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable -pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::ScalarFnData +pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::array::ScalarFnData pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::OperationsVTable = vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -4002,7 +4002,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::serialize(_array: vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: vortex_array::ArrayView<'_, Self>, idx: usize) -> alloc::string::String -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::array::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> impl vortex_array::ValidityVTable for vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -6400,7 +6400,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::scalar_at(array: vortex_ impl vortex_array::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable -pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::ScalarFnData +pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::array::ScalarFnData pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::OperationsVTable = vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -6436,7 +6436,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::serialize(_array: vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: vortex_array::ArrayView<'_, Self>, idx: usize) -> alloc::string::String -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::array::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> impl vortex_array::ValidityVTable for vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -19422,6 +19422,14 @@ pub fn V::id(&self) -> arcref::ArcRef pub fn V::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> core::result::Result>, vortex_error::VortexError> +impl vortex_array::ArrayPlugin for vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::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 + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::id(&self) -> vortex_array::ArrayId + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> vortex_error::VortexResult>> + pub trait vortex_array::vtable::ArrayVTable: 'static + core::clone::Clone + core::marker::Sized + core::marker::Send + core::marker::Sync + core::fmt::Debug pub type vortex_array::vtable::ArrayVTable::ArrayData: 'static + core::marker::Send + core::marker::Sync + core::clone::Clone + core::fmt::Debug + core::fmt::Display + vortex_array::ArrayHash + vortex_array::ArrayEq @@ -20224,7 +20232,7 @@ pub fn vortex_array::arrays::patched::Patched::validate(&self, data: &vortex_arr impl vortex_array::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable -pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::ScalarFnData +pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::array::ScalarFnData pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::OperationsVTable = vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -20260,7 +20268,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::serialize(_array: vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: vortex_array::ArrayView<'_, Self>, idx: usize) -> alloc::string::String -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::array::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> impl vortex_array::VTable for vortex_array::arrays::slice::Slice @@ -21196,7 +21204,7 @@ pub fn vortex_array::arrays::patched::Patched::validate(&self, data: &vortex_arr impl vortex_array::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable -pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::ScalarFnData +pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::array::ScalarFnData pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::OperationsVTable = vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -21232,7 +21240,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::serialize(_array: vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: vortex_array::ArrayView<'_, Self>, idx: usize) -> alloc::string::String -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::array::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> impl vortex_array::VTable for vortex_array::arrays::slice::Slice @@ -22884,10 +22892,6 @@ impl vortex_array::ArrayEq for vortex_array::arrays::primitive::PrimitiveData pub fn vortex_array::arrays::primitive::PrimitiveData::array_eq(&self, other: &Self, precision: vortex_array::Precision) -> bool -impl vortex_array::ArrayEq for vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::array_eq(&self, other: &Self, _precision: vortex_array::Precision) -> bool - impl vortex_array::ArrayEq for vortex_array::arrays::shared::SharedData pub fn vortex_array::arrays::shared::SharedData::array_eq(&self, _other: &Self, _precision: vortex_array::Precision) -> bool @@ -22996,10 +23000,6 @@ impl vortex_array::ArrayHash for vortex_array::arrays::primitive::PrimitiveData pub fn vortex_array::arrays::primitive::PrimitiveData::array_hash(&self, state: &mut H, precision: vortex_array::Precision) -impl vortex_array::ArrayHash for vortex_array::arrays::scalar_fn::ScalarFnData - -pub fn vortex_array::arrays::scalar_fn::ScalarFnData::array_hash(&self, state: &mut H, _precision: vortex_array::Precision) - impl vortex_array::ArrayHash for vortex_array::arrays::shared::SharedData pub fn vortex_array::arrays::shared::SharedData::array_hash(&self, _state: &mut H, _precision: vortex_array::Precision) @@ -23076,6 +23076,22 @@ pub fn V::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_sess pub fn V::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> core::result::Result>, vortex_error::VortexError> +impl vortex_array::ArrayPlugin for vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin + +impl vortex_array::ArrayPlugin for vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::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 + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::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 + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::id(&self) -> vortex_array::ArrayId + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::id(&self) -> vortex_array::ArrayId + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> vortex_error::VortexResult>> + +pub fn vortex_array::arrays::scalar_fn::plugin::ScalarFnArrayPlugin::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> vortex_error::VortexResult>> + pub trait vortex_array::ArrayVTable: 'static + core::clone::Clone + core::marker::Sized + core::marker::Send + core::marker::Sync + core::fmt::Debug pub type vortex_array::ArrayVTable::ArrayData: 'static + core::marker::Send + core::marker::Sync + core::clone::Clone + core::fmt::Debug + core::fmt::Display + vortex_array::ArrayHash + vortex_array::ArrayEq @@ -23878,7 +23894,7 @@ pub fn vortex_array::arrays::patched::Patched::validate(&self, data: &vortex_arr impl vortex_array::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable -pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::ScalarFnData +pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::array::ScalarFnData pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::OperationsVTable = vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -23914,7 +23930,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::serialize(_array: vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: vortex_array::ArrayView<'_, Self>, idx: usize) -> alloc::string::String -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::array::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> impl vortex_array::VTable for vortex_array::arrays::slice::Slice @@ -25098,7 +25114,7 @@ pub fn vortex_array::arrays::patched::Patched::validate(&self, data: &vortex_arr impl vortex_array::VTable for vortex_array::arrays::scalar_fn::ScalarFnVTable -pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::ScalarFnData +pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::ArrayData = vortex_array::arrays::scalar_fn::array::ScalarFnData pub type vortex_array::arrays::scalar_fn::ScalarFnVTable::OperationsVTable = vortex_array::arrays::scalar_fn::ScalarFnVTable @@ -25134,7 +25150,7 @@ pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::serialize(_array: vortex pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::slot_name(array: vortex_array::ArrayView<'_, Self>, idx: usize) -> alloc::string::String -pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> +pub fn vortex_array::arrays::scalar_fn::ScalarFnVTable::validate(&self, data: &vortex_array::arrays::scalar_fn::array::ScalarFnData, dtype: &vortex_array::dtype::DType, len: usize, slots: &[core::option::Option]) -> vortex_error::VortexResult<()> impl vortex_array::VTable for vortex_array::arrays::slice::Slice diff --git a/vortex-array/src/arrays/scalar_fn/array.rs b/vortex-array/src/arrays/scalar_fn/array.rs index 6e568f7aa08..d7d0118d02e 100644 --- a/vortex-array/src/arrays/scalar_fn/array.rs +++ b/vortex-array/src/arrays/scalar_fn/array.rs @@ -92,7 +92,7 @@ impl Array { let arg_dtypes: Vec<_> = children.iter().map(|c| c.dtype().clone()).collect(); let dtype = scalar_fn.return_dtype(&arg_dtypes)?; let data = ScalarFnData::build(scalar_fn.clone(), children.clone(), len)?; - let vtable = ScalarFnVTable { scalar_fn }; + let vtable = ScalarFnVTable { id: scalar_fn.id() }; Ok(unsafe { Array::from_parts_unchecked( ArrayParts::new(vtable, dtype, len, data) diff --git a/vortex-array/src/arrays/scalar_fn/mod.rs b/vortex-array/src/arrays/scalar_fn/mod.rs index 9d2e9e66ed8..6c508dcad96 100644 --- a/vortex-array/src/arrays/scalar_fn/mod.rs +++ b/vortex-array/src/arrays/scalar_fn/mod.rs @@ -2,10 +2,10 @@ // SPDX-FileCopyrightText: Copyright the Vortex contributors mod array; +pub mod plugin; mod rules; mod vtable; pub use array::ScalarFnArrayExt; -pub use array::ScalarFnData; pub use vtable::ScalarFnFactoryExt; pub use vtable::*; diff --git a/vortex-array/src/arrays/scalar_fn/plugin.rs b/vortex-array/src/arrays/scalar_fn/plugin.rs new file mode 100644 index 00000000000..1fb656323d9 --- /dev/null +++ b/vortex-array/src/arrays/scalar_fn/plugin.rs @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use vortex_error::VortexResult; +use vortex_session::VortexSession; + +use crate::ArrayId; +use crate::ArrayPlugin; +use crate::ArrayRef; +use crate::IntoArray; +use crate::arrays::ScalarFnArray; +use crate::arrays::scalar_fn::ExactScalarFn; +use crate::arrays::scalar_fn::ScalarFnArrayView; +use crate::buffer::BufferHandle; +use crate::dtype::DType; +use crate::scalar_fn::ScalarFn; +use crate::scalar_fn::ScalarFnVTable; +use crate::serde::ArrayChildren; + +/// An adapter for enabling a scalar function to be serialized as an array. +pub struct ScalarFnArrayPlugin(V); + +impl ScalarFnArrayPlugin { + /// Create a new plugin for the given scalar function vtable. + pub fn new(vtable: V) -> Self { + Self(vtable) + } +} + +pub trait ScalarFnArrayVTable: ScalarFnVTable { + /// Serialize metadata for storing the scalar function as an array. + /// + /// Notably, this metadata needs enough information to reconstruct the child DTypes, as well + /// as the scalar function's own options. + fn serialize( + &self, + view: &ScalarFnArrayView, + session: &VortexSession, + ) -> VortexResult>>; + + /// Deserialize a scalar function array from its serialized components. + fn deserialize( + &self, + dtype: &DType, + len: usize, + metadata: &[u8], + children: &dyn ArrayChildren, + session: &VortexSession, + ) -> VortexResult>; +} + +/// The parts used to construct a ScalarFnArray. +pub struct ScalarFnArrayParts { + pub options: V::Options, + pub children: Vec, +} + +impl ArrayPlugin for ScalarFnArrayPlugin { + fn id(&self) -> ArrayId { + self.0.id() + } + + fn serialize( + &self, + array: &ArrayRef, + session: &VortexSession, + ) -> VortexResult>> { + // We serialize the scalar function options, along with any scalar function array data. + let scalar_fn = array.as_::>(); + ::serialize(&self.0, &scalar_fn, session) + } + + fn deserialize( + &self, + dtype: &DType, + len: usize, + metadata: &[u8], + _buffers: &[BufferHandle], + children: &dyn ArrayChildren, + session: &VortexSession, + ) -> VortexResult { + let parts = ::deserialize( + &self.0, dtype, len, metadata, children, session, + )?; + Ok(ScalarFnArray::try_new( + ScalarFn::new(self.0.clone(), parts.options).erased(), + parts.children, + len, + )? + .into_array()) + } +} diff --git a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs index 996fbee1046..c663ddfc64e 100644 --- a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs +++ b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs @@ -41,7 +41,6 @@ use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; use crate::scalar_fn::ExecutionArgs; use crate::scalar_fn::ScalarFnId; -use crate::scalar_fn::ScalarFnRef; use crate::scalar_fn::ScalarFnVTableExt; use crate::scalar_fn::VecExecutionArgs; use crate::serde::ArrayChildren; @@ -51,7 +50,7 @@ pub type ScalarFnArray = Array; #[derive(Clone, Debug)] pub struct ScalarFnVTable { - pub(super) scalar_fn: ScalarFnRef, + pub(super) id: ScalarFnId, } impl ArrayHash for ScalarFnData { @@ -72,7 +71,7 @@ impl VTable for ScalarFnVTable { type ValidityVTable = Self; fn id(&self) -> ArrayId { - self.scalar_fn.id() + self.id.clone() } fn validate( @@ -83,7 +82,7 @@ impl VTable for ScalarFnVTable { slots: &[Option], ) -> VortexResult<()> { vortex_ensure!( - data.scalar_fn == self.scalar_fn, + data.scalar_fn.id() == self.id, "ScalarFnArray data scalar_fn does not match vtable" ); vortex_ensure!( @@ -97,7 +96,7 @@ impl VTable for ScalarFnVTable { .map(|c| c.dtype().clone()) .collect_vec(); vortex_ensure!( - self.scalar_fn.return_dtype(&child_dtypes)? == *dtype, + data.scalar_fn.return_dtype(&child_dtypes)? == *dtype, "ScalarFnArray dtype does not match scalar function return dtype" ); Ok(()) @@ -128,7 +127,6 @@ impl VTable for ScalarFnVTable { _dtype: &DType, _len: usize, _metadata: &[u8], - _buffers: &[BufferHandle], _children: &dyn ArrayChildren, _session: &VortexSession, @@ -189,7 +187,7 @@ pub trait ScalarFnFactoryExt: scalar_fn::ScalarFnVTable { let data = ScalarFnData { scalar_fn: scalar_fn.clone(), }; - let vtable = ScalarFnVTable { scalar_fn }; + let vtable = ScalarFnVTable { id: scalar_fn.id() }; Ok(unsafe { Array::from_parts_unchecked( ArrayParts::new(vtable, dtype, len, data)