From cb0066c68b1848a6c500dc4cf9282689b241dedc Mon Sep 17 00:00:00 2001 From: Joseph Isaacs Date: Fri, 24 Jul 2026 15:59:55 +0000 Subject: [PATCH] refactor(edition): back EnabledEditions with a session Registry Replace the Arc> behind EnabledEditions with the shared Registry used by the other session variables (array encodings, scalar functions, layouts, dtypes), keyed by edition family. Enabling an edition maps to Registry::register, which replaces the family's previous entry, matching the "at most one edition per family" semantics. The family &'static str is interned via Into only at enable time, a rare config-time write, so the disallowed hot-path interning does not apply. editions() no longer guarantees an ordering; the one test that asserted a specific order sorts the result itself. Signed-off-by: Joseph Isaacs --- vortex-edition/src/session.rs | 14 ++++++++++---- vortex-edition/src/tests.rs | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/vortex-edition/src/session.rs b/vortex-edition/src/session.rs index a50d17b6b53..f6366371c60 100644 --- a/vortex-edition/src/session.rs +++ b/vortex-edition/src/session.rs @@ -12,6 +12,7 @@ use vortex_session::SessionExt; use vortex_session::SessionGuard; use vortex_session::SessionVar; use vortex_session::registry::Id; +use vortex_session::registry::Registry; use crate::Edition; use crate::EditionDeclaration; @@ -46,19 +47,24 @@ struct Inner { /// same family replaces the previous selection. This is separate from [`EditionSession`]: /// registration describes what a session knows how to reason about, while enabling is the /// explicit writer policy. +/// +/// Backed by the shared session [`Registry`] keyed by edition family, so clones observe the +/// same selection and enabling an edition replaces the family's previous entry. #[derive(Clone, Debug, Default)] pub struct EnabledEditions { - inner: Arc>>, + inner: Registry, } impl EnabledEditions { - /// Return the enabled editions, sorted by family. + /// Return the enabled editions. pub fn editions(&self) -> Vec { - self.inner.read().values().copied().collect() + self.inner.items().collect() } fn enable(&self, edition: EditionId) { - self.inner.write().insert(edition.family, edition); + // The family is a `&'static str`; `Into` interns it once at enable time (a rare + // config-time write, never on the read path). + self.inner.register(edition.family, edition); } } diff --git a/vortex-edition/src/tests.rs b/vortex-edition/src/tests.rs index 3d6550982db..09e1345615a 100644 --- a/vortex-edition/src/tests.rs +++ b/vortex-edition/src/tests.rs @@ -184,7 +184,9 @@ fn enabled_editions_are_independent_across_families() -> Result<(), crate::Editi session.enable_edition(FIRST)?; session.enable_edition(OTHER)?; - assert_eq!(session.enabled_editions().editions(), [OTHER, FIRST]); + let mut enabled = session.enabled_editions().editions(); + enabled.sort_unstable(); + assert_eq!(enabled, [OTHER, FIRST]); assert_eq!(session.enabled_encoding_ids().len(), 3); Ok(()) }