We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f8870ae commit 7303f32Copy full SHA for 7303f32
vortex-session/src/lib.rs
@@ -88,6 +88,18 @@ impl SessionExt for VortexSession {
88
89
/// Returns the scope variable of type `V`, or inserts a default one if it does not exist.
90
fn get<V: SessionVar + Default>(&self) -> Ref<'_, V> {
91
+ // NOTE(ngates): we don't use `entry().or_insert_with_key()` here because the DashMap
92
+ // would immediately acquire an exclusive write lock.
93
+ if let Some(v) = self.0.get(&TypeId::of::<V>()) {
94
+ return Ref(v.map(|v| {
95
+ (**v)
96
+ .as_any()
97
+ .downcast_ref::<V>()
98
+ .vortex_expect("Type mismatch - this is a bug")
99
+ }));
100
+ }
101
+
102
+ // If we get here, the value was not present, so we insert the default with a write lock.
103
Ref(self
104
.0
105
.entry(TypeId::of::<V>())
0 commit comments