Skip to content

Commit fdef306

Browse files
committed
wip
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 1d20f04 commit fdef306

File tree

68 files changed

+659
-865
lines changed

Some content is hidden

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

68 files changed

+659
-865
lines changed

encodings/alp/src/alp/array.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use vortex_array::vtable::{
1313
};
1414
use vortex_array::{
1515
Array, ArrayBufferVisitor, ArrayChildVisitor, ArrayEq, ArrayHash, ArrayRef, Canonical,
16-
DeserializeMetadata, EncodingId, EncodingRef, Precision, ProstMetadata, vtable,
16+
DeserializeMetadata, EncodingId, EncodingRef, Precision, ProstMetadata, SerializeMetadata,
17+
vtable,
1718
};
1819
use vortex_buffer::ByteBuffer;
1920
use vortex_dtype::{DType, PType};
@@ -59,11 +60,13 @@ impl VTable for ALPVTable {
5960
}
6061

6162
fn serialize(metadata: Self::Metadata) -> VortexResult<Option<Vec<u8>>> {
62-
metadata.serialize()
63+
Ok(Some(metadata.serialize()))
6364
}
6465

6566
fn deserialize(buffer: &[u8]) -> VortexResult<Self::Metadata> {
66-
ProstMetadata::<ALPMetadata>::deserialize(buffer)
67+
Ok(ProstMetadata(
68+
<ProstMetadata<ALPMetadata> as DeserializeMetadata>::deserialize(buffer)?,
69+
))
6770
}
6871

