From 8cdf4c0b7a2b1a0906f5a02a6a39f9c839342e69 Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Tue, 16 Jun 2026 18:09:25 +0100 Subject: [PATCH 1/6] Core change Signed-off-by: Adam Gutglick --- Cargo.lock | 1 - encodings/alp/benches/alp_compress.rs | 4 +- encodings/alp/src/alp/array.rs | 4 +- encodings/alp/src/alp/plugin.rs | 3 +- encodings/bytebool/src/array.rs | 4 +- encodings/datetime-parts/src/canonical.rs | 3 +- .../experimental/onpair/benches/decode.rs | 4 +- encodings/experimental/onpair/src/tests.rs | 4 +- .../experimental/onpair/tests/big_data.rs | 4 +- .../fastlanes/benches/bitpack_compare.rs | 4 +- .../benches/bitpack_compare_sweep.rs | 4 +- .../fastlanes/benches/bitpacking_take.rs | 4 +- .../fastlanes/benches/canonicalize_bench.rs | 4 +- encodings/fastlanes/benches/cast_bitpacked.rs | 4 +- .../fastlanes/benches/compute_between.rs | 4 +- .../src/bitpacking/array/bitpack_compress.rs | 4 +- .../bitpacking/array/bitpack_decompress.rs | 4 +- .../fastlanes/src/bitpacking/array/mod.rs | 4 +- .../src/bitpacking/compute/compare.rs | 4 +- encodings/fastlanes/src/bitpacking/plugin.rs | 3 +- .../src/delta/array/delta_compress.rs | 4 +- encodings/fastlanes/src/delta/array/mod.rs | 4 +- encodings/fastlanes/src/delta/compute/cast.rs | 4 +- .../fastlanes/src/delta/vtable/operations.rs | 4 +- .../fastlanes/src/for/array/for_compress.rs | 4 +- encodings/fastlanes/src/lib.rs | 2 +- encodings/fastlanes/src/rle/compute/cast.rs | 4 +- .../fsst/benches/chunked_dict_fsst_builder.rs | 4 +- encodings/fsst/benches/fsst_compress.rs | 4 +- encodings/fsst/benches/fsst_like.rs | 4 +- encodings/fsst/benches/fsst_url_compare.rs | 4 +- encodings/fsst/src/canonical.rs | 4 +- encodings/fsst/src/compute/cast.rs | 4 +- encodings/fsst/src/compute/like.rs | 4 +- encodings/fsst/src/dfa/tests.rs | 4 +- encodings/fsst/src/kernel.rs | 4 +- encodings/parquet-variant/src/arrow.rs | 3 +- encodings/parquet-variant/src/vtable.rs | 6 +- encodings/pco/src/compute/cast.rs | 4 +- encodings/pco/src/tests.rs | 3 +- encodings/runend/benches/run_end_compress.rs | 4 +- encodings/runend/benches/run_end_decode.rs | 4 +- .../runend/benches/run_end_null_count.rs | 4 +- encodings/runend/src/array.rs | 4 +- encodings/runend/src/arrow.rs | 3 +- encodings/runend/src/compute/cast.rs | 4 +- encodings/runend/src/compute/take_from.rs | 11 +- encodings/sequence/src/compute/cast.rs | 4 +- encodings/sparse/benches/sparse_canonical.rs | 4 +- encodings/sparse/benches/sparse_pushdown.rs | 3 +- encodings/sparse/src/compute/between.rs | 3 +- encodings/sparse/src/compute/cast.rs | 4 +- encodings/sparse/src/compute/compare.rs | 3 +- encodings/sparse/src/compute/fill_null.rs | 3 +- encodings/sparse/src/compute/is_constant.rs | 5 +- encodings/sparse/src/compute/min_max.rs | 5 +- encodings/sparse/src/compute/nan_count.rs | 5 +- encodings/sparse/src/compute/null_count.rs | 5 +- encodings/sparse/src/compute/sum.rs | 5 +- encodings/zstd/benches/listview_rebuild.rs | 4 +- encodings/zstd/src/compute/cast.rs | 4 +- fuzz/src/fsst_like.rs | 4 +- vortex-array/src/aggregate_fn/accumulator.rs | 4 +- .../src/aggregate_fn/fns/bounded_max/mod.rs | 3 +- .../src/aggregate_fn/fns/bounded_min/mod.rs | 3 +- vortex-array/src/aggregate_fn/proto.rs | 2 +- vortex-array/src/aggregate_fn/session.rs | 5 +- vortex-array/src/arc_swap_map.rs | 28 +- vortex-array/src/arrays/bool/compute/cast.rs | 4 +- vortex-array/src/arrays/chunked/tests.rs | 4 +- .../src/arrays/chunked/vtable/canonical.rs | 13 +- .../src/arrays/constant/vtable/canonical.rs | 4 +- vortex-array/src/arrays/dict/compute/cast.rs | 4 +- .../src/arrays/dict/compute/min_max.rs | 4 +- vortex-array/src/arrays/dict/compute/mod.rs | 8 +- .../src/arrays/extension/compute/cast.rs | 4 +- .../src/arrays/extension/compute/rules.rs | 4 +- .../src/arrays/filter/execute/listview.rs | 4 +- .../src/arrays/filter/execute/take/tests.rs | 25 +- vortex-array/src/arrays/list/compute/cast.rs | 4 +- vortex-array/src/arrays/list/tests.rs | 4 +- .../src/arrays/listview/tests/common.rs | 4 +- .../src/arrays/listview/tests/density.rs | 4 +- .../src/arrays/listview/tests/filter.rs | 4 +- .../src/arrays/listview/tests/take.rs | 4 +- .../src/arrays/primitive/array/cast.rs | 4 +- vortex-array/src/arrays/shared/tests.rs | 4 +- .../src/arrays/struct_/compute/cast.rs | 7 +- .../src/arrays/struct_/compute/rules.rs | 3 +- .../src/arrays/varbin/compute/cast.rs | 4 +- .../src/arrays/varbinview/compute/cast.rs | 4 +- vortex-array/src/arrow/executor/list.rs | 4 +- vortex-array/src/arrow/executor/list_view.rs | 4 +- vortex-array/src/arrow/executor/run_end.rs | 4 +- vortex-array/src/arrow/session.rs | 7 +- vortex-array/src/builders/dict/bytes.rs | 4 +- vortex-array/src/builders/dict/primitive.rs | 4 +- vortex-array/src/canonical.rs | 4 +- vortex-array/src/dtype/mod.rs | 5 +- vortex-array/src/dtype/serde/proto.rs | 4 +- vortex-array/src/dtype/session.rs | 7 +- vortex-array/src/executor.rs | 8 +- vortex-array/src/lib.rs | 29 +- vortex-array/src/memory.rs | 15 +- vortex-array/src/optimizer/kernels.rs | 8 +- vortex-array/src/optimizer/mod.rs | 1 - vortex-array/src/scalar/tests/mod.rs | 5 +- vortex-array/src/scalar_fn/fns/between/mod.rs | 4 +- vortex-array/src/scalar_fn/fns/case_when.rs | 4 +- vortex-array/src/scalar_fn/session.rs | 5 +- vortex-array/src/session/mod.rs | 5 +- vortex-array/src/stats/expr.rs | 4 +- vortex-array/src/stats/rewrite.rs | 10 +- vortex-array/src/stats/rewrite/builtins.rs | 4 +- vortex-array/src/stats/session.rs | 9 +- vortex-btrblocks/benches/compress.rs | 4 +- vortex-btrblocks/benches/compress_listview.rs | 4 +- vortex-btrblocks/src/canonical_compressor.rs | 4 +- .../schemes/float/scheme_selection_tests.rs | 4 +- vortex-btrblocks/src/schemes/float/tests.rs | 4 +- .../schemes/integer/scheme_selection_tests.rs | 4 +- vortex-btrblocks/src/schemes/integer/tests.rs | 4 +- .../schemes/string/scheme_selection_tests.rs | 4 +- vortex-btrblocks/src/schemes/string/tests.rs | 4 +- vortex-btrblocks/tests/onpair_roundtrip.rs | 3 +- vortex-compressor/benches/dict_encode.rs | 4 +- vortex-compressor/benches/stats_calc.rs | 4 +- vortex-compressor/src/builtins/dict/float.rs | 6 +- .../src/builtins/dict/integer.rs | 6 +- vortex-compressor/src/compressor.rs | 4 +- vortex-cuda/benches/dynamic_dispatch_cuda.rs | 2 +- vortex-cuda/ffi/src/lib.rs | 1 - vortex-cuda/src/executor.rs | 2 +- vortex-cuda/src/session.rs | 3 +- vortex-datafusion/src/persistent/opener.rs | 4 +- vortex-file/src/multi/mod.rs | 1 + vortex-file/src/multi/session.rs | 9 +- vortex-file/src/open.rs | 21 +- vortex-file/src/tests.rs | 6 +- vortex-file/src/v2/file_stats_reader.rs | 6 +- vortex-file/tests/test_write_table.rs | 6 +- vortex-geo/src/extension/coordinate.rs | 4 +- vortex-geo/src/extension/point.rs | 4 +- vortex-geo/src/scalar_fn/distance.rs | 10 +- vortex-geo/src/tests/mod.rs | 3 +- vortex-io/src/session.rs | 16 +- vortex-json/src/arrow.rs | 5 +- vortex-layout/src/layouts/dict/reader.rs | 6 +- vortex-layout/src/layouts/zoned/reader.rs | 6 +- vortex-layout/src/scan/test.rs | 6 +- vortex-layout/src/session.rs | 5 +- vortex-layout/src/test.rs | 6 +- vortex-python/src/arrays/mod.rs | 10 +- vortex-row/benches/row_encode.rs | 4 +- vortex-session/Cargo.toml | 1 - vortex-session/src/immutable.rs | 308 ++++++++++++++++++ vortex-session/src/lib.rs | 224 ++----------- vortex-tensor/src/lib.rs | 3 +- .../common_encoding_tree_throughput.rs | 4 +- vortex/benches/single_encoding_throughput.rs | 4 +- vortex/src/lib.rs | 8 +- 161 files changed, 619 insertions(+), 720 deletions(-) create mode 100644 vortex-session/src/immutable.rs diff --git a/Cargo.lock b/Cargo.lock index 5bedb6481c0..717125c0565 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10192,7 +10192,6 @@ dependencies = [ name = "vortex-session" version = "0.1.0" dependencies = [ - "dashmap", "lasso", "parking_lot", "vortex-error", diff --git a/encodings/alp/benches/alp_compress.rs b/encodings/alp/benches/alp_compress.rs index 70a566ab0f8..f70f69c4177 100644 --- a/encodings/alp/benches/alp_compress.rs +++ b/encodings/alp/benches/alp_compress.rs @@ -19,7 +19,6 @@ use vortex_array::IntoArray; use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; use vortex_array::dtype::NativePType; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_buffer::buffer; @@ -51,8 +50,7 @@ const BENCH_ARGS: &[(usize, f64, f64)] = &[ (10_000, 0.1, 1.0), ]; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[divan::bench(types = [f32, f64], args = BENCH_ARGS)] fn compress_alp(bencher: Bencher, args: (usize, f64, f64)) { diff --git a/encodings/alp/src/alp/array.rs b/encodings/alp/src/alp/array.rs index 3f7c2ca3e6d..c85c0ea1b44 100644 --- a/encodings/alp/src/alp/array.rs +++ b/encodings/alp/src/alp/array.rs @@ -485,7 +485,6 @@ mod tests { use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; use vortex_array::assert_arrays_eq; - use vortex_array::session::ArraySession; use vortex_error::VortexExpect; use vortex_session::VortexSession; @@ -493,8 +492,7 @@ mod tests { use crate::alp_encode; use crate::decompress_into_array; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[rstest] #[case(0)] diff --git a/encodings/alp/src/alp/plugin.rs b/encodings/alp/src/alp/plugin.rs index 25266bef821..c14133109d1 100644 --- a/encodings/alp/src/alp/plugin.rs +++ b/encodings/alp/src/alp/plugin.rs @@ -98,7 +98,6 @@ mod tests { use vortex_array::arrays::PrimitiveArray; use vortex_array::arrays::patched::PatchedArraySlotsExt; use vortex_array::buffer::BufferHandle; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_error::VortexResult; use vortex_error::vortex_err; @@ -111,7 +110,7 @@ mod tests { use crate::alp_encode; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(ALPPatchedPlugin); session }); diff --git a/encodings/bytebool/src/array.rs b/encodings/bytebool/src/array.rs index 722f48f7376..225bad39ded 100644 --- a/encodings/bytebool/src/array.rs +++ b/encodings/bytebool/src/array.rs @@ -322,10 +322,8 @@ mod tests { use vortex_array::assert_arrays_eq; use vortex_array::serde::SerializeOptions; use vortex_array::serde::SerializedArray; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_buffer::ByteBufferMut; - use vortex_session::VortexSession; use vortex_session::registry::ReadContext; use super::*; @@ -367,7 +365,7 @@ mod tests { let array = ByteBool::from_option_vec(vec![Some(true), None, Some(false), None]); let dtype = array.dtype().clone(); let len = array.len(); - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(ByteBool); let ctx = ArrayContext::empty(); diff --git a/encodings/datetime-parts/src/canonical.rs b/encodings/datetime-parts/src/canonical.rs index 3a46eb6f328..eee60bbe913 100644 --- a/encodings/datetime-parts/src/canonical.rs +++ b/encodings/datetime-parts/src/canonical.rs @@ -109,7 +109,6 @@ mod test { use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_error::VortexResult; - use vortex_session::VortexSession; use crate::DateTimeParts; use crate::array::DateTimePartsArraySlotsExt; @@ -133,7 +132,7 @@ mod test { ], validity.clone(), ); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(vortex_array::array_session()); let date_times = DateTimeParts::try_from_temporal( TemporalArray::new_timestamp( milliseconds.clone().into_array(), diff --git a/encodings/experimental/onpair/benches/decode.rs b/encodings/experimental/onpair/benches/decode.rs index ff8db8c22c2..d8623018d8c 100644 --- a/encodings/experimental/onpair/benches/decode.rs +++ b/encodings/experimental/onpair/benches/decode.rs @@ -41,7 +41,6 @@ use vortex_array::builtins::ArrayBuiltins; use vortex_array::dtype::DType; use vortex_array::dtype::NativePType; use vortex_array::dtype::Nullability; -use vortex_array::session::ArraySession; use vortex_buffer::Buffer; use vortex_buffer::ByteBuffer; use vortex_mask::Mask; @@ -80,8 +79,7 @@ impl DecodeInputs { use vortex_onpair::onpair_compress; use vortex_session::VortexSession; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[derive(Copy, Clone, Debug)] enum Shape { diff --git a/encodings/experimental/onpair/src/tests.rs b/encodings/experimental/onpair/src/tests.rs index dd6fe4b0116..571240f3206 100644 --- a/encodings/experimental/onpair/src/tests.rs +++ b/encodings/experimental/onpair/src/tests.rs @@ -15,7 +15,6 @@ use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; use vortex_array::match_each_integer_ptype; -use vortex_array::session::ArraySession; use vortex_array::test_harness::check_metadata; use vortex_array::validity::Validity; use vortex_buffer::BufferMut; @@ -28,8 +27,7 @@ use crate::OnPairMetadata; use crate::compress::DEFAULT_DICT12_CONFIG; use crate::compress::onpair_compress; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn sample_input() -> VarBinArray { VarBinArray::from_iter( diff --git a/encodings/experimental/onpair/tests/big_data.rs b/encodings/experimental/onpair/tests/big_data.rs index c6bc163ea9f..9a38788378c 100644 --- a/encodings/experimental/onpair/tests/big_data.rs +++ b/encodings/experimental/onpair/tests/big_data.rs @@ -26,13 +26,11 @@ use vortex_array::builtins::ArrayBuiltins; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::scalar_fn::fns::operators::Operator; -use vortex_array::session::ArraySession; use vortex_onpair::DEFAULT_DICT12_CONFIG; use vortex_onpair::onpair_compress; use vortex_session::VortexSession; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn corpus(n: usize) -> Vec { let templates: &[&str] = &[ diff --git a/encodings/fastlanes/benches/bitpack_compare.rs b/encodings/fastlanes/benches/bitpack_compare.rs index fc6e67bb11d..e1e8a0e365b 100644 --- a/encodings/fastlanes/benches/bitpack_compare.rs +++ b/encodings/fastlanes/benches/bitpack_compare.rs @@ -23,7 +23,6 @@ use vortex_array::arrays::ConstantArray; use vortex_array::arrays::PrimitiveArray; use vortex_array::builtins::ArrayBuiltins; use vortex_array::scalar_fn::fns::operators::Operator; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Alignment; use vortex_buffer::BufferMut; @@ -36,8 +35,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); const LENS: &[usize] = &[1024, 64 * 1024]; const BIT_WIDTHS: &[u8] = &[4, 16]; diff --git a/encodings/fastlanes/benches/bitpack_compare_sweep.rs b/encodings/fastlanes/benches/bitpack_compare_sweep.rs index 570fa9ceec6..037581d016b 100644 --- a/encodings/fastlanes/benches/bitpack_compare_sweep.rs +++ b/encodings/fastlanes/benches/bitpack_compare_sweep.rs @@ -27,7 +27,6 @@ use vortex_array::builtins::ArrayBuiltins; use vortex_array::dtype::NativePType; use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::operators::Operator; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Alignment; use vortex_buffer::BufferMut; @@ -40,8 +39,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); /// Number of elements per benchmarked array (64 full FastLanes blocks). const LEN: usize = 64 * 1024; diff --git a/encodings/fastlanes/benches/bitpacking_take.rs b/encodings/fastlanes/benches/bitpacking_take.rs index 2e01f1253e6..4d0a915aa99 100644 --- a/encodings/fastlanes/benches/bitpacking_take.rs +++ b/encodings/fastlanes/benches/bitpacking_take.rs @@ -15,7 +15,6 @@ use vortex_array::IntoArray as _; use vortex_array::RecursiveCanonical; use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_buffer::buffer; @@ -27,8 +26,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[divan::bench] fn take_10_stratified(bencher: Bencher) { diff --git a/encodings/fastlanes/benches/canonicalize_bench.rs b/encodings/fastlanes/benches/canonicalize_bench.rs index 7b0ee2453f5..deea4de0032 100644 --- a/encodings/fastlanes/benches/canonicalize_bench.rs +++ b/encodings/fastlanes/benches/canonicalize_bench.rs @@ -12,7 +12,6 @@ use vortex_array::VortexSessionExecute; use vortex_array::arrays::ChunkedArray; use vortex_array::builders::ArrayBuilder; use vortex_array::builders::PrimitiveBuilder; -use vortex_array::session::ArraySession; use vortex_error::VortexExpect; use vortex_fastlanes::bitpack_compress::test_harness::make_array; use vortex_session::VortexSession; @@ -35,8 +34,7 @@ const BENCH_ARGS: &[(usize, usize, f64)] = &[ (10000, 1000, 0.00), ]; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[cfg(not(codspeed))] #[divan::bench(args = BENCH_ARGS)] diff --git a/encodings/fastlanes/benches/cast_bitpacked.rs b/encodings/fastlanes/benches/cast_bitpacked.rs index 097230930a3..9552d61c632 100644 --- a/encodings/fastlanes/benches/cast_bitpacked.rs +++ b/encodings/fastlanes/benches/cast_bitpacked.rs @@ -27,7 +27,6 @@ use vortex_array::builtins::ArrayBuiltins; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::BufferMut; use vortex_error::VortexExpect; @@ -39,8 +38,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); const U32: DType = DType::Primitive(PType::U32, Nullability::NonNullable); diff --git a/encodings/fastlanes/benches/compute_between.rs b/encodings/fastlanes/benches/compute_between.rs index 5a1bdcee655..73af3cc07d7 100644 --- a/encodings/fastlanes/benches/compute_between.rs +++ b/encodings/fastlanes/benches/compute_between.rs @@ -16,7 +16,6 @@ use vortex_array::IntoArray; use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; use vortex_array::dtype::NativePType; -use vortex_array::session::ArraySession; use vortex_error::VortexExpect; use vortex_fastlanes::bitpack_compress::bitpack_to_best_bit_width; use vortex_session::VortexSession; @@ -25,8 +24,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn generate_primitive_array( rng: &mut StdRng, diff --git a/encodings/fastlanes/src/bitpacking/array/bitpack_compress.rs b/encodings/fastlanes/src/bitpacking/array/bitpack_compress.rs index eba5be1b749..890bf72f4a5 100644 --- a/encodings/fastlanes/src/bitpacking/array/bitpack_compress.rs +++ b/encodings/fastlanes/src/bitpacking/array/bitpack_compress.rs @@ -437,7 +437,6 @@ mod test { use vortex_array::assert_arrays_eq; use vortex_array::builders::ArrayBuilder; use vortex_array::builders::PrimitiveBuilder; - use vortex_array::session::ArraySession; use vortex_buffer::Buffer; use vortex_error::VortexError; use vortex_error::vortex_err; @@ -448,8 +447,7 @@ mod test { use crate::bitpack_compress::test_harness::make_array; use crate::bitpacking::array::BitPackedArrayExt; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_best_bit_width() { diff --git a/encodings/fastlanes/src/bitpacking/array/bitpack_decompress.rs b/encodings/fastlanes/src/bitpacking/array/bitpack_decompress.rs index a4f8224966a..71e25ec8197 100644 --- a/encodings/fastlanes/src/bitpacking/array/bitpack_decompress.rs +++ b/encodings/fastlanes/src/bitpacking/array/bitpack_decompress.rs @@ -210,7 +210,6 @@ mod tests { use vortex_array::VortexSessionExecute; use vortex_array::assert_arrays_eq; use vortex_array::dtype::Nullability; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_buffer::BufferMut; @@ -226,8 +225,7 @@ mod tests { bitpack_encode(array, bit_width, None, &mut SESSION.create_execution_ctx()).unwrap() } - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn unpack(bitpacked: &BitPackedArray) -> VortexResult { unpack_array(bitpacked.as_view(), &mut SESSION.create_execution_ctx()) diff --git a/encodings/fastlanes/src/bitpacking/array/mod.rs b/encodings/fastlanes/src/bitpacking/array/mod.rs index e5c64252fbc..03c0973ce52 100644 --- a/encodings/fastlanes/src/bitpacking/array/mod.rs +++ b/encodings/fastlanes/src/bitpacking/array/mod.rs @@ -327,15 +327,13 @@ mod test { use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; use vortex_array::assert_arrays_eq; - use vortex_array::session::ArraySession; use vortex_buffer::Buffer; use vortex_session::VortexSession; use crate::BitPackedData; use crate::bitpacking::array::BitPackedArrayExt; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_encode() { diff --git a/encodings/fastlanes/src/bitpacking/compute/compare.rs b/encodings/fastlanes/src/bitpacking/compute/compare.rs index e622e64a665..d5c50751bae 100644 --- a/encodings/fastlanes/src/bitpacking/compute/compare.rs +++ b/encodings/fastlanes/src/bitpacking/compute/compare.rs @@ -118,7 +118,6 @@ mod tests { use vortex_array::scalar_fn::fns::binary::CompareKernel; use vortex_array::scalar_fn::fns::operators::CompareOperator; use vortex_array::scalar_fn::fns::operators::Operator; - use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_session::VortexSession; @@ -126,8 +125,7 @@ mod tests { use crate::BitPackedArrayExt; use crate::BitPackedData; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); /// All six operators on a small in-range input. #[rstest] diff --git a/encodings/fastlanes/src/bitpacking/plugin.rs b/encodings/fastlanes/src/bitpacking/plugin.rs index d5ecdefd0c7..a621d085514 100644 --- a/encodings/fastlanes/src/bitpacking/plugin.rs +++ b/encodings/fastlanes/src/bitpacking/plugin.rs @@ -100,7 +100,6 @@ mod tests { use vortex_array::arrays::PrimitiveArray; use vortex_array::arrays::patched::PatchedArraySlotsExt; use vortex_array::buffer::BufferHandle; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_buffer::Buffer; use vortex_error::VortexResult; @@ -114,7 +113,7 @@ mod tests { use crate::BitPackedData; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(BitPackedPatchedPlugin); session }); diff --git a/encodings/fastlanes/src/delta/array/delta_compress.rs b/encodings/fastlanes/src/delta/array/delta_compress.rs index e35778ad29e..fd17d481f43 100644 --- a/encodings/fastlanes/src/delta/array/delta_compress.rs +++ b/encodings/fastlanes/src/delta/array/delta_compress.rs @@ -106,7 +106,6 @@ mod tests { use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; use vortex_array::assert_arrays_eq; - use vortex_array::session::ArraySession; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_session::VortexSession; @@ -116,8 +115,7 @@ mod tests { use crate::delta::array::delta_decompress::delta_decompress; use crate::delta_compress; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[rstest] #[case::u32((0u32..10_000).collect())] diff --git a/encodings/fastlanes/src/delta/array/mod.rs b/encodings/fastlanes/src/delta/array/mod.rs index 33ece0deddd..7754bb37a59 100644 --- a/encodings/fastlanes/src/delta/array/mod.rs +++ b/encodings/fastlanes/src/delta/array/mod.rs @@ -38,7 +38,7 @@ pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = ["bases", "deltas"]; /// use vortex_session::VortexSession; /// use vortex_fastlanes::Delta; /// -/// let session = VortexSession::empty().with::(); +/// let session = vortex_array::array_session(); /// let primitive = PrimitiveArray::from_iter([1_u32, 2, 3, 5, 10, 11]); /// let array = Delta::try_from_primitive_array(&primitive, &mut session.create_execution_ctx()).unwrap(); /// ``` @@ -53,7 +53,7 @@ pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = ["bases", "deltas"]; /// use vortex_session::VortexSession; /// use vortex_fastlanes::Delta; /// -/// let session = VortexSession::empty().with::(); +/// let session = vortex_array::array_session(); /// let primitive = PrimitiveArray::from_iter([-3_i32, -2, -1, 0, 1, 2]); /// let array = Delta::try_from_primitive_array(&primitive, &mut session.create_execution_ctx()).unwrap(); /// ``` diff --git a/encodings/fastlanes/src/delta/compute/cast.rs b/encodings/fastlanes/src/delta/compute/cast.rs index f782eedd524..5a9167f126f 100644 --- a/encodings/fastlanes/src/delta/compute/cast.rs +++ b/encodings/fastlanes/src/delta/compute/cast.rs @@ -51,14 +51,12 @@ mod tests { use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_error::VortexResult; use vortex_session::VortexSession; use crate::Delta; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_cast_delta_unsigned_widening_wraps() { diff --git a/encodings/fastlanes/src/delta/vtable/operations.rs b/encodings/fastlanes/src/delta/vtable/operations.rs index 785cdf6aca8..53c5d726158 100644 --- a/encodings/fastlanes/src/delta/vtable/operations.rs +++ b/encodings/fastlanes/src/delta/vtable/operations.rs @@ -35,7 +35,6 @@ mod tests { use vortex_array::assert_arrays_eq; use vortex_array::compute::conformance::binary_numeric::test_binary_numeric_array; use vortex_array::compute::conformance::consistency::test_array_consistency; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_error::VortexExpect; @@ -44,8 +43,7 @@ mod tests { use crate::Delta; use crate::DeltaArray; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn da(array: &PrimitiveArray) -> DeltaArray { Delta::try_from_primitive_array(array, &mut SESSION.create_execution_ctx()) diff --git a/encodings/fastlanes/src/for/array/for_compress.rs b/encodings/fastlanes/src/for/array/for_compress.rs index ad9566027d2..48efe87e834 100644 --- a/encodings/fastlanes/src/for/array/for_compress.rs +++ b/encodings/fastlanes/src/for/array/for_compress.rs @@ -58,7 +58,6 @@ mod test { use vortex_array::dtype::PType; use vortex_array::expr::stats::StatsProvider; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -69,8 +68,7 @@ mod test { use crate::r#for::array::for_decompress::decompress; use crate::r#for::array::for_decompress::fused_decompress; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_compress_round_trip_small() { diff --git a/encodings/fastlanes/src/lib.rs b/encodings/fastlanes/src/lib.rs index 9022b7c4e2b..85b6d0259a1 100644 --- a/encodings/fastlanes/src/lib.rs +++ b/encodings/fastlanes/src/lib.rs @@ -144,7 +144,7 @@ mod test { use super::*; pub static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty(); + let session = vortex_array::array_session(); session.arrays().register(BitPacked); session.arrays().register(Delta); session.arrays().register(FoR); diff --git a/encodings/fastlanes/src/rle/compute/cast.rs b/encodings/fastlanes/src/rle/compute/cast.rs index e01d359e59b..4f5fec886f8 100644 --- a/encodings/fastlanes/src/rle/compute/cast.rs +++ b/encodings/fastlanes/src/rle/compute/cast.rs @@ -58,7 +58,6 @@ mod tests { use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_session::VortexSession; @@ -66,8 +65,7 @@ mod tests { use crate::RLEData; use crate::rle::RLEArray; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn rle(primitive: &PrimitiveArray, ctx: &mut ExecutionCtx) -> RLEArray { RLEData::encode(primitive.as_view(), ctx).unwrap() diff --git a/encodings/fsst/benches/chunked_dict_fsst_builder.rs b/encodings/fsst/benches/chunked_dict_fsst_builder.rs index 22131631a6e..2ea5cfb8f5d 100644 --- a/encodings/fsst/benches/chunked_dict_fsst_builder.rs +++ b/encodings/fsst/benches/chunked_dict_fsst_builder.rs @@ -11,7 +11,6 @@ use vortex_array::VortexSessionExecute; use vortex_array::arrays::ChunkedArray; use vortex_array::builders::builder_with_capacity; use vortex_array::dtype::NativePType; -use vortex_array::session::ArraySession; use vortex_error::VortexExpect; use vortex_fsst::test_utils::gen_dict_fsst_test_data; use vortex_session::VortexSession; @@ -29,8 +28,7 @@ const BENCH_ARGS: &[(usize, usize, usize)] = &[ (1000, 1000, 100), ]; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn make_dict_fsst_chunks( len: usize, diff --git a/encodings/fsst/benches/fsst_compress.rs b/encodings/fsst/benches/fsst_compress.rs index 88e4e26a903..cf648f68c48 100644 --- a/encodings/fsst/benches/fsst_compress.rs +++ b/encodings/fsst/benches/fsst_compress.rs @@ -23,7 +23,6 @@ use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::operators::Operator; -use vortex_array::session::ArraySession; use vortex_fsst::fsst_compress; use vortex_fsst::fsst_train_compressor; use vortex_session::VortexSession; @@ -32,8 +31,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); // [(string_count, avg_len, unique_chars)] const BENCH_ARGS: &[(usize, usize, u8)] = &[ diff --git a/encodings/fsst/benches/fsst_like.rs b/encodings/fsst/benches/fsst_like.rs index 28aa3b109ae..58a49af5582 100644 --- a/encodings/fsst/benches/fsst_like.rs +++ b/encodings/fsst/benches/fsst_like.rs @@ -14,7 +14,6 @@ use vortex_array::arrays::ConstantArray; use vortex_array::arrays::scalar_fn::ScalarFnFactoryExt; use vortex_array::scalar_fn::fns::like::Like; use vortex_array::scalar_fn::fns::like::LikeOptions; -use vortex_array::session::ArraySession; use vortex_fsst::FSSTArray; use vortex_fsst::test_utils::NUM_STRINGS; use vortex_fsst::test_utils::make_fsst_clickbench_urls; @@ -30,8 +29,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); const N: usize = NUM_STRINGS; diff --git a/encodings/fsst/benches/fsst_url_compare.rs b/encodings/fsst/benches/fsst_url_compare.rs index 656cd9f1866..00fdd2aa6f1 100644 --- a/encodings/fsst/benches/fsst_url_compare.rs +++ b/encodings/fsst/benches/fsst_url_compare.rs @@ -18,7 +18,6 @@ use vortex_array::expr::lit; use vortex_array::expr::root; use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::operators::Operator; -use vortex_array::session::ArraySession; use vortex_fsst::fsst_compress; use vortex_fsst::fsst_train_compressor; use vortex_fsst::test_utils::HIGH_MATCH_DOMAIN; @@ -31,8 +30,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); const NUM_URLS: usize = NUM_STRINGS; diff --git a/encodings/fsst/src/canonical.rs b/encodings/fsst/src/canonical.rs index a8b8171b043..67241ffb026 100644 --- a/encodings/fsst/src/canonical.rs +++ b/encodings/fsst/src/canonical.rs @@ -104,15 +104,13 @@ mod tests { use vortex_array::builders::VarBinViewBuilder; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; - use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_session::VortexSession; use crate::fsst_compress; use crate::fsst_train_compressor; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn make_data() -> (VarBinArray, Vec>>) { const STRING_COUNT: usize = 1000; diff --git a/encodings/fsst/src/compute/cast.rs b/encodings/fsst/src/compute/cast.rs index 47c324fc2a4..f6e776e16d9 100644 --- a/encodings/fsst/src/compute/cast.rs +++ b/encodings/fsst/src/compute/cast.rs @@ -98,14 +98,12 @@ mod tests { use vortex_array::compute::conformance::cast::test_cast_conformance; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; - use vortex_array::session::ArraySession; use vortex_session::VortexSession; use crate::fsst_compress; use crate::fsst_train_compressor; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_cast_fsst_nullability() { diff --git a/encodings/fsst/src/compute/like.rs b/encodings/fsst/src/compute/like.rs index 3f704f1e034..ae2402a6e51 100644 --- a/encodings/fsst/src/compute/like.rs +++ b/encodings/fsst/src/compute/like.rs @@ -96,7 +96,6 @@ mod tests { use vortex_array::scalar_fn::fns::like::Like; use vortex_array::scalar_fn::fns::like::LikeKernel; use vortex_array::scalar_fn::fns::like::LikeOptions; - use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_session::VortexSession; @@ -105,8 +104,7 @@ mod tests { use crate::fsst_compress; use crate::fsst_train_compressor; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn make_fsst(strings: &[Option<&str>], nullability: Nullability) -> FSSTArray { let varbin = VarBinArray::from_iter(strings.iter().copied(), DType::Utf8(nullability)); diff --git a/encodings/fsst/src/dfa/tests.rs b/encodings/fsst/src/dfa/tests.rs index d41fedde330..af23ae581d5 100644 --- a/encodings/fsst/src/dfa/tests.rs +++ b/encodings/fsst/src/dfa/tests.rs @@ -20,7 +20,6 @@ use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::scalar_fn::fns::like::Like; use vortex_array::scalar_fn::fns::like::LikeOptions; -use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_session::VortexSession; @@ -32,8 +31,7 @@ use crate::FSSTArray; use crate::fsst_compress; use crate::fsst_train_compressor; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); /// Helper: make a Symbol from a byte string (up to 8 bytes, zero-padded). fn sym(bytes: &[u8]) -> Symbol { diff --git a/encodings/fsst/src/kernel.rs b/encodings/fsst/src/kernel.rs index a54fe41d8cc..d45ee2978e3 100644 --- a/encodings/fsst/src/kernel.rs +++ b/encodings/fsst/src/kernel.rs @@ -36,7 +36,6 @@ mod tests { use vortex_array::dtype::Nullability; use vortex_array::expr::byte_length; use vortex_array::expr::root; - use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_mask::Mask; use vortex_session::VortexSession; @@ -45,8 +44,7 @@ mod tests { use crate::fsst_compress; use crate::fsst_train_compressor; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn build_test_fsst_array() -> ArrayRef { let mut builder = VarBinBuilder::::with_capacity(10); diff --git a/encodings/parquet-variant/src/arrow.rs b/encodings/parquet-variant/src/arrow.rs index 9bee5c738d3..760cd1fb1aa 100644 --- a/encodings/parquet-variant/src/arrow.rs +++ b/encodings/parquet-variant/src/arrow.rs @@ -295,7 +295,6 @@ mod tests { use vortex_array::assert_arrays_eq; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_error::VortexResult; @@ -306,7 +305,7 @@ mod tests { #[fixture] fn session() -> VortexSession { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); crate::initialize(&session); session } diff --git a/encodings/parquet-variant/src/vtable.rs b/encodings/parquet-variant/src/vtable.rs index f2ad4f64743..d73071fc3a6 100644 --- a/encodings/parquet-variant/src/vtable.rs +++ b/encodings/parquet-variant/src/vtable.rs @@ -323,7 +323,6 @@ mod tests { use vortex_array::dtype::PType; use vortex_array::serde::SerializeOptions; use vortex_array::serde::SerializedArray; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_array::stream::ArrayStreamExt; use vortex_array::validity::Validity; @@ -348,7 +347,7 @@ mod tests { let dtype = array.dtype().clone(); let len = array.len(); - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(ParquetVariant); let ctx = ArrayContext::empty(); @@ -387,8 +386,7 @@ mod tests { #[fixture] fn parquet_variant_file_session() -> VortexSession { - let session = VortexSession::empty() - .with::() + let session = vortex_array::array_session() .with::() .with::(); vortex_file::register_default_encodings(&session); diff --git a/encodings/pco/src/compute/cast.rs b/encodings/pco/src/compute/cast.rs index b35526c1016..89100279a3f 100644 --- a/encodings/pco/src/compute/cast.rs +++ b/encodings/pco/src/compute/cast.rs @@ -65,15 +65,13 @@ mod tests { use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_session::VortexSession; use crate::Pco; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_cast_pco_f32_to_f64() { diff --git a/encodings/pco/src/tests.rs b/encodings/pco/src/tests.rs index 20fec7dd9e0..32656c9b7fa 100644 --- a/encodings/pco/src/tests.rs +++ b/encodings/pco/src/tests.rs @@ -18,7 +18,6 @@ use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; use vortex_array::serde::SerializeOptions; use vortex_array::serde::SerializedArray; -use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_array::validity::Validity; use vortex_array::vtable::child_to_validity; @@ -33,7 +32,7 @@ use vortex_session::registry::ReadContext; use crate::PcoData; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(Pco); session }); diff --git a/encodings/runend/benches/run_end_compress.rs b/encodings/runend/benches/run_end_compress.rs index a49a5cfcb50..9bb1b35ab94 100644 --- a/encodings/runend/benches/run_end_compress.rs +++ b/encodings/runend/benches/run_end_compress.rs @@ -13,7 +13,6 @@ use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; use vortex_array::arrays::VarBinViewArray; use vortex_array::dtype::IntegerPType; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_runend::RunEnd; @@ -24,8 +23,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); const BENCH_ARGS: &[(usize, usize)] = &[ (1000, 4), diff --git a/encodings/runend/benches/run_end_decode.rs b/encodings/runend/benches/run_end_decode.rs index f509e55aed3..a2915c0b8b7 100644 --- a/encodings/runend/benches/run_end_decode.rs +++ b/encodings/runend/benches/run_end_decode.rs @@ -10,7 +10,6 @@ use divan::Bencher; use vortex_array::VortexSessionExecute; use vortex_array::arrays::BoolArray; use vortex_array::arrays::PrimitiveArray; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::BitBuffer; use vortex_buffer::BufferMut; @@ -21,8 +20,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); /// Distribution types for bool benchmarks #[derive(Clone, Copy)] diff --git a/encodings/runend/benches/run_end_null_count.rs b/encodings/runend/benches/run_end_null_count.rs index 5392e04189b..e247ad52208 100644 --- a/encodings/runend/benches/run_end_null_count.rs +++ b/encodings/runend/benches/run_end_null_count.rs @@ -12,7 +12,6 @@ use rand::rngs::StdRng; use vortex_array::IntoArray; use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; -use vortex_array::session::ArraySession; use vortex_buffer::Buffer; use vortex_runend::RunEnd; use vortex_runend::RunEndArray; @@ -50,8 +49,7 @@ const BENCH_ARGS: &[(usize, usize, f64)] = &[ (100_000, 1024, 0.5), ]; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[divan::bench(args = BENCH_ARGS)] fn null_count_run_end(bencher: Bencher, (n, run_step, valid_density): (usize, usize, f64)) { diff --git a/encodings/runend/src/array.rs b/encodings/runend/src/array.rs index 7bb069bb458..99cecddc0b0 100644 --- a/encodings/runend/src/array.rs +++ b/encodings/runend/src/array.rs @@ -521,14 +521,12 @@ mod tests { use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_session::VortexSession; use crate::RunEnd; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_runend_constructor() { diff --git a/encodings/runend/src/arrow.rs b/encodings/runend/src/arrow.rs index c26674770c0..aa03e3be5dc 100644 --- a/encodings/runend/src/arrow.rs +++ b/encodings/runend/src/arrow.rs @@ -95,7 +95,6 @@ mod tests { use vortex_array::scalar::PValue; use vortex_array::search_sorted::SearchSorted; use vortex_array::search_sorted::SearchSortedSide; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_array::validity::Validity; use vortex_buffer::Buffer; @@ -107,7 +106,7 @@ mod tests { use crate::ops::find_slice_end_index; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(RunEnd); session }); diff --git a/encodings/runend/src/compute/cast.rs b/encodings/runend/src/compute/cast.rs index f70bb0becb5..ff28baeb2d3 100644 --- a/encodings/runend/src/compute/cast.rs +++ b/encodings/runend/src/compute/cast.rs @@ -46,15 +46,13 @@ mod tests { use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_session::VortexSession; use crate::RunEnd; use crate::RunEndArray; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_cast_runend_i32_to_i64() { diff --git a/encodings/runend/src/compute/take_from.rs b/encodings/runend/src/compute/take_from.rs index 32b22eb96c5..8c3417459a0 100644 --- a/encodings/runend/src/compute/take_from.rs +++ b/encodings/runend/src/compute/take_from.rs @@ -61,7 +61,6 @@ mod tests { use vortex_array::kernel::ExecuteParentKernel; use vortex_buffer::buffer; use vortex_error::VortexResult; - use vortex_session::VortexSession; use crate::RunEnd; use crate::RunEndArray; @@ -83,7 +82,7 @@ mod tests { #[test] fn test_execute_parent_no_offset() -> VortexResult<()> { - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(vortex_array::array_session()); let (codes, dict) = make_dict_with_runend_codes(&mut ctx); let result = RunEndTakeFrom @@ -98,7 +97,7 @@ mod tests { #[test] fn test_execute_parent_with_offset() -> VortexResult<()> { - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(vortex_array::array_session()); let (codes, dict) = make_dict_with_runend_codes(&mut ctx); // Slice codes to positions 2..5 → logical codes [0, 1, 1] → values [2, 3, 3] let sliced_codes = unsafe { @@ -122,7 +121,7 @@ mod tests { #[test] fn test_execute_parent_offset_at_run_boundary() -> VortexResult<()> { - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(vortex_array::array_session()); let (codes, dict) = make_dict_with_runend_codes(&mut ctx); // Slice codes to positions 3..7 → logical codes [1, 1, 0, 0] → values [3, 3, 2, 2] let sliced_codes = unsafe { @@ -146,7 +145,7 @@ mod tests { #[test] fn test_execute_parent_single_element_offset() -> VortexResult<()> { - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(vortex_array::array_session()); let (codes, dict) = make_dict_with_runend_codes(&mut ctx); // Slice to single element at position 4 → code=1 → value=3 let sliced_codes = unsafe { @@ -170,7 +169,7 @@ mod tests { #[test] fn test_execute_parent_returns_none_for_non_codes_child() -> VortexResult<()> { - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(vortex_array::array_session()); let (codes, dict) = make_dict_with_runend_codes(&mut ctx); let result = RunEndTakeFrom.execute_parent(codes.as_view(), dict.as_view(), 1, &mut ctx)?; diff --git a/encodings/sequence/src/compute/cast.rs b/encodings/sequence/src/compute/cast.rs index e6d64fdf7c5..3750fe20fd7 100644 --- a/encodings/sequence/src/compute/cast.rs +++ b/encodings/sequence/src/compute/cast.rs @@ -99,14 +99,12 @@ mod tests { use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_array::session::ArraySession; use vortex_session::VortexSession; use crate::Sequence; use crate::SequenceArray; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_cast_sequence_nullability() { diff --git a/encodings/sparse/benches/sparse_canonical.rs b/encodings/sparse/benches/sparse_canonical.rs index 3861e26da06..8179bec369f 100644 --- a/encodings/sparse/benches/sparse_canonical.rs +++ b/encodings/sparse/benches/sparse_canonical.rs @@ -17,7 +17,6 @@ use vortex_array::arrays::PrimitiveArray; use vortex_array::dtype::Nullability::NonNullable; use vortex_array::dtype::PType::I32; use vortex_array::scalar::Scalar; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_error::VortexExpect; @@ -28,8 +27,7 @@ fn main() { divan::main(); } -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); const LIST_ARGS: &[(usize, usize, usize)] = &[ // len, patch_stride, list_size diff --git a/encodings/sparse/benches/sparse_pushdown.rs b/encodings/sparse/benches/sparse_pushdown.rs index 5abf0905f6e..d34758e7cd8 100644 --- a/encodings/sparse/benches/sparse_pushdown.rs +++ b/encodings/sparse/benches/sparse_pushdown.rs @@ -31,7 +31,6 @@ use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::operators::Operator; -use vortex_array::session::ArraySession; use vortex_buffer::Buffer; use vortex_error::VortexExpect; use vortex_session::VortexSession; @@ -45,7 +44,7 @@ const LEN: usize = 1_000_000; /// Session with Sparse and its pushdown kernels registered. static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); vortex_sparse::initialize(&session); session }); diff --git a/encodings/sparse/src/compute/between.rs b/encodings/sparse/src/compute/between.rs index 053a6694131..ba50a120174 100644 --- a/encodings/sparse/src/compute/between.rs +++ b/encodings/sparse/src/compute/between.rs @@ -74,7 +74,6 @@ mod tests { use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::between::BetweenOptions; use vortex_array::scalar_fn::fns::between::StrictComparison; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -82,7 +81,7 @@ mod tests { use crate::initialize; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); diff --git a/encodings/sparse/src/compute/cast.rs b/encodings/sparse/src/compute/cast.rs index 35ce9474589..1068987b9e4 100644 --- a/encodings/sparse/src/compute/cast.rs +++ b/encodings/sparse/src/compute/cast.rs @@ -48,15 +48,13 @@ mod tests { use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_session::VortexSession; use crate::Sparse; use crate::SparseArray; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_cast_sparse_i32_to_i64() { diff --git a/encodings/sparse/src/compute/compare.rs b/encodings/sparse/src/compute/compare.rs index c64e8142298..f9637da516a 100644 --- a/encodings/sparse/src/compute/compare.rs +++ b/encodings/sparse/src/compute/compare.rs @@ -65,7 +65,6 @@ mod tests { use vortex_array::builtins::ArrayBuiltins; use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::operators::Operator; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -74,7 +73,7 @@ mod tests { use crate::initialize; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); diff --git a/encodings/sparse/src/compute/fill_null.rs b/encodings/sparse/src/compute/fill_null.rs index fd62926b2f3..8f7d2b75a27 100644 --- a/encodings/sparse/src/compute/fill_null.rs +++ b/encodings/sparse/src/compute/fill_null.rs @@ -55,7 +55,6 @@ mod tests { use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -63,7 +62,7 @@ mod tests { use crate::initialize; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); diff --git a/encodings/sparse/src/compute/is_constant.rs b/encodings/sparse/src/compute/is_constant.rs index cfd31c6698d..eee8683df0a 100644 --- a/encodings/sparse/src/compute/is_constant.rs +++ b/encodings/sparse/src/compute/is_constant.rs @@ -73,7 +73,6 @@ mod tests { use vortex_array::VortexSessionExecute; use vortex_array::aggregate_fn::fns::is_constant::is_constant; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_buffer::buffer; use vortex_error::VortexResult; @@ -85,14 +84,14 @@ mod tests { /// Session with Sparse + its pushdown kernels. static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); /// Baseline session: Sparse registered but no pushdown kernels. static CANONICAL_SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(Sparse); session }); diff --git a/encodings/sparse/src/compute/min_max.rs b/encodings/sparse/src/compute/min_max.rs index 22ff3e86c53..cf89bc28da6 100644 --- a/encodings/sparse/src/compute/min_max.rs +++ b/encodings/sparse/src/compute/min_max.rs @@ -69,7 +69,6 @@ mod tests { use vortex_array::aggregate_fn::fns::min_max::MinMaxResult; use vortex_array::aggregate_fn::fns::min_max::min_max; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -79,13 +78,13 @@ mod tests { use crate::initialize; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); static CANONICAL_SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(Sparse); session }); diff --git a/encodings/sparse/src/compute/nan_count.rs b/encodings/sparse/src/compute/nan_count.rs index 7fe03e21103..9a8a3a871c1 100644 --- a/encodings/sparse/src/compute/nan_count.rs +++ b/encodings/sparse/src/compute/nan_count.rs @@ -77,7 +77,6 @@ mod tests { use vortex_array::VortexSessionExecute; use vortex_array::aggregate_fn::fns::nan_count::nan_count; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -87,13 +86,13 @@ mod tests { use crate::initialize; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); static CANONICAL_SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(Sparse); session }); diff --git a/encodings/sparse/src/compute/null_count.rs b/encodings/sparse/src/compute/null_count.rs index ad5e875ea6c..f63dad80205 100644 --- a/encodings/sparse/src/compute/null_count.rs +++ b/encodings/sparse/src/compute/null_count.rs @@ -67,7 +67,6 @@ mod tests { use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -77,13 +76,13 @@ mod tests { use crate::initialize; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); static CANONICAL_SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(Sparse); session }); diff --git a/encodings/sparse/src/compute/sum.rs b/encodings/sparse/src/compute/sum.rs index 4b068aa57b4..a47884e6f0f 100644 --- a/encodings/sparse/src/compute/sum.rs +++ b/encodings/sparse/src/compute/sum.rs @@ -72,7 +72,6 @@ mod tests { use vortex_array::VortexSessionExecute; use vortex_array::aggregate_fn::fns::sum::sum; use vortex_array::scalar::Scalar; - use vortex_array::session::ArraySession; use vortex_array::session::ArraySessionExt; use vortex_buffer::buffer; use vortex_error::VortexResult; @@ -83,13 +82,13 @@ mod tests { use crate::initialize; static SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); initialize(&session); session }); static CANONICAL_SESSION: LazyLock = LazyLock::new(|| { - let session = VortexSession::empty().with::(); + let session = vortex_array::array_session(); session.arrays().register(Sparse); session }); diff --git a/encodings/zstd/benches/listview_rebuild.rs b/encodings/zstd/benches/listview_rebuild.rs index fe4e9f063d1..e3c0e6d5dd1 100644 --- a/encodings/zstd/benches/listview_rebuild.rs +++ b/encodings/zstd/benches/listview_rebuild.rs @@ -11,7 +11,6 @@ use vortex_array::VortexSessionExecute; use vortex_array::arrays::ListViewArray; use vortex_array::arrays::VarBinViewArray; use vortex_array::arrays::listview::ListViewRebuildMode; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_session::VortexSession; @@ -19,8 +18,7 @@ use vortex_zstd::Zstd; use vortex_zstd::ZstdData; /// A shared session for the `ListView` rebuild benchmark, used to create execution contexts. -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[divan::bench(sample_size = 1000)] fn rebuild_naive(bencher: Bencher) { diff --git a/encodings/zstd/src/compute/cast.rs b/encodings/zstd/src/compute/cast.rs index 6cbe4f37795..52f6f8020c0 100644 --- a/encodings/zstd/src/compute/cast.rs +++ b/encodings/zstd/src/compute/cast.rs @@ -83,15 +83,13 @@ mod tests { use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_session::VortexSession; use crate::Zstd; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_cast_zstd_i32_to_i64() { diff --git a/fuzz/src/fsst_like.rs b/fuzz/src/fsst_like.rs index 5ca10af310a..ec310a0b81a 100644 --- a/fuzz/src/fsst_like.rs +++ b/fuzz/src/fsst_like.rs @@ -21,7 +21,6 @@ use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; use vortex_array::scalar_fn::fns::like::Like; use vortex_array::scalar_fn::fns::like::LikeOptions; -use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_fsst::FSSTArray; use vortex_fsst::fsst_compress; @@ -32,8 +31,7 @@ use crate::error::Backtrace; use crate::error::VortexFuzzError; use crate::error::VortexFuzzResult; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); /// A random string from a small alphabet (`a..=h`) with bounded length. #[derive(Debug)] diff --git a/vortex-array/src/aggregate_fn/accumulator.rs b/vortex-array/src/aggregate_fn/accumulator.rs index c89418e67a6..4e1aff762ad 100644 --- a/vortex-array/src/aggregate_fn/accumulator.rs +++ b/vortex-array/src/aggregate_fn/accumulator.rs @@ -264,7 +264,6 @@ impl DynAccumulator for Accumulator { mod tests { use vortex_buffer::buffer; use vortex_error::VortexResult; - use vortex_session::SessionExt; use vortex_session::VortexSession; use crate::ArrayRef; @@ -289,7 +288,6 @@ mod tests { use crate::dtype::Nullability; use crate::dtype::PType; use crate::scalar::Scalar; - use crate::session::ArraySession; /// Mean partial sentinel `{sum: 42.0, count: 1}` — distinguishable from the /// natural fan-out result `{sum: 7.0, count: 1}` that `Combined::try_accumulate` @@ -337,7 +335,7 @@ mod tests { } fn fresh_session() -> VortexSession { - VortexSession::empty().with::() + crate::array_session() } fn dict_of_seven() -> ArrayRef { diff --git a/vortex-array/src/aggregate_fn/fns/bounded_max/mod.rs b/vortex-array/src/aggregate_fn/fns/bounded_max/mod.rs index 998b6032938..37188f25797 100644 --- a/vortex-array/src/aggregate_fn/fns/bounded_max/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/bounded_max/mod.rs @@ -262,7 +262,6 @@ mod tests { use crate::arrays::VarBinViewArray; use crate::dtype::Nullability; use crate::scalar::Scalar; - use crate::session::ArraySession; use crate::validity::Validity; fn max_bytes(value: usize) -> NonZeroUsize { @@ -270,7 +269,7 @@ mod tests { } fn fresh_session() -> VortexSession { - VortexSession::empty().with::() + crate::array_session() } #[test] diff --git a/vortex-array/src/aggregate_fn/fns/bounded_min/mod.rs b/vortex-array/src/aggregate_fn/fns/bounded_min/mod.rs index 7d24457e150..661b7fe1227 100644 --- a/vortex-array/src/aggregate_fn/fns/bounded_min/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/bounded_min/mod.rs @@ -250,7 +250,6 @@ mod tests { use crate::arrays::VarBinViewArray; use crate::dtype::Nullability; use crate::scalar::Scalar; - use crate::session::ArraySession; use crate::validity::Validity; fn max_bytes(value: usize) -> NonZeroUsize { @@ -258,7 +257,7 @@ mod tests { } fn fresh_session() -> VortexSession { - VortexSession::empty().with::() + crate::array_session() } #[test] diff --git a/vortex-array/src/aggregate_fn/proto.rs b/vortex-array/src/aggregate_fn/proto.rs index bff198b3955..fd2d92470e6 100644 --- a/vortex-array/src/aggregate_fn/proto.rs +++ b/vortex-array/src/aggregate_fn/proto.rs @@ -155,7 +155,7 @@ mod tests { #[test] fn aggregate_fn_serde() { - let session = VortexSession::empty().with::(); + let session = crate::array_session(); session.aggregate_fns().register(TestAgg); let agg_fn = TestAgg.bind(EmptyOptions); diff --git a/vortex-array/src/aggregate_fn/session.rs b/vortex-array/src/aggregate_fn/session.rs index c6d7542a687..b309fd02a10 100644 --- a/vortex-array/src/aggregate_fn/session.rs +++ b/vortex-array/src/aggregate_fn/session.rs @@ -4,7 +4,6 @@ use std::any::Any; use std::sync::Arc; -use vortex_session::Ref; use vortex_session::SessionExt; use vortex_session::SessionVar; @@ -50,7 +49,7 @@ use crate::arrays::dict::compute::min_max::DictMinMaxKernel; /// The default session registers the built-in aggregate functions and kernels. Additional /// aggregate functions and kernels may be registered by extensions when they are added to a /// [`VortexSession`](vortex_session::VortexSession). -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct AggregateFnSession { registry: ArcSwapMap, @@ -222,7 +221,7 @@ impl AggregateFnSession { /// Extension trait for accessing aggregate function session data. pub trait AggregateFnSessionExt: SessionExt { /// Returns the aggregate function session data. - fn aggregate_fns(&self) -> Ref<'_, AggregateFnSession> { + fn aggregate_fns(&self) -> &AggregateFnSession { self.get::() } } diff --git a/vortex-array/src/arc_swap_map.rs b/vortex-array/src/arc_swap_map.rs index aff46c22d73..e8308d6343c 100644 --- a/vortex-array/src/arc_swap_map.rs +++ b/vortex-array/src/arc_swap_map.rs @@ -23,14 +23,27 @@ use vortex_utils::aliases::hash_map::HashMap; /// optimizer-kernel and aggregate-function registries). Because every write /// clones the entire map, it is intended for maps that are written rarely /// (typically only while a session is being configured) and read often. +/// +/// The map is held behind an [`Arc`] so that [`Clone`] shares the same +/// underlying cell: a registry mutated through one clone is observed by all +/// others. Session variables rely on this so that encodings registered after a +/// session is built remain visible to clones of that session. pub(crate) struct ArcSwapMap { - inner: ArcSwap>, + inner: Arc>>, } impl Default for ArcSwapMap { fn default() -> Self { Self { - inner: ArcSwap::from_pointee(HashMap::default()), + inner: Arc::new(ArcSwap::from_pointee(HashMap::default())), + } + } +} + +impl Clone for ArcSwapMap { + fn clone(&self) -> Self { + Self { + inner: Arc::clone(&self.inner), } } } @@ -148,4 +161,15 @@ mod tests { map.insert(2, 2); assert_eq!(map.read(|m| m.values().sum::()), 3); } + + #[test] + fn clone_shares_the_same_cell() { + let map = ArcSwapMap::::default(); + let clone = map.clone(); + // A write through one handle is observed through the other. + map.insert(1, 10); + assert_eq!(clone.get(&1), Some(10)); + clone.insert(2, 20); + assert_eq!(map.get(&2), Some(20)); + } } diff --git a/vortex-array/src/arrays/bool/compute/cast.rs b/vortex-array/src/arrays/bool/compute/cast.rs index 0855af21f25..fe9332346ca 100644 --- a/vortex-array/src/arrays/bool/compute/cast.rs +++ b/vortex-array/src/arrays/bool/compute/cast.rs @@ -67,10 +67,8 @@ mod tests { use crate::compute::conformance::cast::test_cast_conformance; use crate::dtype::DType; use crate::dtype::Nullability; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn try_cast_bool_success() { diff --git a/vortex-array/src/arrays/chunked/tests.rs b/vortex-array/src/arrays/chunked/tests.rs index 00d113f273a..970656491ee 100644 --- a/vortex-array/src/arrays/chunked/tests.rs +++ b/vortex-array/src/arrays/chunked/tests.rs @@ -30,11 +30,9 @@ use crate::dtype::Nullability; use crate::dtype::PType; use crate::dtype::PType::I32; use crate::executor::execute_into_builder; -use crate::session::ArraySession; use crate::validity::Validity; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(crate::array_session); fn chunked_array() -> ChunkedArray { ChunkedArray::try_new( diff --git a/vortex-array/src/arrays/chunked/vtable/canonical.rs b/vortex-array/src/arrays/chunked/vtable/canonical.rs index adbe447604b..8c004f59ccb 100644 --- a/vortex-array/src/arrays/chunked/vtable/canonical.rs +++ b/vortex-array/src/arrays/chunked/vtable/canonical.rs @@ -323,12 +323,10 @@ mod tests { use crate::memory::MemorySessionExt; use crate::memory::WritableHostBuffer; use crate::scalar::Scalar; - use crate::session::ArraySession; use crate::validity::Validity; /// A shared session for these chunked-array tests, used to create execution contexts. - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[derive(Debug)] struct CountingAllocator { @@ -640,12 +638,9 @@ mod tests { #[test] fn list_canonicalize_uses_memory_session_allocator() { let allocations = Arc::new(AtomicUsize::new(0)); - let session = VortexSession::empty(); - session - .memory_mut() - .set_allocator(Arc::new(CountingAllocator { - allocations: Arc::clone(&allocations), - })); + let session = crate::array_session().with_allocator(Arc::new(CountingAllocator { + allocations: Arc::clone(&allocations), + })); let mut ctx = ExecutionCtx::new(session); let l1 = ListArray::try_new( diff --git a/vortex-array/src/arrays/constant/vtable/canonical.rs b/vortex-array/src/arrays/constant/vtable/canonical.rs index dd891778949..e12db00c118 100644 --- a/vortex-array/src/arrays/constant/vtable/canonical.rs +++ b/vortex-array/src/arrays/constant/vtable/canonical.rs @@ -361,12 +361,10 @@ mod tests { use crate::expr::stats::Stat; use crate::expr::stats::StatsProvider; use crate::scalar::Scalar; - use crate::session::ArraySession; use crate::validity::Validity; /// A shared session for these constant-array tests, used to create execution contexts. - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_canonicalize_null() { diff --git a/vortex-array/src/arrays/dict/compute/cast.rs b/vortex-array/src/arrays/dict/compute/cast.rs index 490f1f31549..63b20989f4c 100644 --- a/vortex-array/src/arrays/dict/compute/cast.rs +++ b/vortex-array/src/arrays/dict/compute/cast.rs @@ -66,10 +66,8 @@ mod tests { use crate::dtype::DType; use crate::dtype::Nullability; use crate::dtype::PType; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_cast_dict_to_wider_type() { diff --git a/vortex-array/src/arrays/dict/compute/min_max.rs b/vortex-array/src/arrays/dict/compute/min_max.rs index 47a1f0eb8ee..8910ab12a53 100644 --- a/vortex-array/src/arrays/dict/compute/min_max.rs +++ b/vortex-array/src/arrays/dict/compute/min_max.rs @@ -74,10 +74,8 @@ mod tests { use crate::arrays::DictArray; use crate::arrays::PrimitiveArray; use crate::builders::dict::dict_encode; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); fn assert_min_max(array: &ArrayRef, expected: Option<(i32, i32)>) -> VortexResult<()> { let mut ctx = SESSION.create_execution_ctx(); diff --git a/vortex-array/src/arrays/dict/compute/mod.rs b/vortex-array/src/arrays/dict/compute/mod.rs index 28ba1d84789..5ed65c49bbc 100644 --- a/vortex-array/src/arrays/dict/compute/mod.rs +++ b/vortex-array/src/arrays/dict/compute/mod.rs @@ -81,10 +81,8 @@ mod test { use crate::dtype::Nullability; use crate::dtype::PType::I32; use crate::scalar_fn::fns::operators::Operator; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn canonicalise_nullable_primitive() { @@ -332,10 +330,8 @@ mod tests { use crate::compute::conformance::consistency::test_array_consistency; use crate::dtype::DType; use crate::dtype::Nullability; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[rstest] // Primitive arrays diff --git a/vortex-array/src/arrays/extension/compute/cast.rs b/vortex-array/src/arrays/extension/compute/cast.rs index c8e7fa17c36..9558eb35308 100644 --- a/vortex-array/src/arrays/extension/compute/cast.rs +++ b/vortex-array/src/arrays/extension/compute/cast.rs @@ -63,10 +63,8 @@ mod tests { use crate::executor::VortexSessionExecute; use crate::extension::datetime::TimeUnit; use crate::extension::datetime::Timestamp; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn cast_same_ext_dtype() { diff --git a/vortex-array/src/arrays/extension/compute/rules.rs b/vortex-array/src/arrays/extension/compute/rules.rs index 59a8c314517..611be1510a4 100644 --- a/vortex-array/src/arrays/extension/compute/rules.rs +++ b/vortex-array/src/arrays/extension/compute/rules.rs @@ -111,10 +111,8 @@ mod tests { use crate::scalar::ScalarValue; use crate::scalar_fn::fns::binary::Binary; use crate::scalar_fn::fns::operators::Operator; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] struct TestExt; diff --git a/vortex-array/src/arrays/filter/execute/listview.rs b/vortex-array/src/arrays/filter/execute/listview.rs index b3f787133ab..d6d55a72837 100644 --- a/vortex-array/src/arrays/filter/execute/listview.rs +++ b/vortex-array/src/arrays/filter/execute/listview.rs @@ -73,11 +73,9 @@ mod test { use crate::arrays::listview::ListViewArrayExt; use crate::assert_arrays_eq; use crate::compute::conformance::filter::test_filter_conformance; - use crate::session::ArraySession; use crate::validity::Validity; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_filter_listview_conformance() { diff --git a/vortex-array/src/arrays/filter/execute/take/tests.rs b/vortex-array/src/arrays/filter/execute/take/tests.rs index fd40865bf02..3d3a0d1a4e3 100644 --- a/vortex-array/src/arrays/filter/execute/take/tests.rs +++ b/vortex-array/src/arrays/filter/execute/take/tests.rs @@ -4,7 +4,6 @@ use vortex_buffer::buffer; use vortex_error::VortexResult; use vortex_mask::Mask; -use vortex_session::VortexSession; use crate::IntoArray; use crate::RecursiveCanonical; @@ -41,7 +40,7 @@ fn test_take_execute_kernel_maps_indices_through_filter() -> VortexResult<()> { filter.clone(), )? .into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter .execute_parent(&parent, 1, &mut ctx)? @@ -70,7 +69,7 @@ fn test_take_execute_kernel_nullable_fast_path_maps_indices_through_filter() -> filter.clone(), )? .into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter .execute_parent(&parent, 1, &mut ctx)? @@ -92,7 +91,7 @@ fn test_take_execute_kernel_fast_path_maps_indices_through_filter() -> VortexRes ) .into_array(); let parent = DictArray::try_new(buffer![2u64, 0, 3].into_array(), filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter .execute_parent(&parent, 1, &mut ctx)? @@ -113,7 +112,7 @@ fn assert_take_execute_rejects_out_of_bounds_rank( ) -> VortexResult<()> { let filter = FilterArray::new(child, filter_mask).into_array(); let parent = DictArray::try_new(codes, filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); if let Err(err) = filter.execute_parent(&parent, 1, &mut ctx) { assert!( @@ -191,7 +190,7 @@ fn test_take_execute_kernel_handles_empty_sequential_take() -> VortexResult<()> filter.clone(), )? .into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter .execute_parent(&parent, 1, &mut ctx)? @@ -216,7 +215,7 @@ fn assert_take_execute_maps_child_dtype( let filter = FilterArray::new(child, Mask::from_iter([true, false, true, true, false])).into_array(); let parent = DictArray::try_new(buffer![2u64, 0, 1].into_array(), filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter .execute_parent(&parent, 1, &mut ctx)? @@ -234,7 +233,7 @@ fn test_take_execute_kernel_skips_bool_filter_child() -> VortexResult<()> { ) .into_array(); let parent = DictArray::try_new(buffer![2u64, 0, 1].into_array(), filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter.execute_parent(&parent, 1, &mut ctx)?; @@ -256,7 +255,7 @@ fn execute_primitive_take( .into_array(); let indices = PrimitiveArray::from_iter((0..take_len).map(|idx| (idx % filtered_len) as u64)); let parent = DictArray::try_new(indices.into_array(), filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); filter.execute_parent(&parent, 1, &mut ctx) } @@ -323,7 +322,7 @@ fn test_take_execute_kernel_handles_nullable_primitive_filter_child() -> VortexR ) .into_array(); let parent = DictArray::try_new(buffer![2u64, 0, 1].into_array(), filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter.execute_parent(&parent, 1, &mut ctx)?; @@ -345,7 +344,7 @@ fn test_take_execute_kernel_preserves_nullable_all_valid_fixed_width_child() -> ) .into_array(); let parent = DictArray::try_new(buffer![0u64, 1].into_array(), filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter .execute_parent(&parent, 1, &mut ctx)? @@ -372,7 +371,7 @@ fn test_take_execute_kernel_handles_nullable_decimal_filter_child() -> VortexRes ) .into_array(); let parent = DictArray::try_new(buffer![2u64, 0, 1].into_array(), filter.clone())?.into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter.execute_parent(&parent, 1, &mut ctx)?; @@ -465,7 +464,7 @@ fn test_take_execute_kernel_preserves_nullable_indices_dtype_fast_path() -> Vort filter.clone(), )? .into_array(); - let mut ctx = ExecutionCtx::new(VortexSession::empty()); + let mut ctx = ExecutionCtx::new(crate::array_session()); let result = filter .execute_parent(&parent, 1, &mut ctx)? diff --git a/vortex-array/src/arrays/list/compute/cast.rs b/vortex-array/src/arrays/list/compute/cast.rs index e6d71f6e80c..c297d378392 100644 --- a/vortex-array/src/arrays/list/compute/cast.rs +++ b/vortex-array/src/arrays/list/compute/cast.rs @@ -66,7 +66,6 @@ mod tests { use std::sync::LazyLock; use rstest::rstest; - use vortex_array::session::ArraySession; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -86,8 +85,7 @@ mod tests { use crate::dtype::PType; use crate::validity::Validity; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_cast_list_success() { diff --git a/vortex-array/src/arrays/list/tests.rs b/vortex-array/src/arrays/list/tests.rs index 2ed260a5f55..b58b5e0a365 100644 --- a/vortex-array/src/arrays/list/tests.rs +++ b/vortex-array/src/arrays/list/tests.rs @@ -25,12 +25,10 @@ use crate::dtype::DType; use crate::dtype::Nullability; use crate::dtype::PType::I32; use crate::scalar::Scalar; -use crate::session::ArraySession; use crate::validity::Validity; /// A shared session for `List` tests, used to create execution contexts. -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_empty_list_array() { diff --git a/vortex-array/src/arrays/listview/tests/common.rs b/vortex-array/src/arrays/listview/tests/common.rs index be89b586209..1398a8defe6 100644 --- a/vortex-array/src/arrays/listview/tests/common.rs +++ b/vortex-array/src/arrays/listview/tests/common.rs @@ -12,13 +12,11 @@ use crate::IntoArray; use crate::arrays::BoolArray; use crate::arrays::ListViewArray; use crate::arrays::PrimitiveArray; -use crate::session::ArraySession; use crate::validity::Validity; /// A shared session for `ListView` tests, used to create execution contexts via /// [`create_execution_ctx`](crate::VortexSessionExecute::create_execution_ctx). -pub static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +pub static SESSION: LazyLock = LazyLock::new(crate::array_session); /// Creates a basic ListView for testing: [[0,1,2], [3,4], [5,6], [7,8,9]] pub fn create_basic_listview() -> ListViewArray { diff --git a/vortex-array/src/arrays/listview/tests/density.rs b/vortex-array/src/arrays/listview/tests/density.rs index ad408f650b3..8538a9fe20c 100644 --- a/vortex-array/src/arrays/listview/tests/density.rs +++ b/vortex-array/src/arrays/listview/tests/density.rs @@ -7,7 +7,6 @@ use vortex_buffer::buffer; use vortex_error::VortexResult; use vortex_mask::Mask; -use vortex_session::VortexSession; use super::common::create_basic_listview; use super::common::create_empty_lists_listview; @@ -23,13 +22,12 @@ use crate::arrays::listview::tests::common::create_empty_elements_listview; use crate::expr::stats::Precision; use crate::expr::stats::Stat; use crate::scalar::ScalarValue; -use crate::session::ArraySession; use crate::validity::Validity; const EPS: f32 = 1e-6; fn test_execution_ctx() -> ExecutionCtx { - let session = VortexSession::empty().with::(); + let session = crate::array_session(); session.create_execution_ctx() } diff --git a/vortex-array/src/arrays/listview/tests/filter.rs b/vortex-array/src/arrays/listview/tests/filter.rs index e218c94926a..756b1192aef 100644 --- a/vortex-array/src/arrays/listview/tests/filter.rs +++ b/vortex-array/src/arrays/listview/tests/filter.rs @@ -22,11 +22,9 @@ use crate::arrays::PrimitiveArray; use crate::arrays::listview::ListViewArrayExt; use crate::assert_arrays_eq; use crate::compute::conformance::filter::test_filter_conformance; -use crate::session::ArraySession; use crate::validity::Validity; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(crate::array_session); // Conformance tests for common filter scenarios. #[rstest] diff --git a/vortex-array/src/arrays/listview/tests/take.rs b/vortex-array/src/arrays/listview/tests/take.rs index 572340259e9..4391af98ee2 100644 --- a/vortex-array/src/arrays/listview/tests/take.rs +++ b/vortex-array/src/arrays/listview/tests/take.rs @@ -21,11 +21,9 @@ use crate::arrays::PrimitiveArray; use crate::arrays::listview::ListViewArrayExt; use crate::assert_arrays_eq; use crate::compute::conformance::take::test_take_conformance; -use crate::session::ArraySession; use crate::validity::Validity; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(crate::array_session); // Conformance tests for common take scenarios. #[rstest] diff --git a/vortex-array/src/arrays/primitive/array/cast.rs b/vortex-array/src/arrays/primitive/array/cast.rs index 0d9db991d26..bdab4f0beb8 100644 --- a/vortex-array/src/arrays/primitive/array/cast.rs +++ b/vortex-array/src/arrays/primitive/array/cast.rs @@ -50,11 +50,9 @@ mod tests { use crate::dtype::DType; use crate::dtype::Nullability; use crate::dtype::PType; - use crate::session::ArraySession; use crate::validity::Validity; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_downcast_all_invalid() { diff --git a/vortex-array/src/arrays/shared/tests.rs b/vortex-array/src/arrays/shared/tests.rs index b8301389074..fd454a8521e 100644 --- a/vortex-array/src/arrays/shared/tests.rs +++ b/vortex-array/src/arrays/shared/tests.rs @@ -3,7 +3,6 @@ use vortex_buffer::buffer; use vortex_error::VortexResult; -use vortex_session::VortexSession; use crate::Canonical; use crate::ExecutionCtx; @@ -13,7 +12,6 @@ use crate::arrays::SharedArray; use crate::arrays::shared::SharedArrayExt; use crate::hash::ArrayEq; use crate::hash::EqMode; -use crate::session::ArraySession; use crate::validity::Validity; #[test] @@ -21,7 +19,7 @@ fn shared_array_caches_on_canonicalize() -> VortexResult<()> { let array = PrimitiveArray::new(buffer![1i32, 2, 3], Validity::NonNullable).into_array(); let shared = SharedArray::new(array); - let session = VortexSession::empty().with::(); + let session = crate::array_session(); let mut ctx = ExecutionCtx::new(session); let first = shared.get_or_compute(|source| source.clone().execute::(&mut ctx))?; diff --git a/vortex-array/src/arrays/struct_/compute/cast.rs b/vortex-array/src/arrays/struct_/compute/cast.rs index f954dbe2fea..1f8ee705e9d 100644 --- a/vortex-array/src/arrays/struct_/compute/cast.rs +++ b/vortex-array/src/arrays/struct_/compute/cast.rs @@ -140,16 +140,13 @@ mod tests { use crate::dtype::Nullability; use crate::dtype::PType; use crate::dtype::StructFields; - use crate::optimizer::kernels::ArrayKernels; use crate::optimizer::kernels::ArrayKernelsExt; use crate::optimizer::kernels::ExecuteParentFn; use crate::scalar::Scalar; use crate::scalar_fn::fns::cast::Cast; - use crate::session::ArraySession; use crate::validity::Validity; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); fn null_struct_cast_execute_parent( child: &ArrayRef, @@ -224,7 +221,7 @@ mod tests { .try_new_array(source.len(), target.clone(), [source]) .unwrap(); let parent_id = cast.encoding_id(); - let session = VortexSession::empty().with::(); + let session = crate::array_session(); session.kernels().register_execute_parent( parent_id, child_id, diff --git a/vortex-array/src/arrays/struct_/compute/rules.rs b/vortex-array/src/arrays/struct_/compute/rules.rs index ae3a67b50e3..287732beb7d 100644 --- a/vortex-array/src/arrays/struct_/compute/rules.rs +++ b/vortex-array/src/arrays/struct_/compute/rules.rs @@ -153,8 +153,7 @@ mod tests { use crate::scalar_fn::ScalarFnVTable; use crate::scalar_fn::fns::cast::Cast; use crate::validity::Validity; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); fn no_struct_cast_plugin( _child: &ArrayRef, diff --git a/vortex-array/src/arrays/varbin/compute/cast.rs b/vortex-array/src/arrays/varbin/compute/cast.rs index ca5dfde56e5..5983886ea30 100644 --- a/vortex-array/src/arrays/varbin/compute/cast.rs +++ b/vortex-array/src/arrays/varbin/compute/cast.rs @@ -81,10 +81,8 @@ mod tests { use crate::compute::conformance::cast::test_cast_conformance; use crate::dtype::DType; use crate::dtype::Nullability; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[rstest] #[case( diff --git a/vortex-array/src/arrays/varbinview/compute/cast.rs b/vortex-array/src/arrays/varbinview/compute/cast.rs index 449e735d1fc..476c74e7309 100644 --- a/vortex-array/src/arrays/varbinview/compute/cast.rs +++ b/vortex-array/src/arrays/varbinview/compute/cast.rs @@ -85,10 +85,8 @@ mod tests { use crate::compute::conformance::cast::test_cast_conformance; use crate::dtype::DType; use crate::dtype::Nullability; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[rstest] #[case( diff --git a/vortex-array/src/arrow/executor/list.rs b/vortex-array/src/arrow/executor/list.rs index e8bf95e14cd..7bf7a16f496 100644 --- a/vortex-array/src/arrow/executor/list.rs +++ b/vortex-array/src/arrow/executor/list.rs @@ -222,12 +222,10 @@ mod tests { use crate::arrow::executor::list::ListViewArray; use crate::dtype::DType; use crate::dtype::Nullability::NonNullable; - use crate::session::ArraySession; use crate::validity::Validity; /// A shared session for these list-executor tests, used to create execution contexts. - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_to_arrow_list_i32() -> VortexResult<()> { diff --git a/vortex-array/src/arrow/executor/list_view.rs b/vortex-array/src/arrow/executor/list_view.rs index 5a2cd517b37..7d5666b3762 100644 --- a/vortex-array/src/arrow/executor/list_view.rs +++ b/vortex-array/src/arrow/executor/list_view.rs @@ -124,12 +124,10 @@ mod tests { use crate::arrow::ArrowArrayExecutor; use crate::arrow::executor::list_view::ListViewArray; use crate::arrow::executor::list_view::PrimitiveArray; - use crate::session::ArraySession; use crate::validity::Validity; /// A shared session for these list-view-executor tests, used to create execution contexts. - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn trims_zero_copy_with_significant_trailing_waste() -> VortexResult<()> { diff --git a/vortex-array/src/arrow/executor/run_end.rs b/vortex-array/src/arrow/executor/run_end.rs index b579cab7e4d..0632f871f29 100644 --- a/vortex-array/src/arrow/executor/run_end.rs +++ b/vortex-array/src/arrow/executor/run_end.rs @@ -217,10 +217,8 @@ mod tests { use crate::dtype::PType; use crate::executor::VortexSessionExecute; use crate::scalar::Scalar; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); fn ree_type(ends: DataType, values_dtype: DataType) -> DataType { DataType::RunEndEncoded( diff --git a/vortex-array/src/arrow/session.rs b/vortex-array/src/arrow/session.rs index 705f7971f90..e94d403c242 100644 --- a/vortex-array/src/arrow/session.rs +++ b/vortex-array/src/arrow/session.rs @@ -39,7 +39,6 @@ use tracing::trace; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_ensure; -use vortex_session::Ref; use vortex_session::SessionExt; use vortex_session::SessionVar; use vortex_session::registry::Id; @@ -163,7 +162,7 @@ pub type ArrowImportVTableRef = Arc; /// keyed by Arrow extension name. The default session pre-registers the builtin UUID /// plugin; temporal extensions are handled by the canonical Arrow ↔ Vortex path and do not /// need plugins. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct ArrowSession { exporters: ArcSwapMap>, exporters_by_vortex: ArcSwapMap>, @@ -610,11 +609,11 @@ impl SessionVar for ArrowSession { /// Extension trait for accessing the [`ArrowSession`] on a Vortex session. pub trait ArrowSessionExt: SessionExt { /// Get the Arrow session. - fn arrow(&self) -> Ref<'_, ArrowSession>; + fn arrow(&self) -> &ArrowSession; } impl ArrowSessionExt for S { - fn arrow(&self) -> Ref<'_, ArrowSession> { + fn arrow(&self) -> &ArrowSession { self.get::() } } diff --git a/vortex-array/src/builders/dict/bytes.rs b/vortex-array/src/builders/dict/bytes.rs index 081cef33f39..65c49fa0173 100644 --- a/vortex-array/src/builders/dict/bytes.rs +++ b/vortex-array/src/builders/dict/bytes.rs @@ -217,10 +217,8 @@ mod test { use crate::arrays::VarBinArray; use crate::arrays::dict::DictArraySlotsExt; use crate::builders::dict::dict_encode; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn encode_varbin() { diff --git a/vortex-array/src/builders/dict/primitive.rs b/vortex-array/src/builders/dict/primitive.rs index 7c0e68a456a..8d7defd6a50 100644 --- a/vortex-array/src/builders/dict/primitive.rs +++ b/vortex-array/src/builders/dict/primitive.rs @@ -168,10 +168,8 @@ mod test { use crate::assert_arrays_eq; use crate::builders::dict::dict_encode; use crate::builders::dict::primitive::PrimitiveArray; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn encode_primitive() { diff --git a/vortex-array/src/canonical.rs b/vortex-array/src/canonical.rs index 3c07650b2ef..7a2ac8a2a9f 100644 --- a/vortex-array/src/canonical.rs +++ b/vortex-array/src/canonical.rs @@ -1155,11 +1155,9 @@ mod test { use crate::canonical::StructArray; use crate::dtype::Nullability; use crate::scalar::Scalar; - use crate::session::ArraySession; /// A shared session for these canonical tests, used to create execution contexts. - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); fn variant_core_storage(len: usize) -> ArrayRef { ConstantArray::new( diff --git a/vortex-array/src/dtype/mod.rs b/vortex-array/src/dtype/mod.rs index a3a4765c68c..f0152c61301 100644 --- a/vortex-array/src/dtype/mod.rs +++ b/vortex-array/src/dtype/mod.rs @@ -188,8 +188,5 @@ mod test { use vortex_session::VortexSession; - use crate::dtype::session::DTypeSession; - - pub(crate) static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + pub(crate) static SESSION: LazyLock = LazyLock::new(crate::array_session); } diff --git a/vortex-array/src/dtype/serde/proto.rs b/vortex-array/src/dtype/serde/proto.rs index 35e944e0d66..78d4c62f412 100644 --- a/vortex-array/src/dtype/serde/proto.rs +++ b/vortex-array/src/dtype/serde/proto.rs @@ -229,8 +229,6 @@ impl TryFrom<&pb::FieldPath> for FieldPath { mod tests { use std::sync::Arc; - use vortex_session::VortexSession; - use super::*; use crate::dtype::DType; use crate::dtype::DecimalDType; @@ -503,7 +501,7 @@ mod tests { #[test] fn test_unknown_extension_allow_unknown() { - let session = VortexSession::empty().allow_unknown(); + let session = crate::array_session().allow_unknown(); let proto = pb::DType { dtype_type: Some(DtypeType::Extension(Box::new(pb::Extension { id: "vortex.test.foreign_ext".to_string(), diff --git a/vortex-array/src/dtype/session.rs b/vortex-array/src/dtype/session.rs index 757ffbd0ae5..e7aac12d4af 100644 --- a/vortex-array/src/dtype/session.rs +++ b/vortex-array/src/dtype/session.rs @@ -6,7 +6,6 @@ use std::any::Any; use std::sync::Arc; -use vortex_session::Ref; use vortex_session::SessionExt; use vortex_session::SessionVar; use vortex_session::registry::Registry; @@ -22,7 +21,7 @@ use crate::extension::uuid::Uuid; pub type ExtDTypeRegistry = Registry; /// Session for managing extension dtypes. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct DTypeSession { registry: ExtDTypeRegistry, } @@ -69,11 +68,11 @@ impl DTypeSession { /// Extension trait for accessing the DType session. pub trait DTypeSessionExt: SessionExt { /// Get the DType session. - fn dtypes(&self) -> Ref<'_, DTypeSession>; + fn dtypes(&self) -> &DTypeSession; } impl DTypeSessionExt for S { - fn dtypes(&self) -> Ref<'_, DTypeSession> { + fn dtypes(&self) -> &DTypeSession { self.get::() } } diff --git a/vortex-array/src/executor.rs b/vortex-array/src/executor.rs index d6070ac1a4d..2bd5dfd5b37 100644 --- a/vortex-array/src/executor.rs +++ b/vortex-array/src/executor.rs @@ -26,8 +26,6 @@ use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_ensure; use vortex_error::vortex_panic; -use vortex_session::Ref; -use vortex_session::SessionExt; use vortex_session::VortexSession; use crate::AnyCanonical; @@ -430,7 +428,7 @@ impl Executable for ArrayRef { for (slot_idx, slot) in array.slots().iter().enumerate() { let Some(child) = slot else { continue }; if let Some(executed_parent) = - execute_parent_for_child(&array, child, slot_idx, kernels.as_ref(), ctx)? + execute_parent_for_child(&array, child, slot_idx, kernels, ctx)? { ctx.log(format_args!( "execute_parent: slot[{}]({}) rewrote {} -> {}", @@ -542,7 +540,7 @@ fn execute_parent_for_child( parent: &ArrayRef, child: &ArrayRef, slot_idx: usize, - kernels: Option<&Ref>, + kernels: Option<&ArrayKernels>, ctx: &mut ExecutionCtx, ) -> VortexResult> { if let Some(kernels) = kernels @@ -567,7 +565,7 @@ fn try_execute_parent(array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult< for (slot_idx, slot) in array.slots().iter().enumerate() { let Some(child) = slot else { continue }; if let Some(executed_parent) = - execute_parent_for_child(array, child, slot_idx, kernels.as_ref(), ctx)? + execute_parent_for_child(array, child, slot_idx, kernels, ctx)? { ctx.log(format_args!( "execute_parent: slot[{}]({}) rewrote {} -> {}", diff --git a/vortex-array/src/lib.rs b/vortex-array/src/lib.rs index 1f3189eecbb..bb0337856eb 100644 --- a/vortex-array/src/lib.rs +++ b/vortex-array/src/lib.rs @@ -27,7 +27,14 @@ pub use vortex_array_macros::array_slots; use vortex_session::VortexSession; use vortex_session::registry::Context; +use crate::aggregate_fn::session::AggregateFnSession; +use crate::arrow::ArrowSession; +use crate::dtype::session::DTypeSession; +use crate::memory::MemorySession; +use crate::optimizer::kernels::ArrayKernels; +use crate::scalar_fn::session::ScalarFnSession; use crate::session::ArraySession; +use crate::stats::session::StatsSession; pub mod accessor; pub mod aggregate_fn; @@ -78,10 +85,28 @@ pub mod flatbuffers { pub use vortex_flatbuffers::array::*; } +/// Builds a fresh [`VortexSession`] registered with all of vortex-array's built-in session +/// variables: arrays, dtypes, scalar functions, stats, optimizer kernels, aggregate functions, +/// Arrow conversion, and memory. +/// +/// Each call returns an independent session (with its own registries), so callers may register +/// additional encodings or kernels into it without affecting any other session. This does not +/// register file, layout, or runtime state — those live in higher-level crates. +pub fn array_session() -> VortexSession { + VortexSession::empty() + .with::() + .with::() + .with::() + .with::() + .with::() + .with::() + .with::() + .with::() +} + // TODO(ngates): canonicalize doesn't currently take a session, therefore we cannot invoke execute // from the new array encodings to support back-compat for legacy encodings. So we hold a session // here... -pub static LEGACY_SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +pub static LEGACY_SESSION: LazyLock = LazyLock::new(array_session); pub type ArrayContext = Context; diff --git a/vortex-array/src/memory.rs b/vortex-array/src/memory.rs index d3669e49f93..78713dfbde7 100644 --- a/vortex-array/src/memory.rs +++ b/vortex-array/src/memory.rs @@ -16,10 +16,9 @@ use vortex_buffer::ByteBufferMut; use vortex_error::VortexResult; use vortex_error::vortex_ensure; use vortex_error::vortex_err; -use vortex_session::Ref; -use vortex_session::RefMut; use vortex_session::SessionExt; use vortex_session::SessionVar; +use vortex_session::VortexSession; /// Mutable host buffer contract used by [`WritableHostBuffer`]. pub trait HostBufferMut: Send + 'static { @@ -173,7 +172,7 @@ pub trait HostAllocatorExt: HostAllocator { impl HostAllocatorExt for A {} /// Session-scoped memory configuration for Vortex arrays. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct MemorySession { allocator: HostAllocatorRef, } @@ -214,7 +213,7 @@ impl SessionVar for MemorySession { /// Extension trait for accessing session-scoped memory configuration. pub trait MemorySessionExt: SessionExt { /// Returns the memory session for this execution/session context. - fn memory(&self) -> Ref<'_, MemorySession> { + fn memory(&self) -> &MemorySession { self.get::() } @@ -223,9 +222,11 @@ pub trait MemorySessionExt: SessionExt { self.memory().allocator() } - /// Returns mutable access to the memory session. - fn memory_mut(&self) -> RefMut<'_, MemorySession> { - self.get_mut::() + /// Returns a new session configured to use `allocator` as its host allocator. + fn with_allocator(self, allocator: HostAllocatorRef) -> VortexSession { + let mut builder = self.session().to_builder(); + builder.get_mut::().set_allocator(allocator); + builder.build() } } diff --git a/vortex-array/src/optimizer/kernels.rs b/vortex-array/src/optimizer/kernels.rs index 93407a2c42d..b94393a49b3 100644 --- a/vortex-array/src/optimizer/kernels.rs +++ b/vortex-array/src/optimizer/kernels.rs @@ -30,7 +30,6 @@ use std::sync::Arc; use std::sync::LazyLock; use vortex_error::VortexResult; -use vortex_session::Ref; use vortex_session::SessionExt; use vortex_session::SessionVar; use vortex_session::registry::Id; @@ -111,7 +110,7 @@ impl Borrow for ExecuteParentFnId { /// /// Each kernel kind has its own storage map, keyed by `(outer_id, child_id)`. Registering /// functions for an existing key appends them to that key's ordered list. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct ArrayKernels { reduce_parent: ArcSwapMap>, execute_parent: ArcSwapMap>, @@ -213,9 +212,8 @@ impl SessionVar for ArrayKernels { /// Extension trait for accessing optimizer kernels from a /// [`VortexSession`](vortex_session::VortexSession). pub trait ArrayKernelsExt: SessionExt { - /// Returns the [`ArrayKernels`] session variable, inserting a default-constructed one if - /// none has been registered on the session yet. - fn kernels(&self) -> Ref<'_, ArrayKernels> { + /// Returns the [`ArrayKernels`] session variable. + fn kernels(&self) -> &ArrayKernels { self.get::() } } diff --git a/vortex-array/src/optimizer/mod.rs b/vortex-array/src/optimizer/mod.rs index d6e93ca0561..ca3ab1218ce 100644 --- a/vortex-array/src/optimizer/mod.rs +++ b/vortex-array/src/optimizer/mod.rs @@ -18,7 +18,6 @@ use smallvec::SmallVec; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_session::SessionExt; use vortex_session::VortexSession; use crate::ArrayRef; diff --git a/vortex-array/src/scalar/tests/mod.rs b/vortex-array/src/scalar/tests/mod.rs index a82b1908921..676363c853c 100644 --- a/vortex-array/src/scalar/tests/mod.rs +++ b/vortex-array/src/scalar/tests/mod.rs @@ -14,7 +14,4 @@ use std::sync::LazyLock; use vortex_session::VortexSession; -use crate::dtype::session::DTypeSession; - -pub(crate) static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +pub(crate) static SESSION: LazyLock = LazyLock::new(crate::array_session); diff --git a/vortex-array/src/scalar_fn/fns/between/mod.rs b/vortex-array/src/scalar_fn/fns/between/mod.rs index 0e0d9949195..013438e23b2 100644 --- a/vortex-array/src/scalar_fn/fns/between/mod.rs +++ b/vortex-array/src/scalar_fn/fns/between/mod.rs @@ -357,12 +357,10 @@ mod tests { use crate::expr::root; use crate::scalar::DecimalValue; use crate::scalar::Scalar; - use crate::session::ArraySession; use crate::test_harness::to_int_indices; use crate::validity::Validity; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn test_display() { diff --git a/vortex-array/src/scalar_fn/fns/case_when.rs b/vortex-array/src/scalar_fn/fns/case_when.rs index c178e536b38..0a5f6b4ee14 100644 --- a/vortex-array/src/scalar_fn/fns/case_when.rs +++ b/vortex-array/src/scalar_fn/fns/case_when.rs @@ -473,10 +473,8 @@ mod tests { use crate::expr::root; use crate::expr::test_harness; use crate::scalar::Scalar; - use crate::session::ArraySession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); /// Helper to evaluate an expression using the apply+execute pattern fn evaluate_expr(expr: &Expression, array: &ArrayRef) -> ArrayRef { diff --git a/vortex-array/src/scalar_fn/session.rs b/vortex-array/src/scalar_fn/session.rs index 08a5951567b..106f214545c 100644 --- a/vortex-array/src/scalar_fn/session.rs +++ b/vortex-array/src/scalar_fn/session.rs @@ -4,7 +4,6 @@ use std::any::Any; use std::sync::Arc; -use vortex_session::Ref; use vortex_session::SessionExt; use vortex_session::SessionVar; use vortex_session::registry::Registry; @@ -33,7 +32,7 @@ use crate::scalar_fn::fns::variant_get::VariantGet; pub type ScalarFnRegistry = Registry; /// Session state for scalar function vtables and rewrite rules. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct ScalarFnSession { registry: ScalarFnRegistry, } @@ -92,7 +91,7 @@ impl SessionVar for ScalarFnSession { /// Extension trait for accessing scalar function session data. pub trait ScalarFnSessionExt: SessionExt { /// Returns the scalar function vtable registry. - fn scalar_fns(&self) -> Ref<'_, ScalarFnSession> { + fn scalar_fns(&self) -> &ScalarFnSession { self.get::() } } diff --git a/vortex-array/src/session/mod.rs b/vortex-array/src/session/mod.rs index 98a7417722b..b63fa64682e 100644 --- a/vortex-array/src/session/mod.rs +++ b/vortex-array/src/session/mod.rs @@ -6,7 +6,6 @@ use std::sync::Arc; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_session::Ref; use vortex_session::SessionExt; use vortex_session::SessionVar; use vortex_session::registry::Registry; @@ -33,7 +32,7 @@ use crate::arrays::Variant; pub type ArrayRegistry = Registry; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct ArraySession { /// The set of registered array encodings. registry: ArrayRegistry, @@ -100,7 +99,7 @@ impl SessionVar for ArraySession { /// Session data for Vortex arrays. pub trait ArraySessionExt: SessionExt { /// Returns the array encoding registry. - fn arrays(&self) -> Ref<'_, ArraySession> { + fn arrays(&self) -> &ArraySession { self.get::() } diff --git a/vortex-array/src/stats/expr.rs b/vortex-array/src/stats/expr.rs index 32fd48804de..58f0c93c508 100644 --- a/vortex-array/src/stats/expr.rs +++ b/vortex-array/src/stats/expr.rs @@ -100,11 +100,9 @@ mod tests { use crate::expr::stats::Stat; use crate::scalar::Scalar; use crate::scalar::ScalarValue; - use crate::session::ArraySession; use crate::validity::Validity; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); #[test] fn stat_expr_reads_cached_sum() -> VortexResult<()> { diff --git a/vortex-array/src/stats/rewrite.rs b/vortex-array/src/stats/rewrite.rs index 52d354df1a0..7d723155fad 100644 --- a/vortex-array/src/stats/rewrite.rs +++ b/vortex-array/src/stats/rewrite.rs @@ -156,7 +156,6 @@ fn rewrite( #[cfg(test)] mod tests { use vortex_error::VortexResult; - use vortex_session::VortexSession; use super::StatsRewriteCtx; use super::StatsRewriteRule; @@ -169,7 +168,6 @@ mod tests { use crate::scalar_fn::ScalarFnId; use crate::scalar_fn::ScalarFnVTable; use crate::scalar_fn::fns::literal::Literal; - use crate::stats::session::StatsSession; use crate::stats::session::StatsSessionExt; #[derive(Debug)] @@ -202,7 +200,7 @@ mod tests { #[test] fn combines_multiple_falsifiers_with_or() -> VortexResult<()> { - let session = VortexSession::empty().with::(); + let session = crate::array_session(); let dtype = DType::Primitive(PType::I32, Nullability::NonNullable); session.stats().register_rewrite(StaticLiteralRule { falsifier: Some(lit(false)), @@ -222,7 +220,7 @@ mod tests { #[test] fn combines_multiple_satisfiers_with_or() -> VortexResult<()> { - let session = VortexSession::empty().with::(); + let session = crate::array_session(); let dtype = DType::Primitive(PType::I32, Nullability::NonNullable); session.stats().register_rewrite(StaticLiteralRule { falsifier: None, @@ -242,7 +240,7 @@ mod tests { #[test] fn unregistered_expression_has_no_rewrite() -> VortexResult<()> { - let session = VortexSession::empty().with::(); + let session = crate::array_session(); let dtype = DType::Primitive(PType::I32, Nullability::NonNullable); assert_eq!(lit(true).falsify(&dtype, &session)?, None); @@ -252,7 +250,7 @@ mod tests { #[test] fn non_predicate_expression_errors() { - let session = VortexSession::empty().with::(); + let session = crate::array_session(); let dtype = DType::Primitive(PType::I32, Nullability::NonNullable); assert!(lit(7).falsify(&dtype, &session).is_err()); diff --git a/vortex-array/src/stats/rewrite/builtins.rs b/vortex-array/src/stats/rewrite/builtins.rs index 2b7316c7d98..4311b7295f3 100644 --- a/vortex-array/src/stats/rewrite/builtins.rs +++ b/vortex-array/src/stats/rewrite/builtins.rs @@ -616,10 +616,8 @@ mod tests { use crate::scalar_fn::fns::dynamic::DynamicComparisonExpr; use crate::scalar_fn::fns::operators::CompareOperator; use crate::scalar_fn::internal::row_count::RowCount; - use crate::stats::session::StatsSession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(crate::array_session); fn stat(expr: Expression, stat: Stat) -> Expression { let aggregate_fn = stat.aggregate_fn().expect("stat should have aggregate fn"); diff --git a/vortex-array/src/stats/session.rs b/vortex-array/src/stats/session.rs index 2d4325b2cd7..867ec4f8fb0 100644 --- a/vortex-array/src/stats/session.rs +++ b/vortex-array/src/stats/session.rs @@ -7,7 +7,6 @@ use std::any::Any; use std::sync::Arc; use parking_lot::RwLock; -use vortex_session::Ref; use vortex_session::SessionExt; use vortex_session::SessionVar; use vortex_utils::aliases::hash_map::HashMap; @@ -20,15 +19,15 @@ use crate::stats::rewrite::register_builtins; type StatsRewriteRuleSet = Arc<[StatsRewriteRuleRef]>; /// Session state for stats APIs. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct StatsSession { - rewrite_rules: RwLock>, + rewrite_rules: Arc>>, } impl Default for StatsSession { fn default() -> Self { let this = Self { - rewrite_rules: RwLock::new(HashMap::default()), + rewrite_rules: Arc::new(RwLock::new(HashMap::default())), }; register_builtins(&this); this @@ -77,7 +76,7 @@ impl SessionVar for StatsSession { /// Extension trait for accessing stats session data. pub(crate) trait StatsSessionExt: SessionExt { /// Returns the stats session state. - fn stats(&self) -> Ref<'_, StatsSession> { + fn stats(&self) -> &StatsSession { self.get::() } } diff --git a/vortex-btrblocks/benches/compress.rs b/vortex-btrblocks/benches/compress.rs index 8bc47d16404..6898b4a9ab4 100644 --- a/vortex-btrblocks/benches/compress.rs +++ b/vortex-btrblocks/benches/compress.rs @@ -17,14 +17,12 @@ mod benchmarks { use vortex_array::IntoArray; use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; - use vortex_array::session::ArraySession; use vortex_btrblocks::BtrBlocksCompressor; use vortex_buffer::buffer_mut; use vortex_session::VortexSession; use vortex_utils::aliases::hash_set::HashSet; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn make_clickbench_window_name() -> ArrayRef { // A test that's meant to mirror the WindowName column from ClickBench. diff --git a/vortex-btrblocks/benches/compress_listview.rs b/vortex-btrblocks/benches/compress_listview.rs index e1b0595ac27..502acf79e0f 100644 --- a/vortex-btrblocks/benches/compress_listview.rs +++ b/vortex-btrblocks/benches/compress_listview.rs @@ -21,7 +21,6 @@ mod benchmarks { use vortex_array::arrays::StructArray; use vortex_array::arrays::VarBinViewArray; use vortex_array::dtype::FieldNames; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_btrblocks::BtrBlocksCompressor; use vortex_buffer::buffer_mut; @@ -30,8 +29,7 @@ mod benchmarks { const NUM_ROWS: usize = 8192; const SEED: u64 = 42; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); const SHORT_STRINGS: &[&str] = &[ "alpha_one", diff --git a/vortex-btrblocks/src/canonical_compressor.rs b/vortex-btrblocks/src/canonical_compressor.rs index 37e736fb550..ca77bc24ca8 100644 --- a/vortex-btrblocks/src/canonical_compressor.rs +++ b/vortex-btrblocks/src/canonical_compressor.rs @@ -75,7 +75,6 @@ mod tests { use vortex_array::assert_arrays_eq; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::BitBuffer; use vortex_buffer::buffer; @@ -86,8 +85,7 @@ mod tests { #[cfg(feature = "zstd")] use crate::BtrBlocksCompressorBuilder; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[rstest] #[case::zctl( diff --git a/vortex-btrblocks/src/schemes/float/scheme_selection_tests.rs b/vortex-btrblocks/src/schemes/float/scheme_selection_tests.rs index 9ddddef6df1..4c7a5f85fa6 100644 --- a/vortex-btrblocks/src/schemes/float/scheme_selection_tests.rs +++ b/vortex-btrblocks/src/schemes/float/scheme_selection_tests.rs @@ -14,7 +14,6 @@ use vortex_array::arrays::PrimitiveArray; use vortex_array::builders::ArrayBuilder; use vortex_array::builders::PrimitiveBuilder; use vortex_array::dtype::Nullability; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_error::VortexResult; @@ -22,8 +21,7 @@ use vortex_session::VortexSession; use crate::BtrBlocksCompressor; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_constant_compressed() -> VortexResult<()> { diff --git a/vortex-btrblocks/src/schemes/float/tests.rs b/vortex-btrblocks/src/schemes/float/tests.rs index 31fd88d99d8..da84831fcc0 100644 --- a/vortex-btrblocks/src/schemes/float/tests.rs +++ b/vortex-btrblocks/src/schemes/float/tests.rs @@ -12,7 +12,6 @@ use vortex_array::builders::ArrayBuilder; use vortex_array::builders::PrimitiveBuilder; use vortex_array::display::DisplayOptions; use vortex_array::dtype::Nullability; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_buffer::buffer_mut; @@ -24,8 +23,7 @@ use vortex_session::VortexSession; use crate::BtrBlocksCompressor; use crate::schemes::float::FloatRLEScheme; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_empty() -> VortexResult<()> { diff --git a/vortex-btrblocks/src/schemes/integer/scheme_selection_tests.rs b/vortex-btrblocks/src/schemes/integer/scheme_selection_tests.rs index 993827d2057..94d2c0760e0 100644 --- a/vortex-btrblocks/src/schemes/integer/scheme_selection_tests.rs +++ b/vortex-btrblocks/src/schemes/integer/scheme_selection_tests.rs @@ -17,7 +17,6 @@ use vortex_array::arrays::PrimitiveArray; use vortex_array::expr::stats::Precision; use vortex_array::expr::stats::Stat; use vortex_array::expr::stats::StatsProviderExt; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_error::VortexResult; @@ -30,8 +29,7 @@ use vortex_sparse::Sparse; use crate::BtrBlocksCompressor; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_constant_compressed() -> VortexResult<()> { diff --git a/vortex-btrblocks/src/schemes/integer/tests.rs b/vortex-btrblocks/src/schemes/integer/tests.rs index 2f559af8582..5a3a0f33a40 100644 --- a/vortex-btrblocks/src/schemes/integer/tests.rs +++ b/vortex-btrblocks/src/schemes/integer/tests.rs @@ -15,7 +15,6 @@ use vortex_array::arrays::Dict; use vortex_array::arrays::Masked; use vortex_array::arrays::PrimitiveArray; use vortex_array::assert_arrays_eq; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_buffer::BufferMut; @@ -29,8 +28,7 @@ use vortex_session::VortexSession; use crate::BtrBlocksCompressor; use crate::schemes::integer::IntRLEScheme; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_empty() -> VortexResult<()> { diff --git a/vortex-btrblocks/src/schemes/string/scheme_selection_tests.rs b/vortex-btrblocks/src/schemes/string/scheme_selection_tests.rs index a32ac353a7f..c1473146607 100644 --- a/vortex-btrblocks/src/schemes/string/scheme_selection_tests.rs +++ b/vortex-btrblocks/src/schemes/string/scheme_selection_tests.rs @@ -12,15 +12,13 @@ use vortex_array::arrays::Dict; use vortex_array::arrays::VarBinViewArray; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; -use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_fsst::FSST; use vortex_session::VortexSession; use crate::BtrBlocksCompressor; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_constant_compressed() -> VortexResult<()> { diff --git a/vortex-btrblocks/src/schemes/string/tests.rs b/vortex-btrblocks/src/schemes/string/tests.rs index 05b256eda6d..ec9c4060f64 100644 --- a/vortex-btrblocks/src/schemes/string/tests.rs +++ b/vortex-btrblocks/src/schemes/string/tests.rs @@ -11,14 +11,12 @@ use vortex_array::builders::VarBinViewBuilder; use vortex_array::display::DisplayOptions; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; -use vortex_array::session::ArraySession; use vortex_error::VortexResult; use vortex_session::VortexSession; use crate::BtrBlocksCompressor; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); #[test] fn test_strings() -> VortexResult<()> { diff --git a/vortex-btrblocks/tests/onpair_roundtrip.rs b/vortex-btrblocks/tests/onpair_roundtrip.rs index 3843e02c319..ab220857788 100644 --- a/vortex-btrblocks/tests/onpair_roundtrip.rs +++ b/vortex-btrblocks/tests/onpair_roundtrip.rs @@ -25,8 +25,7 @@ use vortex_array::session::ArraySession; use vortex_btrblocks::BtrBlocksCompressor; use vortex_session::VortexSession; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(|| vortex_array::array_session()); /// Helper: synthetic short-string corpus that the cascading compressor should /// route through OnPair. diff --git a/vortex-compressor/benches/dict_encode.rs b/vortex-compressor/benches/dict_encode.rs index 68b7cd98013..5b2b0650ffd 100644 --- a/vortex-compressor/benches/dict_encode.rs +++ b/vortex-compressor/benches/dict_encode.rs @@ -11,15 +11,13 @@ use vortex_array::VortexSessionExecute; use vortex_array::arrays::BoolArray; use vortex_array::arrays::PrimitiveArray; use vortex_array::builders::dict::dict_encode; -use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::BufferMut; use vortex_compressor::builtins::integer_dictionary_encode; use vortex_compressor::stats::IntegerStats; use vortex_session::VortexSession; -static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); +static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn make_array() -> PrimitiveArray { let values: BufferMut = (0..50).cycle().take(64_000).collect(); diff --git a/vortex-compressor/benches/stats_calc.rs b/vortex-compressor/benches/stats_calc.rs index 69a8f970608..abbc34817f1 100644 --- a/vortex-compressor/benches/stats_calc.rs +++ b/vortex-compressor/benches/stats_calc.rs @@ -9,7 +9,6 @@ mod benchmarks { use divan::Bencher; use vortex_array::VortexSessionExecute; use vortex_array::arrays::PrimitiveArray; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::Buffer; use vortex_buffer::BufferMut; @@ -17,8 +16,7 @@ mod benchmarks { use vortex_compressor::stats::IntegerStats; use vortex_session::VortexSession; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn generate_dataset(max_run: u32, distinct: u32) -> Buffer { let mut output = BufferMut::with_capacity(64_000); diff --git a/vortex-compressor/src/builtins/dict/float.rs b/vortex-compressor/src/builtins/dict/float.rs index bf591963db3..2ab34d52e0c 100644 --- a/vortex-compressor/src/builtins/dict/float.rs +++ b/vortex-compressor/src/builtins/dict/float.rs @@ -253,11 +253,9 @@ mod tests { use vortex_array::arrays::PrimitiveArray; use vortex_array::arrays::dict::DictArraySlotsExt; use vortex_array::assert_arrays_eq; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_error::VortexResult; - use vortex_session::VortexSession; use super::dictionary_encode; use crate::stats::FloatStats; @@ -265,9 +263,7 @@ mod tests { #[test] fn test_float_dict_encode() -> VortexResult<()> { - let mut ctx = VortexSession::empty() - .with::() - .create_execution_ctx(); + let mut ctx = vortex_array::array_session().create_execution_ctx(); let values = buffer![1f32, 2f32, 2f32, 0f32, 1f32]; let validity = Validity::Array(BoolArray::from_iter([true, true, true, false, true]).into_array()); diff --git a/vortex-compressor/src/builtins/dict/integer.rs b/vortex-compressor/src/builtins/dict/integer.rs index 82af7f14de7..1bb9ede306c 100644 --- a/vortex-compressor/src/builtins/dict/integer.rs +++ b/vortex-compressor/src/builtins/dict/integer.rs @@ -260,20 +260,16 @@ mod tests { use vortex_array::arrays::PrimitiveArray; use vortex_array::arrays::dict::DictArraySlotsExt; use vortex_array::assert_arrays_eq; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_error::VortexResult; - use vortex_session::VortexSession; use super::dictionary_encode; use crate::stats::IntegerStats; #[test] fn test_dict_encode_integer_stats() -> VortexResult<()> { - let mut ctx = VortexSession::empty() - .with::() - .create_execution_ctx(); + let mut ctx = vortex_array::array_session().create_execution_ctx(); let data = buffer![100i32, 200, 100, 0, 100]; let validity = Validity::Array(BoolArray::from_iter([true, true, true, false, true]).into_array()); diff --git a/vortex-compressor/src/compressor.rs b/vortex-compressor/src/compressor.rs index 33502104b13..77099df91f8 100644 --- a/vortex-compressor/src/compressor.rs +++ b/vortex-compressor/src/compressor.rs @@ -596,7 +596,6 @@ mod tests { use vortex_array::arrays::Constant; use vortex_array::arrays::NullArray; use vortex_array::arrays::PrimitiveArray; - use vortex_array::session::ArraySession; use vortex_array::validity::Validity; use vortex_buffer::buffer; use vortex_session::VortexSession; @@ -613,8 +612,7 @@ mod tests { use crate::estimate::WinnerEstimate; use crate::scheme::SchemeExt; - static SESSION: LazyLock = - LazyLock::new(|| VortexSession::empty().with::()); + static SESSION: LazyLock = LazyLock::new(vortex_array::array_session); fn compressor() -> CascadingCompressor { CascadingCompressor::new(vec![&IntDictScheme, &FloatDictScheme, &StringDictScheme]) diff --git a/vortex-cuda/benches/dynamic_dispatch_cuda.rs b/vortex-cuda/benches/dynamic_dispatch_cuda.rs index cf89c95efff..f79b701f572 100644 --- a/vortex-cuda/benches/dynamic_dispatch_cuda.rs +++ b/vortex-cuda/benches/dynamic_dispatch_cuda.rs @@ -713,7 +713,7 @@ fn bench_dict_bp_codes_alp_for_bp_values_composed_standalone(c: &mut Criterion) exponents, codes_bp, *len, - &cuda_session, + cuda_session, &mut cuda_ctx, ); diff --git a/vortex-cuda/ffi/src/lib.rs b/vortex-cuda/ffi/src/lib.rs index 2a74cb2666c..f3f97210d5b 100644 --- a/vortex-cuda/ffi/src/lib.rs +++ b/vortex-cuda/ffi/src/lib.rs @@ -14,7 +14,6 @@ use std::ptr; use arrow_schema::ffi::FFI_ArrowSchema; use vortex::error::VortexResult; use vortex::error::vortex_ensure; -use vortex::session::SessionExt; use vortex::session::VortexSession; use vortex_cuda::CudaSession; use vortex_cuda::arrow::ArrowDeviceArray; diff --git a/vortex-cuda/src/executor.rs b/vortex-cuda/src/executor.rs index 069941c266c..e2fa1e6dc6f 100644 --- a/vortex-cuda/src/executor.rs +++ b/vortex-cuda/src/executor.rs @@ -96,7 +96,7 @@ pub struct CudaExecutionCtx { impl CudaExecutionCtx { /// Creates a new CUDA execution context. pub(crate) fn new(stream: VortexCudaStream, ctx: ExecutionCtx) -> Self { - let cuda_session = ctx.session().cuda_session().clone(); + let cuda_session = (*ctx.session().cuda_session()).clone(); Self { stream, ctx, diff --git a/vortex-cuda/src/session.rs b/vortex-cuda/src/session.rs index f3f7a2e3a49..914bc585d23 100644 --- a/vortex-cuda/src/session.rs +++ b/vortex-cuda/src/session.rs @@ -12,7 +12,6 @@ use vortex::array::ArrayId; use vortex::array::VortexSessionExecute; use vortex::error::VortexResult; use vortex::error::vortex_err; -use vortex::session::Ref; use vortex::session::SessionExt; use vortex::session::SessionVar; use vortex::utils::aliases::dash_map::DashMap; @@ -183,7 +182,7 @@ impl SessionVar for CudaSession { /// Extension trait for accessing the CUDA session from a Vortex session. pub trait CudaSessionExt: SessionExt { /// Returns the CUDA session. - fn cuda_session(&self) -> Ref<'_, CudaSession> { + fn cuda_session(&self) -> &CudaSession { self.get::() } } diff --git a/vortex-datafusion/src/persistent/opener.rs b/vortex-datafusion/src/persistent/opener.rs index d50b003f1dc..2923b6c313c 100644 --- a/vortex-datafusion/src/persistent/opener.rs +++ b/vortex-datafusion/src/persistent/opener.rs @@ -237,7 +237,7 @@ impl FileOpener for VortexOpener { let this_file_schema = Arc::new(calculate_physical_schema( vxf.dtype(), &unified_file_schema, - &session.arrow(), + session.arrow(), )?); let projected_physical_schema = projection.project_schema(&unified_file_schema)?; @@ -296,7 +296,7 @@ impl FileOpener for VortexOpener { Schema::new(fields) }; let stream_schema = - calculate_physical_schema(&scan_dtype, &scan_reference_schema, &session.arrow())?; + calculate_physical_schema(&scan_dtype, &scan_reference_schema, session.arrow())?; let leftover_projection = leftover_projection .try_map_exprs(|expr| reassign_expr_columns(expr, &stream_schema))?; diff --git a/vortex-file/src/multi/mod.rs b/vortex-file/src/multi/mod.rs index 2baf53ff845..215331f0540 100644 --- a/vortex-file/src/multi/mod.rs +++ b/vortex-file/src/multi/mod.rs @@ -11,6 +11,7 @@ use async_trait::async_trait; use futures::StreamExt; use futures::TryStreamExt; use futures::stream; +pub use session::MultiFileSession; use session::MultiFileSessionExt; use tracing::debug; use vortex_error::VortexError; diff --git a/vortex-file/src/multi/session.rs b/vortex-file/src/multi/session.rs index 7023d3cd020..b6bd5477ec8 100644 --- a/vortex-file/src/multi/session.rs +++ b/vortex-file/src/multi/session.rs @@ -22,7 +22,8 @@ use crate::footer::Footer; /// /// Consider generalizing this cache into [`VortexOpenOptions`](crate::VortexOpenOptions) so /// that single-file opens also benefit from session-level footer caching. -pub(super) struct MultiFileSession { +#[derive(Clone)] +pub struct MultiFileSession { footer_cache: moka::sync::Cache, } @@ -53,12 +54,12 @@ impl Debug for MultiFileSession { impl MultiFileSession { /// Retrieve a cached footer for the given file path. - pub fn get_footer(&self, path: &str) -> Option