@@ -19,17 +19,23 @@ use std::sync::Arc;
19
19
20
20
use arrow:: array:: {
21
21
Array , ArrayRef , ArrowPrimitiveType , AsArray , ListArray , NullBufferBuilder ,
22
+ PrimitiveArray ,
22
23
} ;
23
24
use arrow:: datatypes:: { Field , Int64Type } ;
24
- use arrow:: util:: bench_util:: create_primitive_array;
25
25
use criterion:: { black_box, criterion_group, criterion_main, Criterion } ;
26
26
use datafusion_expr:: Accumulator ;
27
27
use datafusion_functions_aggregate:: array_agg:: ArrayAggAccumulator ;
28
28
29
29
use arrow:: buffer:: OffsetBuffer ;
30
- use arrow:: util:: test_util:: seedable_rng;
31
30
use rand:: distributions:: { Distribution , Standard } ;
31
+ use rand:: prelude:: StdRng ;
32
32
use rand:: Rng ;
33
+ use rand:: SeedableRng ;
34
+
35
+ /// Returns fixed seedable RNG
36
+ pub fn seedable_rng ( ) -> StdRng {
37
+ StdRng :: seed_from_u64 ( 42 )
38
+ }
33
39
34
40
fn merge_batch_bench ( c : & mut Criterion , name : & str , values : ArrayRef ) {
35
41
let list_item_data_type = values. as_list :: < i32 > ( ) . values ( ) . data_type ( ) . clone ( ) ;
@@ -46,6 +52,24 @@ fn merge_batch_bench(c: &mut Criterion, name: &str, values: ArrayRef) {
46
52
} ) ;
47
53
}
48
54
55
+ pub fn create_primitive_array < T > ( size : usize , null_density : f32 ) -> PrimitiveArray < T >
56
+ where
57
+ T : ArrowPrimitiveType ,
58
+ Standard : Distribution < T :: Native > ,
59
+ {
60
+ let mut rng = seedable_rng ( ) ;
61
+
62
+ ( 0 ..size)
63
+ . map ( |_| {
64
+ if rng. gen :: < f32 > ( ) < null_density {
65
+ None
66
+ } else {
67
+ Some ( rng. gen ( ) )
68
+ }
69
+ } )
70
+ . collect ( )
71
+ }
72
+
49
73
/// Create List array with the given item data type, null density, null locations and zero length lists density
50
74
/// Creates an random (but fixed-seeded) array of a given size and null density
51
75
pub fn create_list_array < T > (
0 commit comments