Skip to content

Commit 91f1ca8

Browse files
authored
VortexSession register is public and allow_unknown takes reference (#8647)
While integrating vortex into another project I realised that these are more sensible apis
1 parent 4959939 commit 91f1ca8

7 files changed

Lines changed: 17 additions & 17 deletions

File tree

vortex-array/src/aggregate_fn/proto.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ mod tests {
195195

196196
#[test]
197197
fn unknown_aggregate_fn_id_allow_unknown() {
198-
let session = VortexSession::empty()
199-
.with::<AggregateFnSession>()
200-
.allow_unknown();
198+
let session = VortexSession::empty().with::<AggregateFnSession>();
199+
session.allow_unknown();
201200

202201
let proto = pb::AggregateFn {
203202
id: "vortex.test.foreign_aggregate".to_string(),

vortex-array/src/dtype/serde/proto.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ mod tests {
231231
use std::sync::Arc;
232232

233233
use super::*;
234+
use crate::array_session;
234235
use crate::dtype::DType;
235236
use crate::dtype::DecimalDType;
236237
use crate::dtype::Field;
@@ -502,7 +503,8 @@ mod tests {
502503

503504
#[test]
504505
fn test_unknown_extension_allow_unknown() {
505-
let session = crate::array_session().allow_unknown();
506+
let session = array_session();
507+
session.allow_unknown();
506508
let proto = pb::DType {
507509
dtype_type: Some(DtypeType::Extension(Box::new(pb::Extension {
508510
id: "vortex.test.foreign_ext".to_string(),

vortex-array/src/expr/proto.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ mod tests {
116116

117117
#[test]
118118
fn unknown_expression_id_allow_unknown() {
119-
let session = VortexSession::empty()
120-
.with::<ScalarFnSession>()
121-
.allow_unknown();
119+
let session = VortexSession::empty().with::<ScalarFnSession>();
120+
session.allow_unknown();
122121

123122
let expr_proto = pb::Expr {
124123
id: "vortex.test.foreign_scalar_fn".to_string(),

vortex-session/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ mod tests {
9696
let session = VortexSession::empty();
9797
assert!(!session.allows_unknown());
9898

99-
let session = session.allow_unknown();
99+
session.allow_unknown();
100100
assert!(session.allows_unknown());
101101
}
102102
}

vortex-session/src/session.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ impl VortexSession {
191191

192192
/// Inserts a session variable of type `V`, replacing any existing variable of that type.
193193
///
194-
/// This is the internal copy-on-write insert primitive behind [`with_some`](Self::with_some) and
194+
/// This is the copy-on-write insert primitive behind [`with_some`](Self::with_some) and
195195
/// [`get_mut`](SessionExt::get_mut); it is not public, so a variable can only enter the type-map
196196
/// through those (or through a default inserted by [`get`](SessionExt::get)). The mutation is
197197
/// applied in place to the shared backing store, so it is visible through every clone.
198-
fn register<V: VortexSessionVar>(&self, var: V) {
198+
pub fn register<V: VortexSessionVar>(&self, var: V) {
199199
let var: Arc<dyn VortexSessionVar> = Arc::new(var);
200200
self.0.rcu(|current| {
201201
let mut next = SessionVars::clone(current);
@@ -246,9 +246,8 @@ impl VortexSession {
246246
/// Allow deserializing unknown plugin IDs as non-executable foreign placeholders.
247247
///
248248
/// Mutates this session in place and returns it for chaining.
249-
pub fn allow_unknown(self) -> Self {
249+
pub fn allow_unknown(&self) {
250250
self.get_mut::<UnknownPluginPolicy>().allow_unknown = true;
251-
self
252251
}
253252
}
254253

@@ -435,7 +434,7 @@ mod tests {
435434
let session = VortexSession::empty();
436435
assert!(!session.allows_unknown());
437436

438-
let session = session.allow_unknown();
437+
session.allow_unknown();
439438
assert!(session.allows_unknown());
440439
}
441440

vortex-tui/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use vortex_tui::launch;
88

99
#[tokio::main]
1010
async fn main() -> anyhow::Result<()> {
11-
let session = VortexSession::default().with_tokio().allow_unknown();
11+
let session = VortexSession::default().with_tokio();
12+
session.allow_unknown();
1213
if let Err(err) = launch(&session).await {
1314
// Defer help/version/usage errors back to clap so their formatting
1415
// and exit codes match the standalone-binary convention exactly.

vortex-web/crate/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use vortex::session::VortexSession;
1717
mod wasm;
1818

1919
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
20-
VortexSession::default()
21-
.with_handle(WasmRuntime::handle())
22-
.allow_unknown()
20+
let session = VortexSession::default().with_handle(WasmRuntime::handle());
21+
session.allow_unknown();
22+
session
2323
});

0 commit comments

Comments
 (0)