@@ -33,6 +33,10 @@ use rand::Rng;
33
33
34
34
const SIZE : usize = 65536 ;
35
35
36
+ fn bench_like_utf8view_scalar ( arr_a : & StringViewArray , value_b : & str ) {
37
+ like ( arr_a, & StringViewArray :: new_scalar ( value_b) ) . unwrap ( ) ;
38
+ }
39
+
36
40
fn bench_like_utf8_scalar ( arr_a : & StringArray , value_b : & str ) {
37
41
like ( arr_a, & StringArray :: new_scalar ( value_b) ) . unwrap ( ) ;
38
42
}
@@ -77,6 +81,8 @@ fn add_benchmark(c: &mut Criterion) {
77
81
78
82
let scalar = Float32Array :: from ( vec ! [ 1.0 ] ) ;
79
83
84
+ // eq benchmarks
85
+
80
86
c. bench_function ( "eq Float32" , |b| b. iter ( || eq ( & arr_a, & arr_b) ) ) ;
81
87
c. bench_function ( "eq scalar Float32" , |b| {
82
88
b. iter ( || eq ( & arr_a, & Scalar :: new ( & scalar) ) . unwrap ( ) )
@@ -161,14 +167,9 @@ fn add_benchmark(c: &mut Criterion) {
161
167
let string_right = StringArray :: from_iter ( array_gen) ;
162
168
let string_view_right = StringViewArray :: from_iter ( string_right. iter ( ) ) ;
163
169
170
+ let scalar = StringArray :: new_scalar ( "xxxx" ) ;
164
171
c. bench_function ( "eq scalar StringArray" , |b| {
165
- b. iter ( || {
166
- eq (
167
- & Scalar :: new ( StringArray :: from_iter_values ( [ "xxxx" ] ) ) ,
168
- & string_left,
169
- )
170
- . unwrap ( )
171
- } )
172
+ b. iter ( || eq ( & scalar, & string_left) . unwrap ( ) )
172
173
} ) ;
173
174
174
175
c. bench_function ( "lt scalar StringViewArray" , |b| {
@@ -192,13 +193,7 @@ fn add_benchmark(c: &mut Criterion) {
192
193
} ) ;
193
194
194
195
c. bench_function ( "eq scalar StringViewArray" , |b| {
195
- b. iter ( || {
196
- eq (
197
- & Scalar :: new ( StringViewArray :: from_iter_values ( [ "xxxx" ] ) ) ,
198
- & string_view_left,
199
- )
200
- . unwrap ( )
201
- } )
196
+ b. iter ( || eq ( & scalar, & string_view_left) . unwrap ( ) )
202
197
} ) ;
203
198
204
199
c. bench_function ( "eq StringArray StringArray" , |b| {
@@ -209,6 +204,8 @@ fn add_benchmark(c: &mut Criterion) {
209
204
b. iter ( || eq ( & string_view_left, & string_view_right) . unwrap ( ) )
210
205
} ) ;
211
206
207
+ // StringArray: LIKE benchmarks
208
+
212
209
c. bench_function ( "like_utf8 scalar equals" , |b| {
213
210
b. iter ( || bench_like_utf8_scalar ( & arr_string, "xxxx" ) )
214
211
} ) ;
@@ -229,6 +226,30 @@ fn add_benchmark(c: &mut Criterion) {
229
226
b. iter ( || bench_like_utf8_scalar ( & arr_string, "%xx_xx%xxx" ) )
230
227
} ) ;
231
228
229
+ // StringViewArray: LIKE benchmarks
230
+ // Note: since like/nlike share the same implementation, we only benchmark one
231
+ c. bench_function ( "like_utf8view scalar equals" , |b| {
232
+ b. iter ( || bench_like_utf8view_scalar ( & string_view_left, "xxxx" ) )
233
+ } ) ;
234
+
235
+ c. bench_function ( "like_utf8view scalar contains" , |b| {
236
+ b. iter ( || bench_like_utf8view_scalar ( & string_view_left, "%xxxx%" ) )
237
+ } ) ;
238
+
239
+ c. bench_function ( "like_utf8view scalar ends with" , |b| {
240
+ b. iter ( || bench_like_utf8view_scalar ( & string_view_left, "xxxx%" ) )
241
+ } ) ;
242
+
243
+ c. bench_function ( "like_utf8view scalar starts with" , |b| {
244
+ b. iter ( || bench_like_utf8view_scalar ( & string_view_left, "%xxxx" ) )
245
+ } ) ;
246
+
247
+ c. bench_function ( "like_utf8view scalar complex" , |b| {
248
+ b. iter ( || bench_like_utf8view_scalar ( & string_view_left, "%xx_xx%xxx" ) )
249
+ } ) ;
250
+
251
+ // StringArray: NOT LIKE benchmarks
252
+
232
253
c. bench_function ( "nlike_utf8 scalar equals" , |b| {
233
254
b. iter ( || bench_nlike_utf8_scalar ( & arr_string, "xxxx" ) )
234
255
} ) ;
@@ -249,6 +270,8 @@ fn add_benchmark(c: &mut Criterion) {
249
270
b. iter ( || bench_nlike_utf8_scalar ( & arr_string, "%xx_xx%xxx" ) )
250
271
} ) ;
251
272
273
+ // StringArray: ILIKE benchmarks
274
+
252
275
c. bench_function ( "ilike_utf8 scalar equals" , |b| {
253
276
b. iter ( || bench_ilike_utf8_scalar ( & arr_string, "xxXX" ) )
254
277
} ) ;
@@ -269,6 +292,8 @@ fn add_benchmark(c: &mut Criterion) {
269
292
b. iter ( || bench_ilike_utf8_scalar ( & arr_string, "%xx_xX%xXX" ) )
270
293
} ) ;
271
294
295
+ // StringArray: NOT ILIKE benchmarks
296
+
272
297
c. bench_function ( "nilike_utf8 scalar equals" , |b| {
273
298
b. iter ( || bench_nilike_utf8_scalar ( & arr_string, "xxXX" ) )
274
299
} ) ;
@@ -297,6 +322,8 @@ fn add_benchmark(c: &mut Criterion) {
297
322
b. iter ( || bench_regexp_is_match_utf8_scalar ( & arr_string, "xx$" ) )
298
323
} ) ;
299
324
325
+ // DictionaryArray benchmarks
326
+
300
327
let strings = create_string_array :: < i32 > ( 20 , 0. ) ;
301
328
let dict_arr_a = create_dict_from_values :: < Int32Type > ( SIZE , 0. , & strings) ;
302
329
let scalar = StringArray :: from ( vec ! [ "test" ] ) ;
0 commit comments