Skip to content

Commit 16934da

Browse files
committed
remove metadata from DynArray
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 59c92ab commit 16934da

12 files changed

Lines changed: 31 additions & 148 deletions

File tree

encodings/alp/src/alp/plugin.rs

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

130130
let array = alp_encoded.as_array();
131131

132-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
132+
let metadata = SESSION.array_serialize(array)?.unwrap();
133133
let children = array.children();
134134
let buffers = array
135135
.buffers()
@@ -178,7 +178,7 @@ mod tests {
178178

179179
let array = alp_encoded.as_array();
180180

181-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
181+
let metadata = SESSION.array_serialize(array)?.unwrap();
182182
let children = array.children();
183183
let buffers = array
184184
.buffers()
@@ -209,7 +209,7 @@ mod tests {
209209
fn primitive_array_returns_error() {
210210
let array = PrimitiveArray::from_iter([1.0f64, 2.0, 3.0]).into_array();
211211

212-
let metadata = array.metadata(&SESSION).unwrap().unwrap_or_default();
212+
let metadata = SESSION.array_serialize(&array).unwrap().unwrap();
213213
let children = array.children();
214214
let buffers = array
215215
.buffers()

encodings/bytebool/src/array.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ impl From<Vec<Option<bool>>> for ByteBoolData {
352352
mod tests {
353353
use vortex_array::ArrayContext;
354354
use vortex_array::IntoArray;
355-
use vortex_array::LEGACY_SESSION;
356355
use vortex_array::assert_arrays_eq;
357356
use vortex_array::serde::SerializeOptions;
358357
use vortex_array::serde::SerializedArray;
@@ -407,7 +406,7 @@ mod tests {
407406
let serialized = array
408407
.clone()
409408
.into_array()
410-
.serialize(&ctx, &LEGACY_SESSION, &SerializeOptions::default())
409+
.serialize(&ctx, &session, &SerializeOptions::default())
411410
.unwrap();
412411

413412
let mut concat = ByteBufferMut::empty();

encodings/fastlanes/src/bitpacking/plugin.rs

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

133133
let array = bitpacked.as_array();
134134

135-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
135+
let metadata = SESSION.array_serialize(array)?.unwrap();
136136
let children = array.children();
137137
let buffers = array
138138
.buffers()
@@ -181,7 +181,7 @@ mod tests {
181181

182182
let array = bitpacked.as_array();
183183

184-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
184+
let metadata = SESSION.array_serialize(array)?.unwrap();
185185
let children = array.children();
186186
let buffers = array
187187
.buffers()
@@ -211,7 +211,7 @@ mod tests {
211211
fn primitive_array_returns_error() -> VortexResult<()> {
212212
let array = PrimitiveArray::from_iter([1i32, 2, 3]).into_array();
213213

214-
let metadata = array.metadata(&SESSION)?.unwrap_or_default();
214+
let metadata = SESSION.array_serialize(&array)?.unwrap();
215215
let children = array.children();
216216
let buffers = array
217217
.buffers()

encodings/parquet-variant/src/vtable.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ mod tests {
246246
use vortex_array::IntoArray;
247247
use vortex_array::Precision;
248248
use vortex_array::arrays::VarBinViewArray;
249-
use vortex_array::arrays::Variant;
250249
use vortex_array::arrays::VariantArray;
251250
use vortex_array::dtype::DType;
252251
use vortex_array::dtype::Nullability;
253252
use vortex_array::dtype::PType;
254253
use vortex_array::serde::SerializeOptions;
255254
use vortex_array::serde::SerializedArray;
255+
use vortex_array::session::ArraySession;
256256
use vortex_array::session::ArraySessionExt;
257257
use vortex_array::validity::Validity;
258258
use vortex_buffer::BitBuffer;
@@ -263,11 +263,14 @@ mod tests {
263263

264264
use crate::ParquetVariant;
265265
use crate::array::ParquetVariantArrayExt;
266+
266267
fn roundtrip(array: ArrayRef) -> ArrayRef {
267268
let dtype = array.dtype().clone();
268269
let len = array.len();
269270

270-
let session = VortexSession::empty().with::<vortex_array::session::ArraySession>();
271+
let session = VortexSession::empty().with::<ArraySession>();
272+
session.arrays().register(ParquetVariant);
273+
271274
let ctx = ArrayContext::empty();
272275
let serialized = array
273276
.serialize(&ctx, &session, &SerializeOptions::default())
@@ -278,8 +281,6 @@ mod tests {
278281
concat.extend_from_slice(buf.as_ref());
279282
}
280283
let concat = concat.freeze();
281-
session.arrays().register(ParquetVariant);
282-
session.arrays().register(Variant);
283284

284285
let parts = SerializedArray::try_from(concat).unwrap();
285286
parts

encodings/pco/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ mod array;
55
mod compute;
66
mod rules;
77
mod slice;
8-
#[cfg(test)]
9-
mod test;
108

119
pub use array::*;
1210

@@ -35,3 +33,6 @@ pub struct PcoMetadata {
3533
#[prost(message, repeated, tag = "2")]
3634
pub chunks: Vec<PcoChunkInfo>,
3735
}
36+
37+
#[cfg(test)]
38+
mod tests;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn test_serde() -> VortexResult<()> {
184184
let bytes = pco
185185
.serialize(
186186
&context,
187-
&LEGACY_SESSION,
187+
&SESSION,
188188
&SerializeOptions {
189189
offset: 0,
190190
include_padding: true,

encodings/runend/src/arrow.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ mod tests {
9090
use vortex_array::search_sorted::SearchSorted;
9191
use vortex_array::search_sorted::SearchSortedSide;
9292
use vortex_array::session::ArraySession;
93+
use vortex_array::session::ArraySessionExt;
9394
use vortex_array::validity::Validity;
9495
use vortex_buffer::Buffer;
9596
use vortex_buffer::buffer;
@@ -99,8 +100,11 @@ mod tests {
99100
use crate::RunEnd;
100101
use crate::ops::find_slice_end_index;
101102

102-
static SESSION: LazyLock<VortexSession> =
103-
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
103+
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
104+
let session = VortexSession::empty().with::<ArraySession>();
105+
session.arrays().register(RunEnd);
106+
session
107+
});
104108

105109
fn decode_run_array<R: RunEndIndexType>(
106110
array: &RunArray<R>,

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!("[ZstdBuffers]: Array does not support 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;
@@ -561,11 +560,6 @@ impl ArrayRef {
561560
self.0.slot_name(self, idx)
562561
}
563562

564-
/// Returns the serialized metadata of the array.
565-
pub fn metadata(&self, session: &VortexSession) -> VortexResult<Option<Vec<u8>>> {
566-
self.0.metadata(self, session)
567-
}
568-
569563
/// Formats a human-readable metadata description.
570564
pub fn metadata_fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
571565
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
}

0 commit comments

Comments
 (0)