Skip to content

Commit 363a27c

Browse files
committed
missed this
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 78a34a0 commit 363a27c

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
//! Session state for pluggable parent-reduce rules.
5+
//!
6+
//! [`OptimizerSession`] wraps an [`FnRegistry`] keyed by `(parent_encoding_id, child_encoding_id)`
7+
//! and is consulted by the optimizer during execution, before the child encoding's static
8+
//! `PARENT_RULES` are tried. Entries are typed as [`ReduceParentFn`](super::ReduceParentFn).
9+
//!
10+
//! The registry is empty by default. Downstream crates register `ReduceParentFn` values to add
11+
//! new parent-reduce rules or override ones that the child encoding would otherwise run from its
12+
//! static `PARENT_RULES`.
13+
14+
use vortex_session::Ref;
15+
use vortex_session::SessionExt;
16+
use vortex_session::registry::FnRegistry;
17+
18+
/// Session state for pluggable parent-reduce dispatch keyed by `(parent_id, child_id)`.
19+
#[derive(Debug, Default)]
20+
pub struct OptimizerSession {
21+
registry: FnRegistry,
22+
}
23+
24+
impl OptimizerSession {
25+
/// Create an empty session with no rules registered.
26+
pub fn empty() -> Self {
27+
Self::default()
28+
}
29+
30+
/// Access the underlying registry for direct registration and lookup.
31+
pub fn registry(&self) -> &FnRegistry {
32+
&self.registry
33+
}
34+
}
35+
36+
/// Extension trait for accessing the optimizer registry from a Vortex session.
37+
pub trait OptimizerSessionExt: SessionExt {
38+
/// Returns the optimizer session variable.
39+
fn optimizer(&self) -> Ref<'_, OptimizerSession> {
40+
self.get::<OptimizerSession>()
41+
}
42+
}
43+
impl<S: SessionExt> OptimizerSessionExt for S {}

0 commit comments

Comments
 (0)