Skip to content

Commit 48fd841

Browse files
committed
remove metadata methods
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 0289a0b commit 48fd841

7 files changed

Lines changed: 23 additions & 44 deletions

File tree

encodings/alp/src/alp/plugin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ mod tests {
125125

126126
let array = alp_encoded.as_array();
127127

128-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
128+
let metadata = SESSION.array_serialize(array)?.unwrap();
129129
let children = array.children();
130130
let buffers = array
131131
.buffers()
@@ -174,7 +174,7 @@ mod tests {
174174

175175
let array = alp_encoded.as_array();
176176

177-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
177+
let metadata = SESSION.array_serialize(array)?.unwrap();
178178
let children = array.children();
179179
let buffers = array
180180
.buffers()
@@ -205,7 +205,7 @@ mod tests {
205205
fn primitive_array_returns_error() {
206206
let array = PrimitiveArray::from_iter([1.0f64, 2.0, 3.0]).into_array();
207207

208-
let metadata = array.metadata(&SESSION).unwrap().unwrap_or_default();
208+
let metadata = SESSION.array_serialize(&array).unwrap().unwrap();
209209
let children = array.children();
210210
let buffers = array
211211
.buffers()

encodings/fastlanes/src/bitpacking/plugin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ mod tests {
128128

129129
let array = bitpacked.as_array();
130130

131-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
131+
let metadata = SESSION.array_serialize(array)?.unwrap_or_default();
132132
let children = array.children();
133133
let buffers = array
134134
.buffers()
@@ -177,7 +177,7 @@ mod tests {
177177

178178
let array = bitpacked.as_array();
179179

180-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
180+
let metadata = SESSION.array_serialize(array)?.unwrap_or_default();
181181
let children = array.children();
182182
let buffers = array
183183
.buffers()
@@ -207,7 +207,7 @@ mod tests {
207207
fn primitive_array_returns_error() -> VortexResult<()> {
208208
let array = PrimitiveArray::from_iter([1i32, 2, 3]).into_array();
209209

210-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
210+
let metadata = SESSION.array_serialize(&array)?.unwrap_or_default();
211211
let children = array.children();
212212
let buffers = array
213213
.buffers()

encodings/zstd/src/zstd_buffers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ impl ZstdBuffers {
6060
session: &VortexSession,
6161
) -> VortexResult<ZstdBuffersArray> {
6262
let encoding_id = array.encoding_id();
63-
let metadata = array
64-
.metadata(session)?
65-
.ok_or_else(|| vortex_err!("Array does not support serialization"))?;
63+
let metadata = session
64+
.array_serialize(array)?
65+
.ok_or_else(|| vortex_err!("Array does not support ZstdBuffers serialization"))?;
6666
let buffer_handles = array.buffer_handles();
6767
let children = array.children();
6868

vortex-array/src/array/erased.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use vortex_error::vortex_ensure;
1515
use vortex_error::vortex_err;
1616
use vortex_error::vortex_panic;
1717
use vortex_mask::Mask;
18-
use vortex_session::VortexSession;
1918

2019
use crate::AnyCanonical;
2120
use crate::Array;
@@ -563,11 +562,6 @@ impl ArrayRef {
563562
self.0.slot_name(self, idx)
564563
}
565564

566-
/// Returns the serialized metadata of the array.
567-
pub fn metadata(&self, session: &VortexSession) -> VortexResult<Option<Vec<u8>>> {
568-
self.0.metadata(self, session)
569-
}
570-
571565
/// Formats a human-readable metadata description.
572566
pub fn metadata_fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
573567
self.0.metadata_fmt(f)

vortex-array/src/array/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use vortex_error::VortexResult;
1414
use vortex_error::vortex_ensure;
1515
use vortex_error::vortex_err;
1616
use vortex_error::vortex_panic;
17-
use vortex_session::VortexSession;
1817

1918
use crate::ExecutionCtx;
2019
use crate::LEGACY_SESSION;
@@ -132,10 +131,6 @@ pub(crate) trait DynArray: 'static + private::Sealed + Send + Sync + Debug {
132131
/// Returns the name of the slot at the given index.
133132
fn slot_name(&self, this: &ArrayRef, idx: usize) -> String;
134133

135-
/// Returns the serialized metadata of the array, or `None` if the array does not
136-
/// support serialization.
137-
fn metadata(&self, this: &ArrayRef, session: &VortexSession) -> VortexResult<Option<Vec<u8>>>;
138-
139134
/// Formats a human-readable metadata description.
140135
fn metadata_fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result;
141136

@@ -341,11 +336,6 @@ impl<V: VTable> DynArray for ArrayInner<V> {
341336
V::slot_name(view, idx)
342337
}
343338

344-
fn metadata(&self, this: &ArrayRef, session: &VortexSession) -> VortexResult<Option<Vec<u8>>> {
345-
let view = unsafe { ArrayView::new_unchecked(this, &self.data) };
346-
V::serialize(view, session)
347-
}
348-
349339
fn metadata_fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
350340
std::fmt::Display::fmt(&self.data, f)
351341
}

vortex-array/src/arrow/executor/run_end.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::IntoArray;
2424
use crate::arrays::Constant;
2525
use crate::arrays::ConstantArray;
2626
use crate::arrow::ArrowArrayExecutor;
27+
use crate::session::ArraySessionExt;
2728

2829
/// The encoding ID used by `vortex-runend`. We match on this string to avoid a crate dependency.
2930
const VORTEX_RUNEND_ID: &str = "vortex.runend";
@@ -79,8 +80,10 @@ fn run_end_to_arrow(
7980
ctx: &mut ExecutionCtx,
8081
) -> VortexResult<ArrowArrayRef> {
8182
let length = array.len();
82-
let metadata_bytes = array
83-
.metadata(ctx.session())?
83+
84+
let metadata_bytes = ctx
85+
.session()
86+
.array_serialize(&array)?
8487
.ok_or_else(|| vortex_err!("RunEndArray missing metadata"))?;
8588
let metadata = RunEndMetadata::decode(&*metadata_bytes)
8689
.map_err(|e| vortex_err!("Failed to decode RunEndMetadata: {e}"))?;

vortex-array/src/serde.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,6 @@ impl<'a> ArrayNodeFlatBuffer<'a> {
170170
session: &'a VortexSession,
171171
array: &'a ArrayRef,
172172
) -> VortexResult<Self> {
173-
// Depth-first traversal of the array to ensure it supports serialization.
174-
// FIXME(ngates): this serializes the metadata and throws it away!
175-
for child in array.depth_first_traversal() {
176-
if child.metadata(session)?.is_none() {
177-
vortex_bail!(
178-
"Array {} does not support serialization",
179-
child.encoding_id()
180-
);
181-
}
182-
}
183173
let n_buffers_recursive = array.nbuffers_recursive();
184174
if n_buffers_recursive > u16::MAX as usize {
185175
vortex_bail!(
@@ -210,13 +200,13 @@ impl<'a> ArrayNodeFlatBuffer<'a> {
210200
)
211201
})?;
212202

213-
let metadata = self.array.metadata(self.session)?.ok_or_else(|| {
203+
let metadata_bytes = self.session.array_serialize(self.array)?.ok_or_else(|| {
214204
vortex_err!(
215205
"Array {} does not support serialization",
216206
self.array.encoding_id()
217207
)
218208
})?;
219-
let metadata = Some(fbb.create_vector(metadata.as_slice()));
209+
let metadata = Some(fbb.create_vector(metadata_bytes.as_slice()));
220210

221211
// Assign buffer indices for all child arrays.
222212
let nbuffers = u16::try_from(self.array.nbuffers())
@@ -718,6 +708,7 @@ mod tests {
718708
use crate::dtype::Nullability;
719709
use crate::flatbuffers as fba;
720710
use crate::session::ArraySession;
711+
use crate::session::ArraySessionExt;
721712

722713
static SESSION: LazyLock<VortexSession> = LazyLock::new(VortexSession::empty);
723714

@@ -778,12 +769,13 @@ mod tests {
778769
decoded.nth_child(0).unwrap().encoding_id().as_ref(),
779770
"vortex.test.foreign_child"
780771
);
781-
assert_eq!(decoded.metadata(&SESSION).unwrap().unwrap(), vec![1, 2, 3]);
782772
assert_eq!(
783-
decoded
784-
.nth_child(0)
785-
.unwrap()
786-
.metadata(&SESSION)
773+
SESSION.array_serialize(&decoded).unwrap().unwrap(),
774+
vec![1, 2, 3]
775+
);
776+
assert_eq!(
777+
SESSION
778+
.array_serialize(&decoded.nth_child(0).unwrap())
787779
.unwrap()
788780
.unwrap(),
789781
vec![9]

0 commit comments

Comments
 (0)