@@ -15,7 +15,6 @@ use vortex_dtype::DType;
1515use vortex_dtype:: NativePType ;
1616use vortex_dtype:: match_each_unsigned_integer_ptype;
1717use vortex_error:: VortexResult ;
18- use vortex_mask:: Mask ;
1918use vortex_vector:: Vector ;
2019use vortex_vector:: VectorMutOps ;
2120use vortex_vector:: VectorOps ;
@@ -59,31 +58,11 @@ pub fn decompress_into_vector<T: ALPFloat>(
5958 patches_vectors : Option < ( Vector , Vector , Option < Vector > ) > ,
6059 patches_offset : usize ,
6160) -> VortexResult < Vector > {
62- let encoded_primitive = encoded_vector. into_primitive ( ) ;
63- let validity = encoded_primitive. validity ( ) . clone ( ) ;
64- let encoded_mutable = encoded_primitive. into_mut ( ) ;
65-
66- let alp_buffer = T :: ALPInt :: downcast ( encoded_mutable) . into_parts ( ) . 0 ;
67-
68- decompress_from_buffer :: < T > (
69- alp_buffer,
70- exponents,
71- patches_vectors,
72- patches_offset,
73- validity,
74- )
75- }
76-
77- fn decompress_from_buffer < T : ALPFloat > (
78- mut alp_buffer : BufferMut < T :: ALPInt > ,
79- exponents : Exponents ,
80- patches_vectors : Option < ( Vector , Vector , Option < Vector > ) > ,
81- patches_offset : usize ,
82- validity : Mask ,
83- ) -> VortexResult < Vector > {
61+ let encoded_primitive = encoded_vector. into_primitive ( ) . into_mut ( ) ;
62+ let ( mut alp_buffer, mask) = T :: ALPInt :: downcast ( encoded_primitive) . into_parts ( ) ;
8463 <T >:: decode_slice_inplace ( alp_buffer. as_mut_slice ( ) , exponents) ;
8564
86- // Convert to float buffer .
65+ // SAFETY: `Buffer<T::ALPInt> and `BufferMut<T>` have the same layout .
8766 let mut decoded_buffer: BufferMut < T > = unsafe { transmute ( alp_buffer) } ;
8867
8968 // Apply patches if they exist.
@@ -105,8 +84,7 @@ fn decompress_from_buffer<T: ALPFloat>(
10584 } ) ;
10685 }
10786
108- let result = PVectorMut :: < T > :: new ( decoded_buffer, validity. into_mut ( ) ) ;
109- Ok ( result. freeze ( ) . into ( ) )
87+ Ok ( PVectorMut :: < T > :: new ( decoded_buffer, mask) . freeze ( ) . into ( ) )
11088}
11189
11290/// Decompresses an ALP-encoded array in 1024-element chunks.
0 commit comments