@@ -13,13 +13,12 @@ use libfuzzer_sys::arbitrary::Error::EmptyChoose;
1313use libfuzzer_sys:: arbitrary:: { Arbitrary , Result , Unstructured } ;
1414pub use sort:: sort_canonical_array;
1515use vortex_array:: aliases:: hash_set:: HashSet ;
16- use vortex_array:: arrays:: ListEncoding ;
1716use vortex_array:: arrays:: arbitrary:: ArbitraryArray ;
1817use vortex_array:: compute:: { Operator , SearchResult , SearchSortedSide , scalar_at} ;
19- use vortex_array:: vtable:: EncodingVTable ;
20- use vortex_array:: { Array , ArrayRef , ArrayVisitorExt , EncodingId , IntoArray } ;
18+ use vortex_array:: { Array , ArrayRef , IntoArray } ;
2119use vortex_btrblocks:: BtrBlocksCompressor ;
2220use vortex_buffer:: Buffer ;
21+ use vortex_dtype:: DType ;
2322use vortex_error:: { VortexUnwrap , vortex_panic} ;
2423use vortex_mask:: Mask ;
2524use vortex_scalar:: Scalar ;
@@ -74,7 +73,10 @@ impl<'a> Arbitrary<'a> for FuzzArrayAction {
7473 let array = ArbitraryArray :: arbitrary ( u) ?. 0 ;
7574 let mut current_array = array. to_array ( ) ;
7675
77- let valid_actions = actions_for_array ( & current_array) ;
76+ let mut valid_actions = actions_for_dtype ( current_array. dtype ( ) )
77+ . into_iter ( )
78+ . collect :: < Vec < _ > > ( ) ;
79+ valid_actions. sort_unstable ( ) ;
7880
7981 let mut actions = Vec :: new ( ) ;
8082 let action_count = u. int_in_range ( 1 ..=4 ) ?;
@@ -201,21 +203,18 @@ fn random_value_from_list(u: &mut Unstructured<'_>, vec: &[usize]) -> Result<usi
201203
202204const ALL_ACTIONS : RangeInclusive < usize > = 0 ..=5 ;
203205
204- fn actions_for_encoding ( encoding_id : EncodingId ) -> HashSet < usize > {
205- if ListEncoding . id ( ) == encoding_id {
206+ fn actions_for_dtype ( dtype : & DType ) -> HashSet < usize > {
207+ match dtype {
208+ // All but compare
209+ DType :: Struct ( sdt, _) => sdt
210+ . fields ( )
211+ . map ( |child| actions_for_dtype ( & child) )
212+ . fold ( ( 0 ..=4 ) . collect ( ) , |acc, actions| {
213+ acc. intersection ( & actions) . copied ( ) . collect ( )
214+ } ) ,
215+ // Once we support more list operations also recurse here on child dtype
206216 // compress, slice
207- vec ! [ 0 , 1 ] . into_iter ( ) . collect ( )
208- } else {
209- ALL_ACTIONS . collect ( )
217+ DType :: List ( ..) => [ 0 , 1 ] . into_iter ( ) . collect ( ) ,
218+ _ => ALL_ACTIONS . collect ( ) ,
210219 }
211220}
212-
213- fn actions_for_array ( array : & dyn Array ) -> Vec < usize > {
214- array
215- . depth_first_traversal ( )
216- . map ( |child| actions_for_encoding ( child. encoding ( ) ) )
217- . fold ( ALL_ACTIONS . collect :: < Vec < _ > > ( ) , |mut acc, actions| {
218- acc. retain ( |a| actions. contains ( a) ) ;
219- acc
220- } )
221- }
0 commit comments