Skip to content
Merged
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: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ libfuzzer-sys = "0.4"
libloading = "0.8"
liblzma = "0.4"
log = { version = "0.4.21" }
memchr = "2.8.0"
memmap2 = "0.9.5"
mimalloc = "0.1.42"
moka = { version = "0.12.10", default-features = false }
Expand Down Expand Up @@ -215,7 +216,9 @@ quote = "1.0.44"
rand = "0.10.1"
rand_distr = "0.6"
ratatui = { version = "0.30", default-features = false }
regex = "1.11.0"
regex = "1.12"
regex-automata = "0.4"
regex-syntax = "0.8.9"
reqwest = { version = "0.13.0", features = [
"blocking",
"charset",
Expand Down
8 changes: 7 additions & 1 deletion vortex-array/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ arrow-cast = { workspace = true }
arrow-data = { workspace = true }
arrow-schema = { workspace = true, features = ["canonical_extension_types"] }
arrow-select = { workspace = true }
arrow-string = { workspace = true }
async-lock = { workspace = true }
bytes = { workspace = true }
cfg-if = { workspace = true }
Expand All @@ -43,6 +42,7 @@ humansize = { workspace = true }
inventory = { workspace = true }
itertools = { workspace = true }
jiff = { workspace = true }
memchr = { workspace = true }
num-traits = { workspace = true }
num_enum = { workspace = true }
parking_lot = { workspace = true }
Expand All @@ -53,6 +53,8 @@ primitive-types = { workspace = true, optional = true, features = [
] }
prost = { workspace = true }
rand = { workspace = true }
regex = { workspace = true }
regex-syntax = { workspace = true }
rstest = { workspace = true, optional = true }
rstest_reuse = { workspace = true, optional = true }
rustc-hash = { workspace = true }
Expand Down Expand Up @@ -136,6 +138,10 @@ harness = false
name = "kleene_bool"
harness = false

[[bench]]
name = "like"
harness = false

[[bench]]
name = "interleave"
harness = false
Expand Down
122 changes: 122 additions & 0 deletions vortex-array/benches/like.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

#![expect(clippy::unwrap_used)]

use divan::Bencher;
use rand::RngExt;
use rand::SeedableRng;
use rand::distr::Uniform;
use rand::prelude::StdRng;
use vortex_array::ArrayRef;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::BoolArray;
use vortex_array::arrays::ConstantArray;
use vortex_array::arrays::VarBinViewArray;
use vortex_array::arrays::scalar_fn::ScalarFnFactoryExt;
use vortex_array::scalar_fn::fns::like::Like;
use vortex_array::scalar_fn::fns::like::LikeOptions;

fn main() {
divan::main();
}

const ARRAY_SIZE: usize = 2_048;

/// Random lowercase strings of 4..=24 bytes, some with a `hello` infix.
fn strings() -> ArrayRef {
let mut rng = StdRng::seed_from_u64(0);
let len_dist = Uniform::new_inclusive(4usize, 24).unwrap();
VarBinViewArray::from_iter_str((0..ARRAY_SIZE).map(|i| {
let len = rng.sample(len_dist);
let mut s: String = (0..len)
.map(|_| char::from(rng.random_range(b'a'..=b'z')))
.collect();
if i % 7 == 0 {
s.insert_str(len / 2, "hello");
}
s
}))
.into_array()
}

fn bench_like(bencher: Bencher, pattern: &str, options: LikeOptions) {
let session = vortex_array::array_session();
let array = strings();
bencher
.with_inputs(|| {
(
Like.try_new_array(
ARRAY_SIZE,
options,
[
array.clone(),
ConstantArray::new(pattern, ARRAY_SIZE).into_array(),
],
)
.unwrap(),
session.create_execution_ctx(),
)
})
.bench_values(|(array, mut ctx)| array.execute::<BoolArray>(&mut ctx).unwrap());
}

#[divan::bench]
fn like_exact(bencher: Bencher) {
bench_like(bencher, "hello", LikeOptions::default());
}

#[divan::bench]
fn like_prefix(bencher: Bencher) {
bench_like(bencher, "hello%", LikeOptions::default());
}

#[divan::bench]
fn like_suffix(bencher: Bencher) {
bench_like(bencher, "%hello", LikeOptions::default());
}

#[divan::bench]
fn like_contains(bencher: Bencher) {
bench_like(bencher, "%hello%", LikeOptions::default());
}

#[divan::bench]
fn like_regex(bencher: Bencher) {
bench_like(bencher, "h_llo%w%d", LikeOptions::default());
}

#[divan::bench]
fn like_per_row_patterns(bencher: Bencher) {
let session = vortex_array::array_session();
let array = strings();
// A non-constant pattern child takes the per-row path; repeated patterns hit the
// compile cache.
let patterns = VarBinViewArray::from_iter_str((0..ARRAY_SIZE).map(|_| "hello%")).into_array();
bencher
.with_inputs(|| {
(
Like.try_new_array(
ARRAY_SIZE,
LikeOptions::default(),
[array.clone(), patterns.clone()],
)
.unwrap(),
session.create_execution_ctx(),
)
})
.bench_values(|(array, mut ctx)| array.execute::<BoolArray>(&mut ctx).unwrap());
}

#[divan::bench]
fn ilike_contains(bencher: Bencher) {
bench_like(
bencher,
"%HELLO%",
LikeOptions {
negated: false,
case_insensitive: true,
},
);
}
Loading
Loading