Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/bitpacking/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod tests {

let decoded = casted.to_primitive();
assert_arrays_eq!(
decoded,
decoded.as_ref(),
PrimitiveArray::from_iter([10u32, 20, 30, 40, 50, 60])
);
}
Expand Down
8 changes: 2 additions & 6 deletions encodings/fastlanes/src/rle/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,13 @@ mod test {
fn test_partial_last_chunk() {
// Test array with partial last chunk (not divisible by 1024)
let values: Buffer<u32> = (0..1500).map(|i| (i / 100) as u32).collect();
let expected: Vec<u32> = (0..1500).map(|i| (i / 100) as u32).collect();
let array = values.into_array();

let encoded = RLEArray::encode(&array.to_primitive()).unwrap();
let decoded = encoded.to_primitive();

assert_eq!(encoded.len(), 1500);
let expected_array = PrimitiveArray::from_iter(expected);
assert_arrays_eq!(decoded, expected_array);
assert_arrays_eq!(decoded, array);
// 2 chunks: 1024 + 476 elements
assert_eq!(encoded.values_idx_offsets().len(), 2);
}
Expand All @@ -302,15 +300,13 @@ mod test {
fn test_two_full_chunks() {
// Array that spans exactly 2 chunks (2048 elements)
let values: Buffer<u32> = (0..2048).map(|i| (i / 100) as u32).collect();
let expected: Vec<u32> = (0..2048).map(|i| (i / 100) as u32).collect();
let array = values.into_array();

let encoded = RLEArray::encode(&array.to_primitive()).unwrap();
let decoded = encoded.to_primitive();

assert_eq!(encoded.len(), 2048);
let expected_array = PrimitiveArray::from_iter(expected);
assert_arrays_eq!(decoded, expected_array);
assert_arrays_eq!(decoded, array);
assert_eq!(encoded.values_idx_offsets().len(), 2);
}

Expand Down
1 change: 1 addition & 0 deletions vortex-btrblocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ vortex-zigzag = { workspace = true }
[dev-dependencies]
divan = { workspace = true }
env_logger = "0.11"
vortex-array = { workspace = true, features = ["test-harness"] }

[features]
# This feature enabled unstable encodings for which we don't guarantee stability.
Expand Down
7 changes: 4 additions & 3 deletions vortex-btrblocks/src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ mod tests {

use vortex_array::arrays::PrimitiveArray;
use vortex_array::validity::Validity;
use vortex_array::{Array, IntoArray, ToCanonical};
use vortex_array::{Array, IntoArray, ToCanonical, assert_arrays_eq};
use vortex_buffer::{Buffer, buffer_mut};

use crate::float::{FloatCompressor, RLE_FLOAT_SCHEME};
Expand Down Expand Up @@ -426,7 +426,8 @@ mod tests {
let stats = crate::float::FloatStats::generate(&array);
let compressed = RLE_FLOAT_SCHEME.compress(&stats, false, 3, &[]).unwrap();

let decoded = compressed.to_primitive();
assert_eq!(decoded.as_slice::<f32>(), values.as_slice());
let decoded = compressed;
let expected = Buffer::copy_from(&values).into_array();
assert_arrays_eq!(decoded.as_ref(), expected.as_ref());
}
}
11 changes: 8 additions & 3 deletions vortex-btrblocks/src/float/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl_encode!(f64, u64);
mod tests {
use vortex_array::arrays::{BoolArray, PrimitiveArray};
use vortex_array::validity::Validity;
use vortex_array::{Array, IntoArray, ToCanonical};
use vortex_array::{Array, IntoArray, assert_arrays_eq};
use vortex_buffer::buffer;

use crate::CompressorStats;
Expand All @@ -117,10 +117,15 @@ mod tests {
assert_eq!(dict_array.values().len(), 2);
assert_eq!(dict_array.codes().len(), 5);

let undict = dict_array.to_primitive();
let undict = dict_array;

// We just use code zero but it doesn't really matter.
// We can just shove a whole validity buffer in there instead.
assert_eq!(undict.as_slice::<f32>(), &[1f32, 2f32, 2f32, 1f32, 1f32]);
let expected = PrimitiveArray::new(
buffer![1f32, 2f32, 2f32, 1f32, 1f32],
Validity::Array(BoolArray::from_iter([true, true, true, false, true]).into_array()),
)
.into_array();
assert_arrays_eq!(undict.as_ref(), expected.as_ref());
}
}
32 changes: 19 additions & 13 deletions vortex-btrblocks/src/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ mod tests {
use vortex_array::arrays::PrimitiveArray;
use vortex_array::validity::Validity;
use vortex_array::vtable::ValidityHelper;
use vortex_array::{Array, IntoArray, ToCanonical};
use vortex_array::{Array, IntoArray, ToCanonical, assert_arrays_eq};
use vortex_buffer::{Buffer, BufferMut, buffer, buffer_mut};
use vortex_dict::DictEncoding;
use vortex_sequence::SequenceEncoding;
Expand Down Expand Up @@ -845,10 +845,11 @@ mod tests {
.compress(&IntegerStats::generate(&array), false, 3, &[])
.unwrap();
assert_eq!(compressed.encoding_id(), SparseEncoding.id());
let decoded = compressed.to_primitive();
let expected = [189u8, 189, 189, 0, 0];
assert_eq!(decoded.as_slice::<u8>(), &expected);
assert_eq!(decoded.validity(), array.validity());
let decoded = compressed.clone();
let expected =
PrimitiveArray::new(buffer![189u8, 189, 189, 0, 0], array.validity().clone())
.into_array();
assert_arrays_eq!(decoded.as_ref(), expected.as_ref());
}

#[test]
Expand All @@ -863,10 +864,13 @@ mod tests {
.compress(&IntegerStats::generate(&array), false, 3, &[])
.unwrap();
assert_eq!(compressed.encoding_id(), SparseEncoding.id());
let decoded = compressed.to_primitive();
let expected = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46];
assert_eq!(decoded.as_slice::<u8>(), &expected);
assert_eq!(decoded.validity(), array.validity());
let decoded = compressed.clone();
let expected = PrimitiveArray::new(
buffer![0u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46],
array.validity().clone(),
)
.into_array();
assert_arrays_eq!(decoded.as_ref(), expected.as_ref());
}

#[test]
Expand All @@ -877,8 +881,9 @@ mod tests {
.compress(&IntegerStats::generate(&array), false, 3, &[])
.unwrap();
assert_eq!(compressed.encoding_id(), SequenceEncoding.id());
let decoded = compressed.to_primitive();
assert_eq!(decoded.as_slice::<i32>(), values.as_slice());
let decoded = compressed;
let expected = PrimitiveArray::from_option_iter(values.into_iter().map(Some)).into_array();
assert_arrays_eq!(decoded.as_ref(), expected.as_ref());
}

#[test]
Expand All @@ -893,7 +898,8 @@ mod tests {
.compress(&IntegerStats::generate(&array), false, 3, &[])
.unwrap();

let decoded = compressed.to_primitive();
assert_eq!(decoded.as_slice::<i32>(), values.as_slice());
let decoded = compressed;
let expected = Buffer::copy_from(&values).into_array();
assert_arrays_eq!(decoded.as_ref(), expected.as_ref());
}
}
11 changes: 8 additions & 3 deletions vortex-btrblocks/src/integer/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl_encode!(i64);
mod tests {
use vortex_array::arrays::{BoolArray, PrimitiveArray};
use vortex_array::validity::Validity;
use vortex_array::{Array, IntoArray, ToCanonical};
use vortex_array::{Array, IntoArray, assert_arrays_eq};
use vortex_buffer::buffer;

use crate::CompressorStats;
Expand All @@ -131,10 +131,15 @@ mod tests {
assert_eq!(dict_array.values().len(), 2);
assert_eq!(dict_array.codes().len(), 5);

let undict = dict_array.to_primitive();
let undict = dict_array;

// We just use code zero, but it doesn't really matter.
// We can just shove a whole validity buffer in there instead.
assert_eq!(undict.as_slice::<i32>(), &[100i32, 200, 100, 100, 100]);
let expected = PrimitiveArray::new(
buffer![100i32, 200, 100, 100, 100],
Validity::Array(BoolArray::from_iter([true, true, true, false, true]).into_array()),
)
.into_array();
assert_arrays_eq!(undict.as_ref(), expected.as_ref());
}
}
Loading
Loading