alamb commented on code in PR #19211:
URL: https://github.com/apache/datafusion/pull/19211#discussion_r2599659395
##########
datafusion/physical-expr/benches/in_list.rs:
##########
@@ -37,78 +41,129 @@ fn do_bench(c: &mut Criterion, name: &str, values:
ArrayRef, exprs: &[ScalarValu
});
}
+/// Generates a random alphanumeric string of the specified length.
fn random_string(rng: &mut StdRng, len: usize) -> String {
let value = rng.sample_iter(&Alphanumeric).take(len).collect();
String::from_utf8(value).unwrap()
}
-fn do_benches(
- c: &mut Criterion,
- array_length: usize,
- in_list_length: usize,
- null_percent: f64,
-) {
- let mut rng = StdRng::seed_from_u64(120320);
- for string_length in [5, 10, 20] {
- let values: StringArray = (0..array_length)
- .map(|_| {
- rng.random_bool(null_percent)
- .then(|| random_string(&mut rng, string_length))
- })
- .collect();
-
- let in_list: Vec<_> = (0..in_list_length)
- .map(|_| ScalarValue::from(random_string(&mut rng, string_length)))
- .collect();
-
- do_bench(
- c,
- &format!(
- "in_list_utf8({string_length}) ({array_length},
{null_percent}) IN ({in_list_length}, 0)"
- ),
- Arc::new(values),
- &in_list,
- )
+const IN_LIST_LENGTHS: [usize; 3] = [3, 8, 100];
+const NULL_PERCENTS: [f64; 2] = [0., 0.2];
+const STRING_LENGTHS: [usize; 3] = [3, 12, 100];
+const ARRAY_LENGTH: usize = 1024;
+
+/// Returns a friendly type name for the array type.
+fn array_type_name<A: 'static>() -> &'static str {
Review Comment:
You could potentially use
https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html#display-and-fromstr
So like `array.data_type().to_string()` 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]