@@ -359,6 +359,46 @@ fn add_benchmark(c: &mut Criterion) {
359359    c. bench_function ( "cast binary view to string view" ,  |b| { 
360360        b. iter ( || cast_array ( & binary_view_array,  DataType :: Utf8View ) ) 
361361    } ) ; 
362+ 
363+     c. bench_function ( "cast string single run to ree<int32>" ,  |b| { 
364+         let  source_array = StringArray :: from ( vec ! [ "a" ;  8192 ] ) ; 
365+         let  array_ref = Arc :: new ( source_array)  as  ArrayRef ; 
366+         let  target_type = DataType :: RunEndEncoded ( 
367+             Arc :: new ( Field :: new ( "run_ends" ,  DataType :: Int32 ,  false ) ) , 
368+             Arc :: new ( Field :: new ( "values" ,  DataType :: Utf8 ,  true ) ) , 
369+         ) ; 
370+         b. iter ( || cast ( & array_ref,  & target_type) . unwrap ( ) ) ; 
371+     } ) ; 
372+ 
373+     c. bench_function ( "cast runs of 10 string to ree<int32>" ,  |b| { 
374+         let  source_array:  Int32Array  = ( 0 ..8192 ) . map ( |i| i / 10 ) . collect ( ) ; 
375+         let  array_ref = Arc :: new ( source_array)  as  ArrayRef ; 
376+         let  target_type = DataType :: RunEndEncoded ( 
377+             Arc :: new ( Field :: new ( "run_ends" ,  DataType :: Int32 ,  false ) ) , 
378+             Arc :: new ( Field :: new ( "values" ,  DataType :: Int32 ,  true ) ) , 
379+         ) ; 
380+         b. iter ( || cast ( & array_ref,  & target_type) . unwrap ( ) ) ; 
381+     } ) ; 
382+ 
383+     c. bench_function ( "cast runs of 1000 int32s to ree<int32>" ,  |b| { 
384+         let  source_array:  Int32Array  = ( 0 ..8192 ) . map ( |i| i / 1000 ) . collect ( ) ; 
385+         let  array_ref = Arc :: new ( source_array)  as  ArrayRef ; 
386+         let  target_type = DataType :: RunEndEncoded ( 
387+             Arc :: new ( Field :: new ( "run_ends" ,  DataType :: Int32 ,  false ) ) , 
388+             Arc :: new ( Field :: new ( "values" ,  DataType :: Int32 ,  true ) ) , 
389+         ) ; 
390+         b. iter ( || cast ( & array_ref,  & target_type) . unwrap ( ) ) ; 
391+     } ) ; 
392+ 
393+     c. bench_function ( "cast no runs of int32s to ree<int32>" ,  |b| { 
394+         let  source_array:  Int32Array  = ( 0 ..8192 ) . collect ( ) ; 
395+         let  array_ref = Arc :: new ( source_array)  as  ArrayRef ; 
396+         let  target_type = DataType :: RunEndEncoded ( 
397+             Arc :: new ( Field :: new ( "run_ends" ,  DataType :: Int32 ,  false ) ) , 
398+             Arc :: new ( Field :: new ( "values" ,  DataType :: Int32 ,  true ) ) , 
399+         ) ; 
400+         b. iter ( || cast ( & array_ref,  & target_type) . unwrap ( ) ) ; 
401+     } ) ; 
362402} 
363403
364404criterion_group ! ( benches,  add_benchmark) ; 
0 commit comments