Skip to content

Commit ab358e6

Browse files
committed
Immutable session + registries
Signed-off-by: Nicholas Gates <[email protected]>
1 parent ccbbd6d commit ab358e6

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

java/testfiles/src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
use std::path::Path;
77

88
use vortex::array::arrays::StructArray;
9-
use vortex::array::builders::{ArrayBuilder, DecimalBuilder, VarBinViewBuilder};
9+
use vortex::array::builders::ArrayBuilder;
10+
use vortex::array::builders::DecimalBuilder;
11+
use vortex::array::builders::VarBinViewBuilder;
1012
use vortex::array::validity::Validity;
11-
use vortex::dtype::{DType, DecimalDType, Nullability};
13+
use vortex::dtype::DType;
14+
use vortex::dtype::DecimalDType;
15+
use vortex::dtype::Nullability;
1216
use vortex::file::WriteOptionsSessionExt;
1317
use vortex::io::runtime::current::CurrentThreadRuntime;
1418
use vortex::io::runtime::BlockingRuntime;
@@ -32,7 +36,9 @@ use vortex::VortexSessionDefault;
3236
/// | John | 10000 | VA |
3337
fn main() {
3438
let runtime = CurrentThreadRuntime::new();
35-
let session = VortexSession::default().with_handle(runtime.handle());
39+
let session = VortexSession::new_with_defaults()
40+
.with_handle(runtime.handle())
41+
.freeze();
3642

3743
let mut names = VarBinViewBuilder::with_capacity(DType::Utf8(Nullability::NonNullable), 10);
3844
names.append_value("Alice");

vortex-session/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ impl VortexSession {
6565
///
6666
/// Note that the returned value internally holds a lock on the variable.
6767
pub fn get_mut<V: SessionVar + Default>(&mut self) -> &mut V {
68-
self.0
68+
let v = self
69+
.0
6970
.entry(TypeId::of::<V>())
70-
.or_insert_with(|| Box::new(V::default()))
71+
.or_insert_with(|| Box::new(V::default()));
72+
(**v)
7173
.as_any_mut()
7274
.downcast_mut::<V>()
7375
.vortex_expect("Type mismatch - this is a bug")

vortex/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl VortexSessionDefault for VortexSession {
157157
VortexSession::empty().with_defaults()
158158
}
159159

160+
#[allow(unused_mut)]
160161
fn with_defaults(self) -> VortexSession {
161162
let mut this = self
162163
.with::<VortexMetrics>()

0 commit comments

Comments
 (0)