@@ -9,6 +9,8 @@ use vortex_array::ArrayRef;
99use vortex_array:: ExecutionCtx ;
1010use vortex_array:: IntoArray ;
1111use vortex_array:: arrays:: BoolArray ;
12+ use vortex_array:: arrays:: FixedSizeBinary ;
13+ use vortex_array:: arrays:: FixedSizeBinaryArray ;
1214use vortex_array:: arrays:: FixedSizeList ;
1315use vortex_array:: arrays:: FixedSizeListArray ;
1416use vortex_array:: arrays:: ListView ;
@@ -20,6 +22,7 @@ use vortex_array::arrays::Struct;
2022use vortex_array:: arrays:: StructArray ;
2123use vortex_array:: arrays:: VarBinView ;
2224use vortex_array:: arrays:: VarBinViewArray ;
25+ use vortex_array:: arrays:: fixed_size_binary:: FixedSizeBinaryArrayExt ;
2326use vortex_array:: arrays:: fixed_size_list:: FixedSizeListArrayExt ;
2427use vortex_array:: arrays:: listview:: ListViewArrayExt ;
2528use vortex_array:: arrays:: listview:: ListViewArraySlotsExt ;
@@ -56,6 +59,7 @@ use vortex_buffer::BitBuffer;
5659use vortex_buffer:: Buffer ;
5760use vortex_buffer:: BufferString ;
5861use vortex_buffer:: ByteBuffer ;
62+ use vortex_buffer:: ByteBufferMut ;
5963use vortex_buffer:: buffer;
6064use vortex_buffer:: buffer_mut;
6165use vortex_error:: VortexError ;
@@ -142,6 +146,14 @@ pub(super) fn execute_sparse(parts: SparseParts, ctx: &mut ExecutionCtx) -> Vort
142146 let fill = fill_value. as_binary ( ) . value ( ) . cloned ( ) ;
143147 execute_varbin ( & patches, & fill_value, dtype. clone ( ) , fill, len, ctx) ?
144148 }
149+ DType :: FixedSizeBinary ( byte_width, nullability) => execute_sparse_fixed_size_binary (
150+ & patches,
151+ & fill_value,
152+ * byte_width,
153+ * nullability,
154+ len,
155+ ctx,
156+ ) ?,
145157 DType :: List ( values_dtype, nullability) => execute_sparse_lists (
146158 & patches,
147159 & fill_value,
@@ -168,6 +180,43 @@ pub(super) fn execute_sparse(parts: SparseParts, ctx: &mut ExecutionCtx) -> Vort
168180 } )
169181}
170182
183+ fn execute_sparse_fixed_size_binary (
184+ resolved : & Patches ,
185+ fill_scalar : & Scalar ,
186+ byte_width : u32 ,
187+ nullability : Nullability ,
188+ len : usize ,
189+ ctx : & mut ExecutionCtx ,
190+ ) -> VortexResult < ArrayRef > {
191+ let byte_width_usize = byte_width as usize ;
192+ let fill = fill_scalar
193+ . as_binary ( )
194+ . value ( )
195+ . cloned ( )
196+ . unwrap_or_else ( || ByteBuffer :: zeroed ( byte_width_usize) ) ;
197+ let mut dense = ByteBufferMut :: with_capacity ( len. saturating_mul ( byte_width_usize) ) ;
198+ for _ in 0 ..len {
199+ dense. extend_from_slice ( fill. as_slice ( ) ) ;
200+ }
201+
202+ let indices = resolved. indices ( ) . as_ :: < Primitive > ( ) . into_owned ( ) ;
203+ let values = resolved. values ( ) . as_ :: < FixedSizeBinary > ( ) . into_owned ( ) ;
204+ let patch_bytes = values. buffer_handle ( ) . to_host_sync ( ) ;
205+ match_each_integer_ptype ! ( indices. ptype( ) , |I | {
206+ for ( patch_row, patch_index) in indices. as_slice:: <I >( ) . iter( ) . enumerate( ) {
207+ let patch_index = <usize as NumCast >:: from( * patch_index)
208+ . vortex_expect( "fixed-size binary patch index must fit in usize" ) ;
209+ let source = patch_row * byte_width_usize;
210+ let target = patch_index * byte_width_usize;
211+ dense[ target..target + byte_width_usize]
212+ . copy_from_slice( & patch_bytes[ source..source + byte_width_usize] ) ;
213+ }
214+ } ) ;
215+
216+ let validity = sparse_validity ( resolved, fill_scalar, nullability, len, ctx) ?;
217+ Ok ( FixedSizeBinaryArray :: new ( dense. freeze ( ) , byte_width, len, validity) . into_array ( ) )
218+ }
219+
171220fn execute_sparse_lists (
172221 resolved : & Patches ,
173222 fill_value : & Scalar ,
0 commit comments