Skip to content

Commit ebd37e1

Browse files
authored
Remove EncodeVTable (#6036)
Having an EncodeVTable implies the caller knows the target encoding. Instead we want to have pluggable "compressors", where the output array could be anything. Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent 2162a15 commit ebd37e1

File tree

51 files changed

+86
-611
lines changed

Some content is hidden

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

51 files changed

+86
-611
lines changed

encodings/alp/src/alp/array.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use vortex_array::vtable::ArrayVTable;
3030
use vortex_array::vtable::ArrayVTableExt;
3131
use vortex_array::vtable::BaseArrayVTable;
3232
use vortex_array::vtable::CanonicalVTable;
33-
use vortex_array::vtable::EncodeVTable;
3433
use vortex_array::vtable::NotSupported;
3534
use vortex_array::vtable::VTable;
3635
use vortex_array::vtable::ValidityChild;
@@ -47,7 +46,6 @@ use vortex_error::vortex_err;
4746

4847
use crate::ALPFloat;
4948
use crate::alp::Exponents;
50-
use crate::alp::alp_encode;
5149
use crate::alp::decompress::decompress_into_array;
5250
use crate::alp::decompress::execute_decompress;
5351

@@ -64,7 +62,6 @@ impl VTable for ALPVTable {
6462
type ValidityVTable = ValidityVTableFromChild;
6563
type VisitorVTable = Self;
6664
type ComputeVTable = NotSupported;
67-
type EncodeVTable = Self;
6865

6966
fn id(&self) -> ArrayId {
7067
ArrayId::new_ref("vortex.alp")
@@ -465,20 +462,6 @@ impl CanonicalVTable<ALPVTable> for ALPVTable {
465462
}
466463
}
467464

468-
impl EncodeVTable<ALPVTable> for ALPVTable {
469-
fn encode(
470-
_vtable: &ALPVTable,
471-
canonical: &Canonical,
472-
like: Option<&ALPArray>,
473-
) -> VortexResult<Option<ALPArray>> {
474-
let parray = canonical.clone().into_primitive();
475-
let exponents = like.map(|a| a.exponents());
476-
let alp = alp_encode(&parray, exponents)?;
477-
478-
Ok(Some(alp))
479-
}
480-
}
481-
482465
impl VisitorVTable<ALPVTable> for ALPVTable {
483466
fn visit_buffers(_array: &ALPArray, _visitor: &mut dyn ArrayBufferVisitor) {}
484467

@@ -506,6 +489,7 @@ mod tests {
506489
use vortex_session::VortexSession;
507490

508491
use super::*;
492+
use crate::alp_encode;
509493

510494
static SESSION: LazyLock<VortexSession> =
511495
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());

encodings/alp/src/alp/compute/cast.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,24 @@ register_kernel!(CastKernelAdapter(ALPVTable).lift());
5151
mod tests {
5252
use rstest::rstest;
5353
use vortex_array::IntoArray;
54+
use vortex_array::ToCanonical;
5455
use vortex_array::arrays::PrimitiveArray;
5556
use vortex_array::assert_arrays_eq;
5657
use vortex_array::compute::cast;
5758
use vortex_array::compute::conformance::cast::test_cast_conformance;
58-
use vortex_array::vtable::ArrayVTableExt;
5959
use vortex_buffer::buffer;
6060
use vortex_dtype::DType;
6161
use vortex_dtype::Nullability;
6262
use vortex_dtype::PType;
6363
use vortex_error::VortexExpect;
6464
use vortex_error::VortexResult;
6565

66-
use crate::ALPVTable;
66+
use crate::alp_encode;
6767

6868
#[test]
6969
fn test_cast_alp_f32_to_f64() -> VortexResult<()> {
7070
let values = buffer![1.5f32, 2.5, 3.5, 4.5].into_array();
71-
let alp = ALPVTable
72-
.as_vtable()
73-
.encode(&values.to_canonical()?, None)?
74-
.vortex_expect("must encode");
71+
let alp = alp_encode(&values.to_primitive(), None)?;
7572

7673
let casted = cast(
7774
alp.as_ref(),
@@ -94,10 +91,7 @@ mod tests {
9491
#[test]
9592
fn test_cast_alp_to_int() -> VortexResult<()> {
9693
let values = buffer![1.0f32, 2.0, 3.0, 4.0].into_array();
97-
let alp = ALPVTable
98-
.as_vtable()
99-
.encode(&values.to_canonical()?, None)?
100-
.vortex_expect("must encode");
94+
let alp = alp_encode(&values.to_primitive(), None)?;
10195

10296
let casted = cast(
10397
alp.as_ref(),
@@ -121,10 +115,7 @@ mod tests {
121115
#[case(buffer![42.42f64].into_array())]
122116
#[case(buffer![0.0f32, -1.5, 2.5, -3.5, 4.5].into_array())]
123117
fn test_cast_alp_conformance(#[case] array: vortex_array::ArrayRef) -> VortexResult<()> {
124-
let alp = ALPVTable
125-
.as_vtable()
126-
.encode(&array.to_canonical()?, None)?
127-
.vortex_expect("cannot fail");
118+
let alp = alp_encode(&array.to_primitive(), None).vortex_expect("cannot fail");
128119
test_cast_conformance(alp.as_ref());
129120

130121
Ok(())

encodings/alp/src/alp/compute/filter.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ mod test {
4040
use rstest::rstest;
4141
use vortex_array::ArrayRef;
4242
use vortex_array::IntoArray;
43+
use vortex_array::ToCanonical;
4344
use vortex_array::arrays::PrimitiveArray;
4445
use vortex_array::compute::conformance::filter::test_filter_conformance;
45-
use vortex_array::vtable::ArrayVTableExt;
4646
use vortex_buffer::buffer;
4747

48-
use crate::ALPVTable;
48+
use crate::alp_encode;
4949

5050
#[rstest]
5151
#[case(buffer![1.23f32, 4.56, 7.89, 10.11, 12.13].into_array())]
@@ -57,11 +57,7 @@ mod test {
5757
11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0
5858
].into_array())]
5959
fn test_filter_alp_conformance(#[case] array: ArrayRef) {
60-
let alp = ALPVTable
61-
.as_vtable()
62-
.encode(&array.to_canonical().unwrap(), None)
63-
.unwrap()
64-
.unwrap();
60+
let alp = alp_encode(&array.to_primitive(), None).unwrap();
6561
test_filter_conformance(alp.as_ref());
6662
}
6763
}

encodings/alp/src/alp/compute/mask.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ register_kernel!(MaskKernelAdapter(ALPVTable).lift());
3838
mod test {
3939
use rstest::rstest;
4040
use vortex_array::IntoArray;
41+
use vortex_array::ToCanonical;
4142
use vortex_array::arrays::PrimitiveArray;
4243
use vortex_array::compute::conformance::mask::test_mask_conformance;
43-
use vortex_array::vtable::ArrayVTableExt;
4444
use vortex_buffer::buffer;
4545

46-
use crate::ALPVTable;
46+
use crate::alp_encode;
4747

4848
#[rstest]
4949
#[case(buffer![10.5f32, 20.5, 30.5, 40.5, 50.5].into_array())]
@@ -55,11 +55,7 @@ mod test {
5555
1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0
5656
].into_array())]
5757
fn test_mask_alp_conformance(#[case] array: vortex_array::ArrayRef) {
58-
let alp = ALPVTable
59-
.as_vtable()
60-
.encode(&array.to_canonical().unwrap(), None)
61-
.unwrap()
62-
.unwrap();
58+
let alp = alp_encode(&array.to_primitive(), None).unwrap();
6359
test_mask_conformance(alp.as_ref());
6460
}
6561
}

encodings/alp/src/alp/compute/take.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,20 @@ register_kernel!(TakeKernelAdapter(ALPVTable).lift());
3939
mod test {
4040
use rstest::rstest;
4141
use vortex_array::IntoArray;
42+
use vortex_array::ToCanonical;
4243
use vortex_array::arrays::PrimitiveArray;
4344
use vortex_array::compute::conformance::take::test_take_conformance;
44-
use vortex_array::vtable::ArrayVTableExt;
4545
use vortex_buffer::buffer;
4646

47-
use crate::ALPVTable;
47+
use crate::alp_encode;
4848

4949
#[rstest]
5050
#[case(buffer![1.23f32, 4.56, 7.89, 10.11, 12.13].into_array())]
5151
#[case(buffer![100.1f64, 200.2, 300.3, 400.4, 500.5].into_array())]
5252
#[case(PrimitiveArray::from_option_iter([Some(1.1f32), None, Some(2.2), Some(3.3), None]).into_array())]
5353
#[case(buffer![42.42f64].into_array())]
5454
fn test_take_alp_conformance(#[case] array: vortex_array::ArrayRef) {
55-
let alp = ALPVTable
56-
.as_vtable()
57-
.encode(&array.to_canonical().unwrap(), None)
58-
.unwrap()
59-
.unwrap();
55+
let alp = alp_encode(&array.to_primitive(), None).unwrap();
6056
test_take_conformance(alp.as_ref());
6157
}
6258
}

encodings/alp/src/alp_rd/array.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use vortex_array::vtable::ArrayVTable;
3232
use vortex_array::vtable::ArrayVTableExt;
3333
use vortex_array::vtable::BaseArrayVTable;
3434
use vortex_array::vtable::CanonicalVTable;
35-
use vortex_array::vtable::EncodeVTable;
3635
use vortex_array::vtable::NotSupported;
3736
use vortex_array::vtable::VTable;
3837
use vortex_array::vtable::ValidityChild;
@@ -78,7 +77,6 @@ impl VTable for ALPRDVTable {
7877
type ValidityVTable = ValidityVTableFromChild;
7978
type VisitorVTable = Self;
8079
type ComputeVTable = NotSupported;
81-
type EncodeVTable = Self;
8280

8381
fn id(&self) -> ArrayId {
8482
ArrayId::new_ref("vortex.alprd")
@@ -465,36 +463,6 @@ impl CanonicalVTable<ALPRDVTable> for ALPRDVTable {
465463
}
466464
}
467465

468-
impl EncodeVTable<ALPRDVTable> for ALPRDVTable {
469-
fn encode(
470-
_vtable: &ALPRDVTable,
471-
canonical: &Canonical,
472-
like: Option<&ALPRDArray>,
473-
) -> VortexResult<Option<ALPRDArray>> {
474-
let parray = canonical.clone().into_primitive();
475-
476-
let alprd_array = match like {
477-
None => {
478-
let encoder = match parray.ptype() {
479-
PType::F32 => crate::alp_rd::RDEncoder::new(parray.as_slice::<f32>()),
480-
PType::F64 => crate::alp_rd::RDEncoder::new(parray.as_slice::<f64>()),
481-
ptype => vortex_bail!("cannot ALPRD compress ptype {ptype}"),
482-
};
483-
encoder.encode(&parray)
484-
}
485-
Some(like) => {
486-
let encoder = crate::alp_rd::RDEncoder::from_parts(
487-
like.right_bit_width(),
488-
like.left_parts_dictionary().to_vec(),
489-
);
490-
encoder.encode(&parray)
491-
}
492-
};
493-
494-
Ok(Some(alprd_array))
495-
}
496-
}
497-
498466
impl VisitorVTable<ALPRDVTable> for ALPRDVTable {
499467
fn visit_buffers(_array: &ALPRDArray, _visitor: &mut dyn ArrayBufferVisitor) {}
500468

encodings/bytebool/src/array.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ impl VTable for ByteBoolVTable {
5555
type ValidityVTable = ValidityVTableFromValidityHelper;
5656
type VisitorVTable = Self;
5757
type ComputeVTable = NotSupported;
58-
type EncodeVTable = NotSupported;
5958

6059
fn id(&self) -> ArrayId {
6160
ArrayId::new_ref("vortex.bytebool")

encodings/datetime-parts/src/array.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ use vortex_array::ArrayChildVisitor;
1111
use vortex_array::ArrayEq;
1212
use vortex_array::ArrayHash;
1313
use vortex_array::ArrayRef;
14-
use vortex_array::Canonical;
1514
use vortex_array::DeserializeMetadata;
1615
use vortex_array::IntoArray;
1716
use vortex_array::Precision;
1817
use vortex_array::ProstMetadata;
1918
use vortex_array::SerializeMetadata;
20-
use vortex_array::arrays::TemporalArray;
2119
use vortex_array::buffer::BufferHandle;
2220
use vortex_array::serde::ArrayChildren;
2321
use vortex_array::stats::ArrayStats;
@@ -27,7 +25,6 @@ use vortex_array::vtable::ArrayId;
2725
use vortex_array::vtable::ArrayVTable;
2826
use vortex_array::vtable::ArrayVTableExt;
2927
use vortex_array::vtable::BaseArrayVTable;
30-
use vortex_array::vtable::EncodeVTable;
3128
use vortex_array::vtable::NotSupported;
3229
use vortex_array::vtable::VTable;
3330
use vortex_array::vtable::ValidityChild;
@@ -87,7 +84,6 @@ impl VTable for DateTimePartsVTable {
8784
type ValidityVTable = ValidityVTableFromChild;
8885
type VisitorVTable = Self;
8986
type ComputeVTable = NotSupported;
90-
type EncodeVTable = Self;
9187

9288
fn id(&self) -> ArrayId {
9389
ArrayId::new_ref("vortex.datetimeparts")
@@ -308,19 +304,6 @@ impl ValidityChild<DateTimePartsVTable> for DateTimePartsVTable {
308304
}
309305
}
310306

311-
impl EncodeVTable<DateTimePartsVTable> for DateTimePartsVTable {
312-
fn encode(
313-
_vtable: &DateTimePartsVTable,
314-
canonical: &Canonical,
315-
_like: Option<&DateTimePartsArray>,
316-
) -> VortexResult<Option<DateTimePartsArray>> {
317-
let ext_array = canonical.clone().into_extension();
318-
let temporal = TemporalArray::try_from(ext_array)?;
319-
320-
Ok(Some(DateTimePartsArray::try_from(temporal)?))
321-
}
322-
}
323-
324307
impl VisitorVTable<DateTimePartsVTable> for DateTimePartsVTable {
325308
fn visit_buffers(_array: &DateTimePartsArray, _visitor: &mut dyn ArrayBufferVisitor) {}
326309

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ impl VTable for DecimalBytePartsVTable {
7272
type ValidityVTable = ValidityVTableFromChild;
7373
type VisitorVTable = Self;
7474
type ComputeVTable = NotSupported;
75-
type EncodeVTable = NotSupported;
7675

7776
fn id(&self) -> ArrayId {
7877
ArrayId::new_ref("vortex.decimal_byte_parts")

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

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)