Skip to content

Commit d4b2926

Browse files
committed
use BitWidthsView in bitpacked v2 serde
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
1 parent 759884c commit d4b2926

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎encodings/fastlanes/src/bitpacking/plugin/mod.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use vortex_session::registry::CachedId;
2828
use crate::BitPacked;
2929
use crate::BitPackedArray;
3030
use crate::BitPackedArrayExt;
31-
use crate::BitWidths;
31+
use crate::BitWidthsView;
3232

3333
#[cfg(test)]
3434
mod tests;
@@ -77,8 +77,8 @@ impl ArrayPlugin for BitPackedPlugin {
7777
vortex_err!("BitPacked plugin cannot serialize {}", array.encoding_id())
7878
})?;
7979
let serialization = match view.bit_widths() {
80-
BitWidths::Global(bit_width) => v1::serialize(array, view, bit_width)?,
81-
BitWidths::Blocked(block_offsets) => v2::serialize(array, view, &block_offsets)?,
80+
BitWidthsView::Global(bit_width) => v1::serialize(array, view, bit_width)?,
81+
BitWidthsView::Blocked(block_offsets) => v2::serialize(array, view, block_offsets)?,
8282
};
8383
Ok(Some(serialization))
8484
}
@@ -156,15 +156,15 @@ impl ArrayPlugin for BitPackedPatchedPlugin {
156156
let offset = bitpacked.offset();
157157

158158
let bitpacked_without_patches = match bitpacked.bit_widths() {
159-
BitWidths::Global(bw) => {
159+
BitWidthsView::Global(bw) => {
160160
BitPacked::try_new(packed, ptype, validity, None, bw, len, offset)?
161161
}
162-
BitWidths::Blocked(block_offsets) => BitPacked::try_new_with_block_offsets(
162+
BitWidthsView::Blocked(block_offsets) => BitPacked::try_new_with_block_offsets(
163163
packed,
164164
ptype,
165165
validity,
166166
None,
167-
block_offsets,
167+
block_offsets.clone(),
168168
len,
169169
offset,
170170
)?,

‎encodings/fastlanes/src/bitpacking/plugin/tests.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use crate::BitPacked;
4242
use crate::BitPackedArray;
4343
use crate::BitPackedArrayExt;
4444
use crate::BitPackedData;
45-
use crate::BitWidths;
45+
use crate::BitWidthsView;
4646
use crate::bitpack_compress::bitpack_encode_blocked;
4747
use crate::bitpack_compress::bitpack_to_best_bit_widths;
4848

@@ -270,7 +270,7 @@ fn v2_roundtrip(
270270
Some(bit_widths) => bitpack_encode_blocked(&values, &bit_widths, None, &mut ctx)?,
271271
None => bitpack_to_best_bit_widths(&values, &mut ctx)?,
272272
};
273-
let BitWidths::Blocked(block_offsets) = array.bit_widths() else {
273+
let BitWidthsView::Blocked(block_offsets) = array.bit_widths() else {
274274
vortex_bail!("expected block offsets");
275275
};
276276
let serialization = PLUGIN_SESSION
@@ -297,7 +297,7 @@ fn v2_roundtrip_offset_and_nonzero_base() -> VortexResult<()> {
297297
let mut ctx = PLUGIN_SESSION.create_execution_ctx();
298298
let values = drifting();
299299
let encoded = bitpack_to_best_bit_widths(&values, &mut ctx)?;
300-
let BitWidths::Blocked(block_offsets) = encoded.bit_widths() else {
300+
let BitWidthsView::Blocked(block_offsets) = encoded.bit_widths() else {
301301
vortex_bail!("expected block offsets");
302302
};
303303
let block_offsets = block_offsets
@@ -335,7 +335,7 @@ fn v2_roundtrip_offset_and_nonzero_base() -> VortexResult<()> {
335335
fn v2_rejects_malformed_parts() -> VortexResult<()> {
336336
let array =
337337
bitpack_to_best_bit_widths(&drifting(), &mut PLUGIN_SESSION.create_execution_ctx())?;
338-
let BitWidths::Blocked(block_offsets) = array.bit_widths() else {
338+
let BitWidthsView::Blocked(block_offsets) = array.bit_widths() else {
339339
vortex_bail!("expected block offsets");
340340
};
341341
let metadata = BitPackedV2Metadata {
@@ -358,14 +358,14 @@ fn v2_rejects_malformed_parts() -> VortexResult<()> {
358358
)
359359
};
360360

361-
assert!(deserialize(&metadata, std::slice::from_ref(&block_offsets)).is_ok());
361+
assert!(deserialize(&metadata, std::slice::from_ref(block_offsets)).is_ok());
362362
assert!(deserialize(&metadata, &[]).is_err());
363363
let offset_past_block = BitPackedV2Metadata {
364364
offset: 1024,
365365
block_offsets_ptype: metadata.block_offsets_ptype,
366366
patches: None,
367367
};
368-
assert!(deserialize(&offset_past_block, std::slice::from_ref(&block_offsets)).is_err());
368+
assert!(deserialize(&offset_past_block, std::slice::from_ref(block_offsets)).is_err());
369369
let signed = BitPackedV2Metadata {
370370
offset: 0,
371371
block_offsets_ptype: PType::I32 as i32,

0 commit comments

Comments
 (0)