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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion encodings/alp/benches/alp_compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ use vortex_alp::decompress_into_array;
use vortex_array::Canonical;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::aggregate_fn::session::AggregateFnSession;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::dtype::NativePType;
use vortex_array::dtype::session::DTypeSession;
use vortex_array::memory::MemorySession;
use vortex_array::optimizer::kernels::KernelSession;
use vortex_array::scalar_fn::session::ScalarFnSession;
use vortex_array::session::ArraySession;
use vortex_array::stats::session::StatsSession;
use vortex_array::validity::Validity;
use vortex_buffer::Buffer;
use vortex_buffer::buffer;
Expand All @@ -30,6 +37,7 @@ use vortex_session::VortexSession;
static GLOBAL: MiMalloc = MiMalloc;

fn main() {
LazyLock::force(&SESSION);
divan::main();
}

Expand All @@ -56,7 +64,14 @@ const BENCH_ARGS: &[(usize, f64, f64)] = &[
];

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty()
.with::<ArraySession>()
.with::<KernelSession>()
.with::<DTypeSession>()
.with::<ScalarFnSession>()
.with::<AggregateFnSession>()
.with::<MemorySession>()
.with::<StatsSession>();
vortex_alp::initialize(&session);
session
});
Expand Down
2 changes: 1 addition & 1 deletion encodings/alp/src/alp/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ mod tests {
use crate::decompress_into_array;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
2 changes: 1 addition & 1 deletion encodings/alp/src/alp/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ mod tests {
use crate::decompress_into_array;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
2 changes: 1 addition & 1 deletion encodings/alp/src/alp/compute/between.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod tests {
use crate::alp_encode;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
2 changes: 1 addition & 1 deletion encodings/alp/src/alp/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod tests {
use crate::alp_encode;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
2 changes: 1 addition & 1 deletion encodings/alp/src/alp/compute/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mod tests {
use crate::alp_encode;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
8 changes: 6 additions & 2 deletions encodings/alp/src/alp/compute/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ impl FilterKernel for ALP {

#[cfg(test)]
mod test {
use std::sync::LazyLock;

use rstest::rstest;
use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::conformance::filter::test_filter_conformance;
use vortex_buffer::buffer;
use vortex_session::VortexSession;

use crate::alp_encode;

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

#[rstest]
#[case(buffer![1.23f32, 4.56, 7.89, 10.11, 12.13].into_array())]
#[case(buffer![100.1f64, 200.2, 300.3, 400.4, 500.5].into_array())]
Expand All @@ -62,7 +66,7 @@ mod test {
11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0
].into_array())]
fn test_filter_alp_conformance(#[case] array: ArrayRef) {
let mut ctx = array_session().create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let array_primitive = array.execute::<PrimitiveArray>(&mut ctx).unwrap();
let alp = alp_encode(array_primitive.as_view(), None, &mut ctx).unwrap();
test_filter_conformance(&alp.into_array(), &mut ctx);
Expand Down
12 changes: 8 additions & 4 deletions encodings/alp/src/alp/compute/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,24 @@ impl MaskKernel for ALP {

#[cfg(test)]
mod test {
use std::sync::LazyLock;

use rstest::rstest;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::BoolArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::conformance::mask::test_mask_conformance;
use vortex_array::dtype::Nullability;
use vortex_array::scalar_fn::fns::mask::MaskKernel;
use vortex_buffer::buffer;
use vortex_session::VortexSession;

use crate::alp::array::ALPArrayExt;
use crate::alp_encode;

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

#[rstest]
#[case(buffer![10.5f32, 20.5, 30.5, 40.5, 50.5].into_array())]
#[case(buffer![1000.123f64, 2000.456, 3000.789, 4000.012, 5000.345].into_array())]
Expand All @@ -73,7 +77,7 @@ mod test {
1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0
].into_array())]
fn test_mask_alp_conformance(#[case] array: vortex_array::ArrayRef) {
let mut ctx = array_session().create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let array_primitive = array.execute::<PrimitiveArray>(&mut ctx).unwrap();
let alp = alp_encode(array_primitive.as_view(), None, &mut ctx).unwrap();
test_mask_conformance(&alp.into_array(), &mut ctx);
Expand All @@ -82,7 +86,7 @@ mod test {
#[test]
fn test_mask_alp_with_patches() {
use std::f64::consts::PI;
let mut ctx = array_session().create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
// PI doesn't encode cleanly with ALP, so it creates patches.
let values: Vec<f64> = (0..100)
.map(|i| if i % 4 == 3 { PI } else { 1.0 })
Expand All @@ -95,7 +99,7 @@ mod test {

#[test]
fn test_mask_alp_with_patches_casts_surviving_patch_values_to_nullable() {
let mut ctx = array_session().create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let values = PrimitiveArray::from_iter([1.234f32, f32::NAN, 2.345, f32::INFINITY, 3.456]);
let alp = alp_encode(values.as_view(), None, &mut ctx).unwrap();
assert!(alp.patches().is_some(), "expected patches");
Expand Down
27 changes: 13 additions & 14 deletions encodings/alp/src/alp/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ mod tests {
use rstest::rstest;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::conformance::binary_numeric::test_binary_numeric_array;
use vortex_array::compute::conformance::consistency::test_array_consistency;
Expand All @@ -27,34 +26,34 @@ mod tests {
use crate::alp_encode;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});

#[rstest]
// Basic float arrays
#[case::f32_array(alp_encode(PrimitiveArray::from_iter([1.23f32, 4.56, 7.89, 10.11, 12.13]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::f64_array(alp_encode(PrimitiveArray::from_iter([100.1f64, 200.2, 300.3, 400.4, 500.5]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::f32_array(alp_encode(PrimitiveArray::from_iter([1.23f32, 4.56, 7.89, 10.11, 12.13]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
#[case::f64_array(alp_encode(PrimitiveArray::from_iter([100.1f64, 200.2, 300.3, 400.4, 500.5]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
// Nullable arrays
#[case::nullable_f32(alp_encode(PrimitiveArray::from_option_iter([Some(1.1f32), None, Some(2.2), Some(3.3), None]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::nullable_f64(alp_encode(PrimitiveArray::from_option_iter([Some(1.1f64), None, Some(2.2), Some(3.3), None]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::nullable_f32(alp_encode(PrimitiveArray::from_option_iter([Some(1.1f32), None, Some(2.2), Some(3.3), None]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
#[case::nullable_f64(alp_encode(PrimitiveArray::from_option_iter([Some(1.1f64), None, Some(2.2), Some(3.3), None]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
// Edge cases
#[case::single_element(alp_encode(PrimitiveArray::from_iter([42.42f64]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::single_element(alp_encode(PrimitiveArray::from_iter([42.42f64]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
// Large arrays
#[case::large_f32(alp_encode(PrimitiveArray::from_iter((0..1000).map(|i| i as f32 * 0.1)).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::large_f32(alp_encode(PrimitiveArray::from_iter((0..1000).map(|i| i as f32 * 0.1)).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
// Arrays with patterns
#[case::repeating_pattern(alp_encode(PrimitiveArray::from_iter([1.1f32, 2.2, 3.3, 1.1, 2.2, 3.3, 1.1, 2.2, 3.3]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::close_values(alp_encode(PrimitiveArray::from_iter([100.001f64, 100.002, 100.003, 100.004, 100.005]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::repeating_pattern(alp_encode(PrimitiveArray::from_iter([1.1f32, 2.2, 3.3, 1.1, 2.2, 3.3, 1.1, 2.2, 3.3]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
#[case::close_values(alp_encode(PrimitiveArray::from_iter([100.001f64, 100.002, 100.003, 100.004, 100.005]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
fn test_alp_consistency(#[case] array: ALPArray) {
test_array_consistency(&array.into_array(), &mut SESSION.create_execution_ctx());
}

#[rstest]
#[case::f32_basic(alp_encode(PrimitiveArray::from_iter([1.23f32, 4.56, 7.89, 10.11, 12.13]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::f64_basic(alp_encode(PrimitiveArray::from_iter([100.1f64, 200.2, 300.3, 400.4, 500.5]).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::f32_large(alp_encode(PrimitiveArray::from_iter((0..100).map(|i| i as f32 * 1.5)).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::f64_large(alp_encode(PrimitiveArray::from_iter((0..100).map(|i| i as f64 * 2.5)).as_view(), None, &mut array_session().create_execution_ctx()).unwrap())]
#[case::f32_basic(alp_encode(PrimitiveArray::from_iter([1.23f32, 4.56, 7.89, 10.11, 12.13]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
#[case::f64_basic(alp_encode(PrimitiveArray::from_iter([100.1f64, 200.2, 300.3, 400.4, 500.5]).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
#[case::f32_large(alp_encode(PrimitiveArray::from_iter((0..100).map(|i| i as f32 * 1.5)).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
#[case::f64_large(alp_encode(PrimitiveArray::from_iter((0..100).map(|i| i as f64 * 2.5)).as_view(), None, &mut SESSION.create_execution_ctx()).unwrap())]
fn test_alp_binary_numeric(#[case] array: ALPArray) {
test_binary_numeric_array(&array.into_array(), &mut SESSION.create_execution_ctx());
}
Expand Down
8 changes: 6 additions & 2 deletions encodings/alp/src/alp/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,27 @@ impl TakeExecute for ALP {

#[cfg(test)]
mod test {
use std::sync::LazyLock;

use rstest::rstest;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::conformance::take::test_take_conformance;
use vortex_buffer::buffer;
use vortex_session::VortexSession;

use crate::alp_encode;

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

#[rstest]
#[case(buffer![1.23f32, 4.56, 7.89, 10.11, 12.13].into_array())]
#[case(buffer![100.1f64, 200.2, 300.3, 400.4, 500.5].into_array())]
#[case(PrimitiveArray::from_option_iter([Some(1.1f32), None, Some(2.2), Some(3.3), None]).into_array())]
#[case(buffer![42.42f64].into_array())]
fn test_take_alp_conformance(#[case] array: vortex_array::ArrayRef) {
let mut ctx = array_session().create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let array_primitive = array.execute::<PrimitiveArray>(&mut ctx).unwrap();
let alp = alp_encode(array_primitive.as_view(), None, &mut ctx).unwrap();
test_take_conformance(&alp.into_array(), &mut ctx);
Expand Down
2 changes: 1 addition & 1 deletion encodings/alp/src/alp/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod tests {
use crate::alp_encode;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty();
session.arrays().register(ALPPatchedPlugin);
session
});
Expand Down
2 changes: 1 addition & 1 deletion encodings/alp/src/alp_rd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ mod test {
use crate::alp_rd;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = vortex_array::array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
15 changes: 8 additions & 7 deletions encodings/alp/src/alp_rd/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,28 @@ impl CastReduce for ALPRD {

#[cfg(test)]
mod tests {
use std::sync::LazyLock;

use rstest::rstest;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::assert_arrays_eq;
use vortex_array::builtins::ArrayBuiltins;
use vortex_array::compute::conformance::cast::test_cast_conformance;
use vortex_array::dtype::DType;
use vortex_array::dtype::Nullability;
use vortex_array::dtype::PType;
use vortex_session::VortexSession;

use crate::RDEncoder;
use crate::RDEncoderExt;

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

#[test]
fn test_cast_alprd_f32_to_f64() {
let mut ctx = array_session().create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let values = vec![1.0f32, 1.1, 1.2, 1.3, 1.4];
let arr = PrimitiveArray::from_iter(values.clone());
let encoder = RDEncoder::new(&values);
Expand All @@ -85,7 +89,7 @@ mod tests {

#[test]
fn test_cast_alprd_nullable() {
let mut ctx = array_session().create_execution_ctx();
let mut ctx = SESSION.create_execution_ctx();
let arr =
PrimitiveArray::from_option_iter([Some(10.0f64), None, Some(10.1), Some(10.2), None]);
let values = vec![10.0f64, 10.1, 10.2];
Expand Down Expand Up @@ -147,9 +151,6 @@ mod tests {
encoder.encode(arr.as_view())
})]
fn test_cast_alprd_conformance(#[case] alprd: crate::alp_rd::ALPRDArray) {
test_cast_conformance(
&alprd.into_array(),
&mut array_session().create_execution_ctx(),
);
test_cast_conformance(&alprd.into_array(), &mut SESSION.create_execution_ctx());
}
}
3 changes: 1 addition & 2 deletions encodings/alp/src/alp_rd/compute/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ mod test {
use rstest::rstest;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::assert_arrays_eq;
use vortex_array::compute::conformance::filter::test_filter_conformance;
Expand All @@ -62,7 +61,7 @@ mod test {
use crate::RDEncoderExt;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
3 changes: 1 addition & 2 deletions encodings/alp/src/alp_rd/compute/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ mod tests {
use rstest::rstest;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::conformance::mask::test_mask_conformance;
use vortex_array::dtype::NativePType;
Expand All @@ -49,7 +48,7 @@ mod tests {
use crate::RDEncoderExt;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
3 changes: 1 addition & 2 deletions encodings/alp/src/alp_rd/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mod tests {
use rstest::rstest;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::array_session;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::compute::conformance::binary_numeric::test_binary_numeric_array;
use vortex_array::compute::conformance::consistency::test_array_consistency;
Expand All @@ -24,7 +23,7 @@ mod tests {
use crate::RDEncoderExt;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = array_session();
let session = VortexSession::empty();
crate::initialize(&session);
session
});
Expand Down
Loading
Loading