Skip to content

Commit

Permalink
remove invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-isaacs committed Nov 22, 2024
1 parent 9a6059a commit 52b33c9
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 94 deletions.
4 changes: 2 additions & 2 deletions datafusion/functions/benches/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("concat function");
group.bench_function(BenchmarkId::new("concat", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
criterion::black_box(concat().invoke(&args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
criterion::black_box(concat().invoke_batch(&args, size).unwrap())
})
});
group.finish();
Expand Down
8 changes: 4 additions & 4 deletions datafusion/functions/benches/cot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ fn criterion_benchmark(c: &mut Criterion) {
let f32_args = vec![ColumnarValue::Array(f32_array)];
c.bench_function(&format!("cot f32 array: {}", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(cot_fn.invoke(&f32_args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
black_box(cot_fn.invoke_batch(&f32_args, size).unwrap())
})
});
let f64_array = Arc::new(create_primitive_array::<Float64Type>(size, 0.2));
let f64_args = vec![ColumnarValue::Array(f64_array)];
c.bench_function(&format!("cot f64 array: {}", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(cot_fn.invoke(&f64_args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
black_box(cot_fn.invoke_batch(&f64_args, size).unwrap())
})
});
}
Expand Down
10 changes: 6 additions & 4 deletions datafusion/functions/benches/date_bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern crate criterion;

use std::sync::Arc;

use arrow::array::{ArrayRef, TimestampSecondArray};
use arrow::array::{Array, ArrayRef, TimestampSecondArray};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use datafusion_common::ScalarValue;
use rand::rngs::ThreadRng;
Expand All @@ -40,14 +40,16 @@ fn timestamps(rng: &mut ThreadRng) -> TimestampSecondArray {
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("date_bin_1000", |b| {
let mut rng = rand::thread_rng();
let timestamps_array = Arc::new(timestamps(&mut rng)) as ArrayRef;
let batch_len = timestamps_array.len();
let interval = ColumnarValue::Scalar(ScalarValue::new_interval_dt(0, 1_000_000));
let timestamps = ColumnarValue::Array(Arc::new(timestamps(&mut rng)) as ArrayRef);
let timestamps = ColumnarValue::Array(timestamps_array);
let udf = date_bin();

b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
#[allow(deprecated)] // TODO use invoke_with_args
black_box(
udf.invoke(&[interval.clone(), timestamps.clone()])
udf.invoke_batch(&[interval.clone(), timestamps.clone()], batch_len)
.expect("date_bin should work on valid values"),
)
})
Expand Down
8 changes: 4 additions & 4 deletions datafusion/functions/benches/isnan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ fn criterion_benchmark(c: &mut Criterion) {
let f32_args = vec![ColumnarValue::Array(f32_array)];
c.bench_function(&format!("isnan f32 array: {}", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(isnan.invoke(&f32_args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
black_box(isnan.invoke_batch(&f32_args, size).unwrap())
})
});
let f64_array = Arc::new(create_primitive_array::<Float64Type>(size, 0.2));
let f64_args = vec![ColumnarValue::Array(f64_array)];
c.bench_function(&format!("isnan f64 array: {}", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(isnan.invoke(&f64_args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
black_box(isnan.invoke_batch(&f64_args, size).unwrap())
})
});
}
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/benches/ltrim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ fn run_with_string_type<M: Measurement>(
),
|b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(ltrim.invoke(&args))
#[allow(deprecated)] // TODO use invoke_with_args
black_box(ltrim.invoke_batch(&args, size))
})
},
);
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/benches/nullif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fn criterion_benchmark(c: &mut Criterion) {
];
c.bench_function(&format!("nullif scalar array: {}", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(nullif.invoke(&args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
black_box(nullif.invoke_batch(&args, size).unwrap())
})
});
}
Expand Down
7 changes: 4 additions & 3 deletions datafusion/functions/benches/substr_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern crate criterion;

use std::sync::Arc;

