@@ -15,15 +15,13 @@ use futures::future::LocalBoxFuture;
1515use futures:: future:: ready;
1616use futures:: pin_mut;
1717use futures:: select;
18- use itertools:: Itertools ;
1918use vortex_array:: ArrayContext ;
2019use vortex_array:: ArrayRef ;
2120use vortex_array:: dtype:: DType ;
2221use vortex_array:: dtype:: FieldPath ;
2322use vortex_array:: expr:: stats:: Stat ;
2423use vortex_array:: iter:: ArrayIterator ;
2524use vortex_array:: iter:: ArrayIteratorExt ;
26- use vortex_array:: session:: ArraySessionExt ;
2725use vortex_array:: stats:: PRUNING_STATS ;
2826use vortex_array:: stream:: ArrayStream ;
2927use vortex_array:: stream:: ArrayStreamAdapter ;
@@ -60,8 +58,7 @@ use crate::segments::writer::BufferedSegmentSink;
6058/// Configure a new writer, which can eventually be used to write an [`ArrayStream`] into a sink
6159/// that implements [`VortexWrite`].
6260///
63- /// Unless overridden, the default [write strategy][crate::WriteStrategyBuilder] will be restricted
64- /// to the encodings in the session's enabled editions.
61+ /// All write strategies are restricted to the encodings in the session's enabled editions.
6562///
6663/// Construct with [`WriteOptionsSessionExt::write_options`] for normal use so the writer inherits
6764/// the session's runtime, array registry, and memory configuration.
@@ -102,7 +99,7 @@ impl VortexWriteOptions {
10299 ///
103100 /// The strategy controls repartitioning, statistics layout, compression, and leaf segment
104101 /// emission. Use [`WriteStrategyBuilder`] when only a small part of the default strategy needs
105- /// customization.
102+ /// customization. Replacing the strategy does not change the enabled-edition encoding policy.
106103 pub fn with_strategy ( mut self , strategy : Arc < dyn LayoutStrategy > ) -> Self {
107104 self . strategy = strategy;
108105 self
@@ -155,13 +152,11 @@ impl VortexWriteOptions {
155152 mut write : W ,
156153 stream : SendableArrayStream ,
157154 ) -> VortexResult < WriteSummary > {
158- // Pre-populate the array context with the registered encodings selected by the enabled
159- // editions. This keeps the serialized ordering deterministic without advertising every
160- // encoding the session happens to know how to read.
161- let ctx = ArrayContext :: new ( self . session . enabled_encoding_ids ( ) )
162- // The registry supplies serialization implementations; the layout strategy applies
163- // the enabled-edition write policy before arrays reach serialization.
164- . with_registry ( self . session . arrays ( ) . registry ( ) . clone ( ) ) ;
155+ let enabled_encoding_ids = self . session . enabled_encoding_ids ( ) ;
156+ // Pre-populate the array context in deterministic order and reject any array encoding
157+ // that is not part of an enabled edition, regardless of the configured write strategy.
158+ let ctx =
159+ ArrayContext :: new ( enabled_encoding_ids. clone ( ) ) . with_valid_ids ( enabled_encoding_ids) ;
165160 let dtype = stream. dtype ( ) . clone ( ) ;
166161
167162 let ( mut ptr, eof) = SequenceId :: root ( ) . split ( ) ;
@@ -531,36 +526,37 @@ impl WriteSummary {
531526
532527#[ cfg( test) ]
533528mod tests {
529+ use vortex_array:: ArrayContext ;
534530 use vortex_array:: VTable ;
535531 use vortex_array:: array_session;
536532 use vortex_array:: arrays:: Bool ;
537533 use vortex_array:: arrays:: Primitive ;
538- use vortex_array:: session:: ArraySessionExt ;
539534 use vortex_edition:: Edition ;
540535 use vortex_edition:: EditionDeclaration ;
541536 use vortex_edition:: EditionId ;
542537 use vortex_edition:: EditionSession ;
543538 use vortex_edition:: EditionSessionExt ;
544539
545540 #[ test]
546- fn initial_array_ids_are_registered_and_enabled ( ) -> Result < ( ) , vortex_edition:: EditionError > {
541+ fn array_context_only_permits_enabled_encodings ( ) -> Result < ( ) , vortex_edition:: EditionError > {
547542 const EDITION : EditionId = EditionId :: new ( "test" , 2026 , 7 , 0 ) ;
548543 static DECLARATION : EditionDeclaration = EditionDeclaration {
549544 edition : Edition {
550545 id : EDITION ,
551546 min_vortex_version : None ,
552547 } ,
553- added : & [ & "vortex.primitive" , & "test.not_registered" ] ,
548+ added : & [ & "vortex.primitive" ] ,
554549 } ;
555550
556551 let session = array_session ( ) . with :: < EditionSession > ( ) ;
557552 session. register_edition ( & DECLARATION ) ?;
558553 session. enable_edition ( EDITION ) ?;
559554
560- let registry = session. arrays ( ) . registry ( ) . clone ( ) ;
561- let ids = session. enabled_encoding_ids ( ) ;
562- assert_eq ! ( ids, [ Primitive . id( ) ] ) ;
563- assert ! ( !ids. contains( & Bool . id( ) ) ) ;
555+ let enabled_encoding_ids = session. enabled_encoding_ids ( ) ;
556+ let ctx =
557+ ArrayContext :: new ( enabled_encoding_ids. clone ( ) ) . with_valid_ids ( enabled_encoding_ids) ;
558+ assert_eq ! ( ctx. to_ids( ) , [ Primitive . id( ) ] ) ;
559+ assert ! ( ctx. intern( & Bool . id( ) ) . is_none( ) ) ;
564560 Ok ( ( ) )
565561 }
566562}
0 commit comments