Skip to content

Commit ea3e0db

Browse files
committed
fix
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent a9a3a2c commit ea3e0db

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
#![expect(clippy::unwrap_used)]
5+
#![expect(clippy::cast_possible_truncation)]
6+
7+
use divan::Bencher;
8+
use vortex_array::dtype::DType;
9+
use vortex_array::dtype::Nullability;
10+
use vortex_array::dtype::PType;
11+
use vortex_array::dtype::StructFields;
12+
use vortex_array::expr::Expression;
13+
use vortex_array::expr::eq;
14+
use vortex_array::expr::get_item;
15+
use vortex_array::expr::lit;
16+
use vortex_array::expr::or;
17+
use vortex_array::expr::root;
18+
19+
fn main() {
20+
divan::main();
21+
}
22+
23+
fn struct_scope() -> DType {
24+
DType::Struct(
25+
StructFields::new(
26+
["x"].into(),
27+
vec![DType::Primitive(PType::I32, Nullability::NonNullable)],
28+
),
29+
Nullability::NonNullable,
30+
)
31+
}
32+
33+
fn build_or_chain(n: usize) -> Expression {
34+
let base = eq(get_item("x", root()), lit(0i32));
35+
(1..n).fold(base, |acc, i| or(acc, eq(get_item("x", root()), lit(i as i32))))
36+
}
37+
38+
#[divan::bench(args = [200])]
39+
fn optimize_or_chain(bencher: Bencher, n: usize) {
40+
let expr = build_or_chain(n);
41+
let scope = struct_scope();
42+
bencher.bench(|| expr.optimize_recursive(&scope).unwrap());
43+
}

0 commit comments

Comments
 (0)