use arrow::array::{ArrayRef, Int64Array, StringArray};
use arrow::array::{Array, ArrayRef, Int64Array, StringArray};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::distributions::{Alphanumeric, Uniform};
use rand::prelude::Distribution;
Expand Down Expand Up @@ -84,16 +84,17 @@ fn data() -> (StringArray, StringArray, Int64Array) {
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("substr_index_array_array_1000", |b| {
let (strings, delimiters, counts) = data();
let batch_len = counts.len();
let strings = ColumnarValue::Array(Arc::new(strings) as ArrayRef);
let delimiters = ColumnarValue::Array(Arc::new(delimiters) as ArrayRef);
let counts = ColumnarValue::Array(Arc::new(counts) as ArrayRef);

let args = [strings, delimiters, counts];
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
#[allow(deprecated)] // TODO: invoke_with_args
black_box(
substr_index()
.invoke(&args)
.invoke_batch(&args, batch_len)
.expect("substr_index should work on valid values"),
)
})
Expand Down
16 changes: 10 additions & 6 deletions datafusion/functions/benches/to_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,34 @@ fn patterns(rng: &mut ThreadRng) -> StringArray {
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("to_char_array_array_1000", |b| {
let mut rng = rand::thread_rng();
let data = ColumnarValue::Array(Arc::new(data(&mut rng)) as ArrayRef);
let data_arr = data(&mut rng);
let batch_len = data_arr.len();
let data = ColumnarValue::Array(Arc::new(data_arr) as ArrayRef);
let patterns = ColumnarValue::Array(Arc::new(patterns(&mut rng)) as ArrayRef);

b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
#[allow(deprecated)] // TODO use invoke_with_args
black_box(
to_char()
.invoke(&[data.clone(), patterns.clone()])
.invoke_batch(&[data.clone(), patterns.clone()], batch_len)
.expect("to_char should work on valid values"),
)
})
});

c.bench_function("to_char_array_scalar_1000", |b| {
let mut rng = rand::thread_rng();
let data = ColumnarValue::Array(Arc::new(data(&mut rng)) as ArrayRef);
let data_arr = data(&mut rng);
let batch_len = data_arr.len();
let data = ColumnarValue::Array(Arc::new(data_arr) as ArrayRef);
let patterns =
ColumnarValue::Scalar(ScalarValue::Utf8(Some("%Y-%m-%d".to_string())));

b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
#[allow(deprecated)] // TODO use invoke_with_args
black_box(
to_char()
.invoke(&[data.clone(), patterns.clone()])
.invoke_batch(&[data.clone(), patterns.clone()], batch_len)
.expect("to_char should work on valid values"),
)
})
Expand Down
8 changes: 4 additions & 4 deletions datafusion/functions/benches/trunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ fn criterion_benchmark(c: &mut Criterion) {
let f32_args = vec![ColumnarValue::Array(f32_array)];
c.bench_function(&format!("trunc f32 array: {}", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(trunc.invoke(&f32_args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
black_box(trunc.invoke_batch(&f32_args, size).unwrap())
})
});
let f64_array = Arc::new(create_primitive_array::<Float64Type>(size, 0.2));
let f64_args = vec![ColumnarValue::Array(f64_array)];
c.bench_function(&format!("trunc f64 array: {}", size), |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(trunc.invoke(&f64_args).unwrap())
#[allow(deprecated)] // TODO use invoke_with_args
black_box(trunc.invoke_batch(&f64_args, size).unwrap())
})
});
}
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/benches/upper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ fn criterion_benchmark(c: &mut Criterion) {
let args = create_args(size, 32);
c.bench_function("upper_all_values_are_ascii", |b| {
b.iter(|| {
#[allow(deprecated)] // TODO use invoke_batch
black_box(upper.invoke(&args))
#[allow(deprecated)] // TODO use invoke_with_args
black_box(upper.invoke_batch(&args, size))
})
});
}
Expand Down
Loading

0 comments on commit 52b33c9

Please sign in to comment.