Skip to content

Commit 957eb3a

Browse files
authored
Fix semantic merge conflict between session serde and foreign encodings (#7362)
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 84e4dc0 commit 957eb3a

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

vortex-array/src/array/foreign.rs

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

44
use std::fmt;
5+
use std::fmt::Display;
56
use std::fmt::Formatter;
67
use std::hash::Hash;
78
use std::hash::Hasher;
@@ -40,6 +41,12 @@ impl ForeignArrayData {
4041
}
4142
}
4243

44+
impl Display for ForeignArrayData {
45+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
46+
write!(f, "ForeignArrayData({}B)", self.metadata.len())
47+
}
48+
}
49+
4350
impl ArrayHash for ForeignArrayData {
4451
fn array_hash<H: Hasher>(&self, state: &mut H, precision: crate::Precision) {
4552
self.metadata.hash(state);
@@ -112,14 +119,13 @@ impl VTable for ForeignArray {
112119
Some(format!("buffer[{idx}]"))
113120
}
114121

115-
fn serialize(array: ArrayView<'_, Self>) -> VortexResult<Option<Vec<u8>>> {
122+
fn serialize(
123+
array: ArrayView<'_, Self>,
124+
_session: &VortexSession,
125+
) -> VortexResult<Option<Vec<u8>>> {
116126
Ok(Some(array.metadata.clone()))
117127
}
118128

119-
fn fmt_metadata(array: ArrayView<'_, Self>, f: &mut Formatter<'_>) -> fmt::Result {
120-
write!(f, "ForeignMetadata({}B)", array.metadata.len())
121-
}
122-
123129
fn deserialize(
124130
&self,
125131
dtype: &DType,

vortex-array/src/serde.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ impl TryFrom<BufferHandle> for SerializedArray {
704704

705705
#[cfg(test)]
706706
mod tests {
707+
use std::sync::LazyLock;
708+
707709
use flatbuffers::FlatBufferBuilder;
708710
use vortex_session::VortexSession;
709711
use vortex_session::registry::ReadContext;
@@ -717,6 +719,8 @@ mod tests {
717719
use crate::flatbuffers as fba;
718720
use crate::session::ArraySession;
719721

722+
static SESSION: LazyLock<VortexSession> = LazyLock::new(VortexSession::empty);
723+
720724
#[test]
721725
fn unknown_array_encoding_allow_unknown() {
722726
let mut fbb = FlatBufferBuilder::new();
@@ -774,14 +778,23 @@ mod tests {
774778
decoded.nth_child(0).unwrap().encoding_id().as_ref(),
775779
"vortex.test.foreign_child"
776780
);
777-
assert_eq!(decoded.metadata().unwrap().unwrap(), vec![1, 2, 3]);
781+
assert_eq!(decoded.metadata(&SESSION).unwrap().unwrap(), vec![1, 2, 3]);
778782
assert_eq!(
779-
decoded.nth_child(0).unwrap().metadata().unwrap().unwrap(),
783+
decoded
784+
.nth_child(0)
785+
.unwrap()
786+
.metadata(&SESSION)
787+
.unwrap()
788+
.unwrap(),
780789
vec![9]
781790
);
782791

783792
let serialized = decoded
784-
.serialize(&ArrayContext::default(), &SerializeOptions::default())
793+
.serialize(
794+
&ArrayContext::default(),
795+
&SESSION,
796+
&SerializeOptions::default(),
797+
)
785798
.unwrap();
786799
assert!(!serialized.is_empty());
787800
}

0 commit comments

Comments
 (0)