Skip to content

Commit e50242a

Browse files
committed
Impl ArrayPlugin directly on DecimalByteParts
Signed-off-by: Matt Katz <[email protected]>
1 parent b701797 commit e50242a

4 files changed

Lines changed: 5 additions & 31 deletions

File tree

‎encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ mod split;
3131
mod testing;
3232

3333
pub use array::*;
34-
pub use plugin::DecimalBytePartsPlugin;
3534
pub use plugin::DecimalBytePartsV2Metadata;
3635
pub use plugin::decimal_byte_parts_v1_id;
3736
pub use plugin::decimal_byte_parts_v2_id;

‎encodings/decimal-byte-parts/src/decimal_byte_parts/plugin/mod.rs‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,9 @@ pub fn decimal_byte_parts_v2_id() -> ArrayId {
4444
/// Each version owns its metadata schema and serde functions. The plugin writes v1 whenever an
4545
/// array has no lower parts, so such arrays stay readable by older readers, and v2 otherwise.
4646
/// The v2 format itself accepts any lower part count up to the maximum.
47-
///
48-
/// Register this plugin, or call [`crate::initialize`], to enable both formats. Direct registration
49-
/// of [`DecimalByteParts`] does not support serde.
50-
#[derive(Clone, Debug)]
51-
pub struct DecimalBytePartsPlugin;
52-
53-
impl ArrayPlugin for DecimalBytePartsPlugin {
47+
impl ArrayPlugin for DecimalByteParts {
5448
fn id(&self) -> ArrayId {
55-
VTable::id(&DecimalByteParts)
49+
VTable::id(self)
5650
}
5751

5852
fn serialized_ids(&self) -> Vec<ArrayId> {

‎encodings/decimal-byte-parts/src/decimal_byte_parts/plugin/tests.rs‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,6 @@ fn serialization_requires_v2_permission() -> VortexResult<()> {
244244
Ok(())
245245
}
246246

247-
#[test]
248-
fn bare_vtable_refuses_serde() -> VortexResult<()> {
249-
let session = array_session();
250-
let array = DecimalByteParts::try_new(msp(), DecimalDType::new(19, 2))?.into_array();
251-
let result = session.array_serialize(&array);
252-
assert!(
253-
result.as_ref().is_err_and(|err| err
254-
.to_string()
255-
.contains("is not registered for serialization")),
256-
"expected serialization without DecimalBytePartsPlugin to fail, got {result:?}"
257-
);
258-
259-
let id = VTable::id(&DecimalByteParts);
260-
assert!(
261-
session.arrays().registry().get(&id).is_none(),
262-
"DecimalByteParts must not be deserializable without DecimalBytePartsPlugin"
263-
);
264-
Ok(())
265-
}
266-
267247
fn msp() -> ArrayRef {
268248
buffer![1i64, 2, 3].into_array()
269249
}
@@ -303,7 +283,8 @@ fn deserialize_with(
303283
children: Vec<ArrayRef>,
304284
) -> VortexResult<ArrayRef> {
305285
let dtype = DType::Decimal(DecimalDType::new(38, 2), Nullability::NonNullable);
306-
DecimalBytePartsPlugin.deserialize(
286+
ArrayPlugin::deserialize(
287+
&DecimalByteParts,
307288
ArrayDeserialization::new(serialized_id, &dtype, 3, metadata, &[], &children),
308289
&array_session(),
309290
)

‎encodings/decimal-byte-parts/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use vortex_session::VortexSession;
2424
pub fn initialize(session: &VortexSession) {
2525
// One plugin owns both serialized formats: registering it reads either ID and writes the
2626
// one that fits the array. Which of them a writer may emit is decided by its editions.
27-
session.arrays().register(DecimalBytePartsPlugin);
27+
session.arrays().register(DecimalByteParts);
2828
compute::kernel::initialize(session);
2929

3030
session.aggregate_fns().register_aggregate_kernel(

0 commit comments

Comments
 (0)