Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmarks/compress-bench/src/vortex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl Compressor for VortexCompressor {
// Columns are named "0".."num_columns-1"; project the given subset.
let names: FieldNames = cols.iter().map(|i| i.to_string()).collect();
let projection = select(names, root())
.optimize_recursive(&source_dtype)?
.bind(&source_dtype)?;
.bind(&source_dtype)?
.optimize_recursive()?;
scan = scan.with_projection(projection);
}
let schema = Arc::new(SESSION.arrow().to_arrow_schema(&scan.dtype()?)?);
Expand Down
8 changes: 4 additions & 4 deletions fuzz/fuzz_targets/file_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ fuzz_target!(|fuzz: FuzzFileAction| -> Corpus {
.vortex_expect("open_buffer should succeed in fuzz test");
let projection = projection_expr
.unwrap_or_else(root)
.optimize_recursive(file.dtype())
.and_then(|expr| expr.bind(file.dtype()))
.bind(file.dtype())
.and_then(|expr| expr.optimize_recursive())
.vortex_expect("projection should bind in fuzz test");
let filter = filter_expr
.map(|filter| {
filter
.optimize_recursive(file.dtype())
.and_then(|expr| expr.bind(file.dtype()))
.bind(file.dtype())
.and_then(|expr| expr.optimize_recursive())
})
.transpose()
.vortex_expect("filter should bind in fuzz test");
Expand Down
27 changes: 18 additions & 9 deletions vortex-array/benches/expr/case_when_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ fn case_when_simple(bencher: Bencher, size: usize) {
lit(100i32),
lit(0i32),
);
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -99,13 +100,14 @@ fn case_when_nary_3_conditions(bencher: Bencher, size: usize) {
],
Some(lit(0i32)),
);
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -127,13 +129,14 @@ fn case_when_nary_10_conditions(bencher: Bencher, size: usize) {
})
.collect();
let expr = nested_case_when(pairs, Some(lit(0i32)));
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -150,13 +153,14 @@ fn case_when_nary_equality_lookup(bencher: Bencher, size: usize) {
.map(|i| (eq(get_item("value", root()), lit(i)), lit(i * 10)))
.collect();
let expr = nested_case_when(pairs, Some(lit(-1i32)));
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -170,13 +174,14 @@ fn case_when_without_else(bencher: Bencher, size: usize) {

// CASE WHEN value > 500 THEN 100 END
let expr = case_when_no_else(gt(get_item("value", root()), lit(500i32)), lit(100i32));
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -194,13 +199,14 @@ fn case_when_all_true(bencher: Bencher, size: usize) {
lit(100i32),
lit(0i32),
);
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -227,13 +233,14 @@ fn case_when_nary_early_dominant(bencher: Bencher, size: usize) {
],
Some(lit(4i32)),
);
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -251,13 +258,14 @@ fn case_when_all_false(bencher: Bencher, size: usize) {
lit(100i32),
lit(0i32),
);
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand All @@ -278,13 +286,14 @@ fn case_when_fragmented(bencher: Bencher, size: usize) {
],
Some(lit(2i32)),
);
let expr = expr.bind(array.dtype()).unwrap();

bencher
.with_inputs(|| (&expr, &array, SESSION.create_execution_ctx()))
.bench_refs(|(expr, array, ctx)| {
array
.clone()
.apply(expr)
.apply_bound(expr)
.unwrap()
.execute::<Canonical>(ctx)
.unwrap()
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/benches/expr/optimize_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ fn build_or_chain(n: usize) -> Expression {
fn optimize_or_chain(bencher: Bencher, n: usize) {
let expr = build_or_chain(n);
let scope = struct_scope();
bencher.bench(|| expr.optimize_recursive(&scope).unwrap());
let expr = expr.bind(&scope).unwrap();
bencher.bench(|| expr.optimize_recursive().unwrap());
}
10 changes: 5 additions & 5 deletions vortex-array/benches/expr/optimize_predicate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Benchmarks `Expression::optimize_recursive` on lookup-style pushdown predicates:
//! an id membership test (either `list_contains` or a balanced OR of equalities) conjoined
//! with timestamp range bounds and kind filters.
//! Benchmarks bound optimization on lookup-style pushdown predicates: an id membership test
//! (either `list_contains` or a balanced OR of equalities) conjoined with timestamp range bounds
//! and kind filters.

#![expect(clippy::unwrap_used)]

Expand Down Expand Up @@ -207,7 +207,7 @@ fn lookup_predicate(predicate_case: PredicateCase) -> Expression {
#[divan::bench(args = PREDICATE_CASES)]
fn optimize_lookup_predicate(bencher: Bencher, predicate_case: &PredicateCase) {
let scope = scope();
let predicate = lookup_predicate(*predicate_case);
let predicate = lookup_predicate(*predicate_case).bind(&scope).unwrap();

bencher.bench(|| black_box(predicate.optimize_recursive(&scope)));
bencher.bench(|| black_box(predicate.optimize_recursive()));
}
7 changes: 3 additions & 4 deletions vortex-array/src/expr/bound_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::hash::Hasher;
use std::sync::Arc;

use itertools::Itertools;
use smallvec::SmallVec;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_ensure;
Expand Down Expand Up @@ -127,10 +128,8 @@ impl BoundExpression {
children.len()
);

let arg_dtypes = children
.iter()
.map(|child| child.dtype().clone())
.collect_vec();
let arg_dtypes: SmallVec<[DType; 4]> =
children.iter().map(|child| child.dtype().clone()).collect();
let dtype = scalar_fn.return_dtype(&arg_dtypes)?;

Ok(Self::Scalar {
Expand Down
Loading
Loading