6972
fn build(

encodings/alp/src/alp/mod.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,36 @@ mod array;
1111
mod compress;
1212
mod compute;
1313
mod ops;
14-
mod serde;
14+
15+
#[cfg(test)]
16+
mod tests {
17+
use vortex_array::ProstMetadata;
18+
use vortex_array::patches::PatchesMetadata;
19+
use vortex_array::test_harness::check_metadata;
20+
use vortex_dtype::PType;
21+
22+
use crate::alp::array::ALPMetadata;
23+
24+
#[cfg_attr(miri, ignore)]
25+
#[test]
26+
fn test_alp_metadata() {
27+
check_metadata(
28+
"alp.metadata",
29+
ProstMetadata(ALPMetadata {
30+
patches: Some(PatchesMetadata::new(
31+
usize::MAX,
32+
usize::MAX,
33+
PType::U64,
34+
None,
35+
None,
36+
None,
37+
)),
38+
exp_e: u32::MAX,
39+
exp_f: u32::MAX,
40+
}),
41+
);
42+
}
43+
}
1544

1645
pub use array::*;
1746
pub use compress::*;

encodings/alp/src/alp/serde.rs

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

encodings/alp/src/alp_rd/array.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use vortex_array::vtable::{
1616
};
1717
use vortex_array::{
1818
Array, ArrayBufferVisitor, ArrayChildVisitor, ArrayEq, ArrayHash, ArrayRef, Canonical,
19-
EncodingId, EncodingRef, Precision, ProstMetadata, ToCanonical, vtable,
19+
DeserializeMetadata, EncodingId, EncodingRef, Precision, ProstMetadata, SerializeMetadata,
20+
ToCanonical, vtable,
2021
};
2122
use vortex_buffer::{Buffer, ByteBuffer};
2223
use vortex_dtype::{DType, Nullability, PType};
@@ -83,11 +84,13 @@ impl VTable for ALPRDVTable {
8384
}
8485

8586
fn serialize(metadata: Self::Metadata) -> VortexResult<Option<Vec<u8>>> {
86-
metadata.serialize()
87+
Ok(Some(metadata.serialize()))
8788
}
8889

8990
fn deserialize(buffer: &[u8]) -> VortexResult<Self::Metadata> {
90-
ProstMetadata::deserialize(buffer)
91+
Ok(ProstMetadata(
92+
<ProstMetadata<ALPRDMetadata> as DeserializeMetadata>::deserialize(buffer)?,
93+
))
9194
}
9295

9396
fn build(

encodings/alp/src/alp_rd/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use vortex_fastlanes::bitpack_compress::bitpack_encode_unchecked;
1212
mod array;
1313
mod compute;
1414
mod ops;
15-
mod serde;
1615

1716
use std::ops::{Shl, Shr};
1817

encodings/alp/src/alp_rd/serde.rs

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

encodings/datetime-parts/src/array.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use vortex_array::{
1818
};
1919
use vortex_buffer::ByteBuffer;
2020
use vortex_dtype::{DType, Nullability, PType};
21-
use vortex_error::{VortexResult, vortex_bail};
21+
use vortex_error::{VortexResult, vortex_bail, vortex_err};
2222

2323
vtable!(DateTimeParts);
2424

@@ -28,24 +28,27 @@ pub struct DateTimePartsMetadata {
2828
// Validity lives in the days array
2929
// TODO(ngates): we should actually model this with a Tuple array when we have one.
3030
#[prost(enumeration = "PType", tag = "1")]
31-
days_ptype: i32,
31+
pub days_ptype: i32,
3232
#[prost(enumeration = "PType", tag = "2")]
33-
seconds_ptype: i32,
33+
pub seconds_ptype: i32,
3434
#[prost(enumeration = "PType", tag = "3")]
35-
subseconds_ptype: i32,
35+
pub subseconds_ptype: i32,
3636
}
3737

3838
impl DateTimePartsMetadata {
39-
pub fn get_days_ptype(&self) -> PType {
40-
PType::try_from(self.days_ptype).unwrap()
39+
pub fn get_days_ptype(&self) -> VortexResult<PType> {
40+
PType::try_from(self.days_ptype)
41+
.map_err(|_| vortex_err!("Invalid PType {}", self.days_ptype))
4142
}
4243

43-
pub fn get_seconds_ptype(&self) -> PType {
44-
PType::try_from(self.seconds_ptype).unwrap()
44+
pub fn get_seconds_ptype(&self) -> VortexResult<PType> {
45+
PType::try_from(self.seconds_ptype)
46+
.map_err(|_| vortex_err!("Invalid PType {}", self.seconds_ptype))
4547
}
4648

47-
pub fn get_subseconds_ptype(&self) -> PType {
48-
PType::try_from(self.subseconds_ptype).unwrap()
49+
pub fn get_subseconds_ptype(&self) -> VortexResult<PType> {
50+
PType::try_from(self.subseconds_ptype)
51+
.map_err(|_| vortex_err!("Invalid PType {}", self.subseconds_ptype))
4952
}
5053
}
5154

@@ -106,17 +109,17 @@ impl VTable for DateTimePartsVTable {
106109

107110
let days = children.get(
108111
0,
109-
&DType::Primitive(metadata.get_days_ptype(), dtype.nullability()),
112+
&DType::Primitive(metadata.0.get_days_ptype()?, dtype.nullability()),
110113
len,
111114
)?;
112115
let seconds = children.get(
113116
1,
114-
&DType::Primitive(metadata.get_seconds_ptype(), Nullability::NonNullable),
117+
&DType::Primitive(metadata.0.get_seconds_ptype()?, Nullability::NonNullable),
115118
len,
116119
)?;
117120
let subseconds = children.get(
118121
2,
119-
&DType::Primitive(metadata.get_subseconds_ptype(), Nullability::NonNullable),
122+
&DType::Primitive(metadata.0.get_subseconds_ptype()?, Nullability::NonNullable),
120123
len,
121124
)?;
122125

encodings/datetime-parts/src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,26 @@ mod canonical;
99
mod compress;
1010
mod compute;
1111
mod ops;
12-
mod serde;
1312
mod timestamp;
13+
14+
#[cfg(test)]
15+
mod test {
16+
use vortex_array::ProstMetadata;
17+
use vortex_array::test_harness::check_metadata;
18+
use vortex_dtype::PType;
19+
20+
use crate::DateTimePartsMetadata;
21+
22+
#[cfg_attr(miri, ignore)]
23+
#[test]
24+
fn test_datetimeparts_metadata() {
25+
check_metadata(
26+
"datetimeparts.metadata",
27+
ProstMetadata(DateTimePartsMetadata {
28+
days_ptype: PType::I64 as i32,
29+
seconds_ptype: PType::I64 as i32,
30+
subseconds_ptype: PType::I64 as i32,
31+
}),
32+
);
33+
}
34+
}

encodings/datetime-parts/src/serde.rs

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

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
mod compute;
5-
mod serde;
65

76
use std::hash::Hash;
87
use std::ops::Range;
@@ -13,11 +12,11 @@ use vortex_array::serde::ArrayChildren;
1312
use vortex_array::stats::{ArrayStats, StatsSetRef};
1413
use vortex_array::vtable::{
1514
ArrayVTable, CanonicalVTable, NotSupported, OperationsVTable, VTable, ValidityChild,
16-
ValidityHelper, ValidityVTableFromChild,
15+
ValidityHelper, ValidityVTableFromChild, VisitorVTable,
1716
};
1817
use vortex_array::{
19-
Array, ArrayEq, ArrayHash, ArrayRef, Canonical, DeserializeMetadata, EncodingId, EncodingRef,
20-
IntoArray, Precision, ProstMetadata, SerializeMetadata, ToCanonical, vtable,
18+
Array, ArrayBufferVisitor, ArrayChildVisitor, ArrayEq, ArrayHash, ArrayRef, Canonical, EncodingId, EncodingRef, IntoArray, Precision, ProstMetadata,
19+
SerializeMetadata, ToCanonical, vtable,
2120
};
2221
use vortex_buffer::ByteBuffer;
2322
use vortex_dtype::{DType, DecimalDType, PType, match_each_signed_integer_ptype};
@@ -232,6 +231,14 @@ impl ValidityChild<DecimalBytePartsVTable> for DecimalBytePartsVTable {
232231
}
233232
}
234233

234+
impl VisitorVTable<DecimalBytePartsVTable> for DecimalBytePartsVTable {
235+
fn visit_buffers(_array: &DecimalBytePartsArray, _visitor: &mut dyn ArrayBufferVisitor) {}
236+
237+
fn visit_children(array: &DecimalBytePartsArray, visitor: &mut dyn ArrayChildVisitor) {
238+
visitor.visit_child("msp", &array.msp);
239+
}
240+
}
241+
235242
#[cfg(test)]
236243
mod tests {
237244
use vortex_array::Array;

0 commit comments

Comments
 (0)