Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions encodings/fastlanes/src/bitpacking/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ impl ArrayPlugin for BitPackedPatchedPlugin {

Ok(patched.into_array())
}

fn is_supported_encoding(&self, id: &ArrayId) -> bool {
id == &BitPacked::ID || id == &Patched.id()
}
}

#[cfg(test)]
Expand Down
12 changes: 12 additions & 0 deletions vortex-array/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19412,6 +19412,8 @@ pub fn vortex_array::vtable::ArrayPlugin::deserialize(&self, dtype: &vortex_arra

pub fn vortex_array::vtable::ArrayPlugin::id(&self) -> vortex_array::ArrayId

pub fn vortex_array::vtable::ArrayPlugin::is_supported_encoding(&self, id: &vortex_array::ArrayId) -> bool

pub fn vortex_array::vtable::ArrayPlugin::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> vortex_error::VortexResult<core::option::Option<alloc::vec::Vec<u8>>>

impl<V: vortex_array::VTable> vortex_array::ArrayPlugin for V
Expand All @@ -19420,6 +19422,8 @@ pub fn V::deserialize(&self, dtype: &vortex_array::dtype::DType, len: usize, met

pub fn V::id(&self) -> arcref::ArcRef<str>

pub fn V::is_supported_encoding(&self, id: &vortex_array::ArrayId) -> bool

pub fn V::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> core::result::Result<core::option::Option<alloc::vec::Vec<u8>>, vortex_error::VortexError>

pub trait vortex_array::vtable::ArrayVTable: 'static + core::clone::Clone + core::marker::Sized + core::marker::Send + core::marker::Sync + core::fmt::Debug
Expand Down Expand Up @@ -23056,6 +23060,10 @@ pub fn vortex_array::ArrayPlugin::id(&self) -> vortex_array::ArrayId

pub fn vortex_array::ArrayPlugin::id(&self) -> vortex_array::ArrayId

pub fn vortex_array::ArrayPlugin::is_supported_encoding(&self, id: &vortex_array::ArrayId) -> bool

pub fn vortex_array::ArrayPlugin::is_supported_encoding(&self, id: &vortex_array::ArrayId) -> bool

pub fn vortex_array::ArrayPlugin::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> vortex_error::VortexResult<core::option::Option<alloc::vec::Vec<u8>>>

pub fn vortex_array::ArrayPlugin::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> vortex_error::VortexResult<core::option::Option<alloc::vec::Vec<u8>>>
Expand All @@ -23072,6 +23080,10 @@ pub fn V::id(&self) -> arcref::ArcRef<str>

pub fn V::id(&self) -> arcref::ArcRef<str>

pub fn V::is_supported_encoding(&self, id: &vortex_array::ArrayId) -> bool

pub fn V::is_supported_encoding(&self, id: &vortex_array::ArrayId) -> bool

pub fn V::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> core::result::Result<core::option::Option<alloc::vec::Vec<u8>>, vortex_error::VortexError>

pub fn V::serialize(&self, array: &vortex_array::ArrayRef, session: &vortex_session::VortexSession) -> core::result::Result<core::option::Option<alloc::vec::Vec<u8>>, vortex_error::VortexError>
Expand Down
11 changes: 11 additions & 0 deletions vortex-array/src/array/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub type ArrayPluginRef = Arc<dyn ArrayPlugin>;
/// [`deserialize`]: ArrayPlugin::deserialize
pub trait ArrayPlugin: 'static + Send + Sync {
/// Returns the ID for this array encoding.
///
/// During serde, this is the key the registry uses to find
/// this plugin instance and call the appropriate method on it.
fn id(&self) -> ArrayId;

/// Serialize the array metadata.
Expand All @@ -49,6 +52,14 @@ pub trait ArrayPlugin: 'static + Send + Sync {
children: &dyn ArrayChildren,
session: &VortexSession,
) -> VortexResult<ArrayRef>;

/// Can this plugin emit an array with the given encoding.
///
/// By default, this is just the [ID][Self::id] of the plugin, but
/// can be overridden if this plugin instance supports reading/writing multiple arrays.
fn is_supported_encoding(&self, id: &ArrayId) -> bool {
self.id() == *id
}
}

impl std::fmt::Debug for dyn ArrayPlugin {
Expand Down
6 changes: 3 additions & 3 deletions vortex-array/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ impl SerializedArray {
decoded.dtype(),
dtype,
);
assert_eq!(
decoded.encoding_id(),
encoding_id,

assert!(
plugin.is_supported_encoding(&decoded.encoding_id()),
"Array decoded from {} has incorrect encoding {}",
encoding_id,
decoded.encoding_id(),
Expand Down
Loading