@@ -6,12 +6,25 @@ use std::io::Write;
66use std:: sync:: Arc ;
77use std:: sync:: atomic:: AtomicU64 ;
88
9- use futures:: future:: { Fuse , LocalBoxFuture , ready} ;
10- use futures:: { FutureExt , StreamExt , TryStreamExt , pin_mut, select} ;
11- use vortex_array:: iter:: { ArrayIterator , ArrayIteratorExt } ;
12- use vortex_array:: stats:: { PRUNING_STATS , Stat } ;
13- use vortex_array:: stream:: { ArrayStream , ArrayStreamAdapter , ArrayStreamExt , SendableArrayStream } ;
14- use vortex_array:: { ArrayContext , ArrayRef } ;
9+ use futures:: FutureExt ;
10+ use futures:: StreamExt ;
11+ use futures:: TryStreamExt ;
12+ use futures:: future:: Fuse ;
13+ use futures:: future:: LocalBoxFuture ;
14+ use futures:: future:: ready;
15+ use futures:: pin_mut;
16+ use futures:: select;
17+ use vortex_array:: ArrayContext ;
18+ use vortex_array:: ArrayRef ;
19+ use vortex_array:: iter:: ArrayIterator ;
20+ use vortex_array:: iter:: ArrayIteratorExt ;
21+ use vortex_array:: ArraySessionExt ;
22+ use vortex_array:: stats:: PRUNING_STATS ;
23+ use vortex_array:: stats:: Stat ;
24+ use vortex_array:: stream:: ArrayStream ;
25+ use vortex_array:: stream:: ArrayStreamAdapter ;
26+ use vortex_array:: stream:: ArrayStreamExt ;
27+ use vortex_array:: stream:: SendableArrayStream ;
1528use vortex_buffer:: ByteBuffer ;
1629use vortex_dtype:: DType ;
1730use vortex_error:: { VortexError , VortexExpect , VortexResult , vortex_bail, vortex_err} ;
@@ -116,8 +129,12 @@ impl VortexWriteOptions {
116129 mut write : W ,
117130 stream : SendableArrayStream ,
118131 ) -> VortexResult < WriteSummary > {
119- // Set up a Context to capture the encodings used in the file.
120- let ctx = ArrayContext :: empty ( ) ;
132+ // NOTE(os): Setup an array context that already has all known encodings pre-populated.
133+ // This is preferred for now over having an empty context here, because only the
134+ // serialised array order is deterministic. The serialisation of arrays are done
135+ // parallel and with an empty context they can register their encodings to the context
136+ // in different order, changing the written bytes from run to run.
137+ let ctx = ArrayContext :: from_registry_sorted ( self . session . arrays ( ) . registry ( ) ) ;
121138 let dtype = stream. dtype ( ) . clone ( ) ;
122139
123140 let ( mut ptr, eof) = SequenceId :: root ( ) . split ( ) ;
0 commit comments