@@ -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:: primitive:: PrimitiveArrayExt ;
@@ -54,6 +57,7 @@ use vortex_buffer::BitBuffer;
5457use vortex_buffer:: Buffer ;
5558use vortex_buffer:: BufferString ;
5659use vortex_buffer:: ByteBuffer ;
60+ use vortex_buffer:: ByteBufferMut ;
5761use vortex_buffer:: buffer;
5862use vortex_buffer:: buffer_mut;
5963use vortex_error:: VortexError ;
@@ -140,6 +144,14 @@ pub(super) fn execute_sparse(parts: SparseParts, ctx: &mut ExecutionCtx) -> Vort
140144 let fill = fill_value. as_binary ( ) . value ( ) . cloned ( ) ;
141145 execute_varbin ( & patches, & fill_value, dtype. clone ( ) , fill, len, ctx) ?
142146 }
147+ DType :: FixedSizeBinary ( byte_width, nullability) => execute_sparse_fixed_size_binary (
148+ & patches,
149+ & fill_value,
150+ * byte_width,
151+ * nullability,
152+ len,
153+ ctx,
154+ ) ?,
143155 DType :: List ( values_dtype, nullability) => execute_sparse_lists (
144156 & patches,
145157 & fill_value,
@@ -165,6 +177,43 @@ pub(super) fn execute_sparse(parts: SparseParts, ctx: &mut ExecutionCtx) -> Vort
165177 } )
166178}
167179
180+ fn execute_sparse_fixed_size_binary (
181+ resolved : & Patches ,
182+ fill_scalar : & Scalar ,
183+ byte_width : u32 ,
184+ nullability : Nullability ,
185+ len : usize ,
186+ ctx : & mut ExecutionCtx ,
187+ ) -> VortexResult < ArrayRef > {
188+ let byte_width_usize = byte_width as usize ;
189+ let fill = fill_scalar
190+ . as_binary ( )
191+ . value ( )
192+ . cloned ( )
193+ . unwrap_or_else ( || ByteBuffer :: zeroed ( byte_width_usize) ) ;
194+ let mut dense = ByteBufferMut :: with_capacity ( len. saturating_mul ( byte_width_usize) ) ;
195+ for _ in 0 ..len {
196+ dense. extend_from_slice ( fill. as_slice ( ) ) ;
197+ }
198+
199+ let indices = resolved. indices ( ) . as_ :: < Primitive > ( ) . into_owned ( ) ;
200+ let values = resolved. values ( ) . as_ :: < FixedSizeBinary > ( ) . into_owned ( ) ;
201+ let patch_bytes = values. buffer_handle ( ) . to_host_sync ( ) ;
202+ match_each_integer_ptype ! ( indices. ptype( ) , |I | {
203+ for ( patch_row, patch_index) in indices. as_slice:: <I >( ) . iter( ) . enumerate( ) {
204+ let patch_index = <usize as NumCast >:: from( * patch_index)
205+ . vortex_expect( "fixed-size binary patch index must fit in usize" ) ;
206+ let source = patch_row * byte_width_usize;
207+ let target = patch_index * byte_width_usize;
208+ dense[ target..target + byte_width_usize]
209+ . copy_from_slice( & patch_bytes[ source..source + byte_width_usize] ) ;
210+ }
211+ } ) ;
212+
213+ let validity = sparse_validity ( resolved, fill_scalar, nullability, len, ctx) ?;
214+ Ok ( FixedSizeBinaryArray :: new ( dense. freeze ( ) , byte_width, len, validity) . into_array ( ) )
215+ }
216+
168217fn execute_sparse_lists (
169218 resolved : & Patches ,
170219 fill_value : & Scalar ,
0 commit comments