@@ -14,6 +14,7 @@ mod reader;
1414pub mod writer;
1515
1616use std:: sync:: Arc ;
17+ use std:: sync:: LazyLock ;
1718use std:: sync:: OnceLock ;
1819
1920use futures:: FutureExt ;
@@ -47,6 +48,7 @@ use vortex_error::vortex_bail;
4748use vortex_error:: vortex_err;
4849use vortex_error:: vortex_panic;
4950use vortex_session:: VortexSession ;
51+ use vortex_session:: registry:: Id ;
5052use vortex_session:: registry:: ReadContext ;
5153use vortex_utils:: aliases:: hash_map:: HashMap ;
5254
@@ -69,6 +71,17 @@ use crate::vtable;
6971
7072vtable ! ( ArrayTree ) ;
7173
74+ /// Well-known [`LayoutReaderContext`] key under which [`ArrayTreeLayout::derive_reader_ctx`]
75+ /// publishes its [`ArrayTreesSource`].
76+ ///
77+ /// Both the publisher (parent [`ArrayTreeLayout`]) and the consumer
78+ /// ([`ArrayTreeFlatLayout`]'s `new_reader`) hardcode this id, so no metadata persistence is
79+ /// needed to bind them. Two stacked `ArrayTreeLayouts` both publish under this id; the
80+ /// inner one overrides the outer in the descendant's view — exactly the "nearest ancestor
81+ /// wins" semantic each `ArrayTreeFlat` leaf wants.
82+ pub static ARRAY_TREES_SOURCE_ID : LazyLock < Id > =
83+ LazyLock :: new ( || Id :: new_static ( "vortex.array_tree.source" ) ) ;
84+
7285/// Encoding marker for [`ArrayTreeLayout`].
7386#[ derive( Debug ) ]
7487pub struct ArrayTreeLayoutEncoding ;
@@ -134,8 +147,9 @@ impl ArrayTreeLayout {
134147 }
135148
136149 /// Derive a [`LayoutReaderContext`] that publishes an [`ArrayTreesSource`] backed by this
137- /// layout's auxiliary `array_trees` child. Descendant [`ArrayTreeFlatLayout`] readers
138- /// pull the source via `ctx.get::<ArrayTreesSource>()` to resolve their compact trees.
150+ /// layout's auxiliary `array_trees` child under [`ARRAY_TREES_SOURCE_ID`]. Descendant
151+ /// [`ArrayTreeFlatLayout`] readers pull the source by the same id to resolve their
152+ /// compact trees.
139153 ///
140154 /// Used by:
141155 /// - The normal [`crate::VTable::new_reader`] dispatch on `ArrayTreeLayout` (production path).
@@ -158,7 +172,7 @@ impl ArrayTreeLayout {
158172 ctx,
159173 ) ?;
160174 let source = Arc :: new ( ArrayTreesSource :: new ( trees_reader, session. clone ( ) ) ) ;
161- Ok ( ctx. with ( source) )
175+ Ok ( ctx. with ( * ARRAY_TREES_SOURCE_ID , source) )
162176 }
163177}
164178
@@ -259,8 +273,8 @@ impl VTable for ArrayTree {
259273/// the cached map.
260274///
261275/// Published by [`ArrayTreeLayout::derive_reader_ctx`] into the [`LayoutReaderContext`]
262- /// passed to descendants; pulled by [`ArrayTreeFlatLayout`]'s reader via
263- /// `ctx.get::<ArrayTreesSource>()` .
276+ /// passed to descendants under [`ARRAY_TREES_SOURCE_ID`]; pulled by
277+ /// [`ArrayTreeFlatLayout`]'s reader by the same id .
264278pub struct ArrayTreesSource {
265279 reader : LayoutReaderRef ,
266280 /// Session used to create execution contexts when canonicalizing the consolidated array
0 commit comments