@@ -9,7 +9,6 @@ use lending_iterator::gat;
99use lending_iterator:: prelude:: Item ;
1010#[ gat( Item ) ]
1111use lending_iterator:: prelude:: LendingIterator ;
12- use vortex_array:: builders:: UninitRange ;
1312use vortex_buffer:: ByteBuffer ;
1413use vortex_dtype:: PhysicalPType ;
1514
@@ -159,29 +158,34 @@ impl<T: PhysicalPType, S: UnpackStrategy<T>> UnpackedChunks<T, S> {
159158
160159 /// Decode all chunks (initial, full, and trailer) into the output range.
161160 /// This consolidates the logic for handling all three chunk types in one place.
162- pub fn decode_into ( & mut self , output : & mut UninitRange < T > ) {
161+ pub fn decode_into ( & mut self , output : & mut [ MaybeUninit < T > ] ) {
163162 let mut local_idx = 0 ;
164163
165164 // Handle initial partial chunk if present
166165 if let Some ( initial) = self . initial ( ) {
167- output. copy_from_slice ( 0 , initial) ;
168166 local_idx = initial. len ( ) ;
167+
168+ // SAFETY: &[T] and &[MaybeUninit<T>] have the same layout.
169+ let uninit_initial: & [ MaybeUninit < T > ] = unsafe { mem:: transmute ( initial) } ;
170+ output[ ..uninit_initial. len ( ) ] . copy_from_slice ( uninit_initial) ;
169171 }
170172
171173 // Handle full chunks
172174 local_idx = self . decode_full_chunks_into_at ( output, local_idx) ;
173175
174176 // Handle trailing partial chunk if present
175177 if let Some ( trailer) = self . trailer ( ) {
176- output. copy_from_slice ( local_idx, trailer) ;
178+ // SAFETY: &[T] and &[MaybeUninit<T>] have the same layout.
179+ let uninit_trailer: & [ MaybeUninit < T > ] = unsafe { mem:: transmute ( trailer) } ;
180+ output[ local_idx..] [ ..uninit_trailer. len ( ) ] . copy_from_slice ( uninit_trailer) ;
177181 }
178182 }
179183
180184 /// Unpack full chunks into output range starting at the given index.
181185 /// Returns the next local index to write to.
182186 fn decode_full_chunks_into_at (
183187 & mut self ,
184- output : & mut UninitRange < T > ,
188+ output : & mut [ MaybeUninit < T > ] ,
185189 start_idx : usize ,
186190 ) -> usize {
187191 // If there's only one chunk it has been handled already by `initial` method
@@ -204,8 +208,7 @@ impl<T: PhysicalPType, S: UnpackStrategy<T>> UnpackedChunks<T, S> {
204208 let chunk = & packed_slice[ i * elems_per_chunk..] [ ..elems_per_chunk] ;
205209
206210 unsafe {
207- // SAFETY: We're about to initialize CHUNK_SIZE elements at local_idx.
208- let uninit_dst = output. slice_uninit_mut ( local_idx, CHUNK_SIZE ) ;
211+ let uninit_dst = & mut output[ local_idx..local_idx + CHUNK_SIZE ] ;
209212 // SAFETY: &[T] and &[MaybeUninit<T>] have the same layout
210213 let dst: & mut [ T :: Physical ] = mem:: transmute ( uninit_dst) ;
211214 self . strategy . unpack_chunk ( self . bit_width , chunk, dst) ;
0 commit comments