Skip to content

Commit 9f494a1

Browse files
authored
Immutable session backed by HashMap (#8454)
## Summary This PR replaces the current `DashMap` backed session with one backed by a `HashMap`. Instead of being initialized on access which might cause deadlocks or otherwise weird performance behavior. There's also an explicit `Builder` type for the session, allowing the user to explicitly include the components they want. --------- Signed-off-by: Adam Gutglick <adam@spiraldb.com>
1 parent 679e2c5 commit 9f494a1

227 files changed

Lines changed: 951 additions & 1111 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/developer-guide/internals/session.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ For tests or specialized use-cases, sessions can be assembled from individual co
9999
the `.with::<T>()` builder:
100100

101101
```rust
102-
let session = VortexSession::empty()
102+
let session = VortexSession::builder()
103103
.with::<ArraySession>()
104104
.with::<LayoutSession>()
105105
.with::<ScalarFnSession>()
106-
.with::<RuntimeSession>();
106+
.with::<RuntimeSession>()
107+
.build();
107108
```

encodings/alp/benches/alp_compress.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use vortex_array::IntoArray;
1919
use vortex_array::VortexSessionExecute;
2020
use vortex_array::arrays::PrimitiveArray;
2121
use vortex_array::dtype::NativePType;
22-
use vortex_array::session::ArraySession;
2322
use vortex_array::validity::Validity;
2423
use vortex_buffer::Buffer;
2524
use vortex_buffer::buffer;
@@ -51,8 +50,7 @@ const BENCH_ARGS: &[(usize, f64, f64)] = &[
5150
(10_000, 0.1, 1.0),
5251
];
5352

54-
static SESSION: LazyLock<VortexSession> =
55-
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
53+
static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_array::array_session);
5654

5755
#[divan::bench(types = [f32, f64], args = BENCH_ARGS)]
5856
fn compress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64, f64)) {

encodings/alp/src/alp/array.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,14 @@ mod tests {
485485
use vortex_array::VortexSessionExecute;
486486
use vortex_array::arrays::PrimitiveArray;
487487
use vortex_array::assert_arrays_eq;
488-
use vortex_array::session::ArraySession;
489488
use vortex_error::VortexExpect;
490489
use vortex_session::VortexSession;
491490

492491
use super::*;
493492
use crate::alp_encode;
494493
use crate::decompress_into_array;
495494

496-
static SESSION: LazyLock<VortexSession> =
497-
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
495+
static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_array::array_session);
498496

499497
#[rstest]
500498
#[case(0)]

encodings/alp/src/alp/plugin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ mod tests {
9898
use vortex_array::arrays::PrimitiveArray;
9999
use vortex_array::arrays::patched::PatchedArraySlotsExt;
100100
use vortex_array::buffer::BufferHandle;
101-
use vortex_array::session::ArraySession;
102101
use vortex_array::session::ArraySessionExt;
103102
use vortex_error::VortexResult;
104103
use vortex_error::vortex_err;
@@ -111,7 +110,7 @@ mod tests {
111110
use crate::alp_encode;
112111

113112
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
114-
let session = VortexSession::empty().with::<ArraySession>();
113+
let session = vortex_array::array_session();
115114
session.arrays().register(ALPPatchedPlugin);
116115
session
117116
});

encodings/bytebool/src/array.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,8 @@ mod tests {
322322
use vortex_array::assert_arrays_eq;
323323
use vortex_array::serde::SerializeOptions;
324324
use vortex_array::serde::SerializedArray;
325-
use vortex_array::session::ArraySession;
326325
use vortex_array::session::ArraySessionExt;
327326
use vortex_buffer::ByteBufferMut;
328-
use vortex_session::VortexSession;
329327
use vortex_session::registry::ReadContext;
330328

331329
use super::*;
@@ -367,7 +365,7 @@ mod tests {
367365
let array = ByteBool::from_option_vec(vec![Some(true), None, Some(false), None]);
368366
let dtype = array.dtype().clone();
369367
let len = array.len();
370-
let session = VortexSession::empty().with::<ArraySession>();
368+
let session = vortex_array::array_session();
371369
session.arrays().register(ByteBool);
372370

373371
let ctx = ArrayContext::empty();

encodings/datetime-parts/src/canonical.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ mod test {
109109
use vortex_array::validity::Validity;
110110
use vortex_buffer::buffer;
111111
use vortex_error::VortexResult;
112-
use vortex_session::VortexSession;
113112

114113
use crate::DateTimeParts;
115114
use crate::array::DateTimePartsArraySlotsExt;
@@ -133,7 +132,7 @@ mod test {
133132
],
134133
validity.clone(),
135134
);
136-
let mut ctx = ExecutionCtx::new(VortexSession::empty());
135+
let mut ctx = ExecutionCtx::new(vortex_array::array_session());
137136
let date_times = DateTimeParts::try_from_temporal(
138137
TemporalArray::new_timestamp(
139138
milliseconds.clone().into_array(),

encodings/experimental/onpair/benches/decode.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ use vortex_array::builtins::ArrayBuiltins;
4141
use vortex_array::dtype::DType;
4242
use vortex_array::dtype::NativePType;
4343
use vortex_array::dtype::Nullability;
44-
use vortex_array::session::ArraySession;
4544
use vortex_buffer::Buffer;
4645
use vortex_buffer::ByteBuffer;
4746
use vortex_mask::Mask;
@@ -80,8 +79,7 @@ impl DecodeInputs {
8079
use vortex_onpair::onpair_compress;
8180
use vortex_session::VortexSession;
8281

83-
static SESSION: LazyLock<VortexSession> =
84-
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
82+
static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_array::array_session);
8583

8684
#[derive(Copy, Clone, Debug)]
8785
enum Shape {

encodings/experimental/onpair/src/compute/compare.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,13 @@ mod tests {
7878
use vortex_array::dtype::Nullability;
7979
use vortex_array::scalar::Scalar;
8080
use vortex_array::scalar_fn::fns::operators::Operator;
81-
use vortex_array::session::ArraySession;
8281
use vortex_error::VortexResult;
8382
use vortex_session::VortexSession;
8483

8584
use crate::compress::DEFAULT_DICT12_CONFIG;
8685
use crate::compress::onpair_compress;
8786

88-
static SESSION: LazyLock<VortexSession> =
89-
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
87+
static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_array::array_session);
9088

9189
#[cfg_attr(miri, ignore)]
9290
#[rstest]

encodings/experimental/onpair/src/tests.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use vortex_array::dtype::DType;
1515
use vortex_array::dtype::Nullability;
1616
use vortex_array::dtype::PType;
1717
use vortex_array::match_each_integer_ptype;
18-
use vortex_array::session::ArraySession;
1918
use vortex_array::test_harness::check_metadata;
2019
use vortex_array::validity::Validity;
2120
use vortex_buffer::BufferMut;
@@ -28,8 +27,7 @@ use crate::OnPairMetadata;
2827
use crate::compress::DEFAULT_DICT12_CONFIG;
2928
use crate::compress::onpair_compress;
3029

31-
static SESSION: LazyLock<VortexSession> =
32-
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
30+
static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_array::array_session);
3331

3432
fn sample_input() -> VarBinArray {
3533
VarBinArray::from_iter(

0 commit comments

Comments
 (0)