Skip to content

Commit

Permalink
Make bind consuming (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr authored Dec 5, 2024
1 parent a07bdfc commit d07a7e1
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions partiql-eval/src/eval/expr/coll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) enum EvalCollFn {

impl BindEvalExpr for EvalCollFn {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
fn create<const STRICT: bool, F>(
Expand Down Expand Up @@ -70,7 +70,7 @@ impl BindEvalExpr for EvalCollFn {
PartiqlShapeBuilder::init_or_get().new_static(Static::Bag(BagType::new_any())),
])];

match *self {
match self {
EvalCollFn::Count(setq) => {
create::<{ STRICT }, _>(any_elems, args, move |it| it.coll_count(setq))
}
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/eval/expr/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) enum EvalExtractFn {

impl BindEvalExpr for EvalExtractFn {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions partiql-eval/src/eval/expr/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use std::ops::ControlFlow;

impl BindEvalExpr for ScalarFnCallSpec {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let plan = self.output.clone();
let plan = self.output;
Ok(Box::new(EvalExprFnScalar::<{ STRICT }> { plan, args }))
}
}
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/eval/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub enum BindError {
/// A trait for binding an expression to its arguments into an `EvalExpr`
pub trait BindEvalExpr: Debug {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError>;
}
14 changes: 7 additions & 7 deletions partiql-eval/src/eval/expr/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Debug for EvalLitExpr {

impl BindEvalExpr for EvalLitExpr {
fn bind<const STRICT: bool>(
&self,
self,
_args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
Ok(Box::new(self.clone()))
Expand Down Expand Up @@ -77,7 +77,7 @@ pub(crate) enum EvalOpUnary {

impl BindEvalExpr for EvalOpUnary {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let any_num = PartiqlShapeBuilder::init_or_get().any_of(type_numeric!());
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<const STRICT: bool, OnMissing: ArgShortCircuit> ArgChecker
impl BindEvalExpr for EvalOpBinary {
#[inline]
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
type AndCheck = BoolShortCircuitArgChecker<false, PropagateNull<false>>;
Expand Down Expand Up @@ -345,7 +345,7 @@ pub(crate) struct EvalBetweenExpr {}

impl BindEvalExpr for EvalBetweenExpr {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let types = [type_dynamic!(), type_dynamic!(), type_dynamic!()];
Expand All @@ -363,7 +363,7 @@ pub(crate) struct EvalFnExists {}

impl BindEvalExpr for EvalFnExists {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
UnaryValueExpr::create_with_any::<{ STRICT }, _>(args, |v| {
Expand All @@ -383,7 +383,7 @@ pub(crate) struct EvalFnAbs {}

impl BindEvalExpr for EvalFnAbs {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let nums = PartiqlShapeBuilder::init_or_get().any_of(type_numeric!());
Expand All @@ -404,7 +404,7 @@ pub(crate) struct EvalFnCardinality {}

impl BindEvalExpr for EvalFnCardinality {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let shape_builder = PartiqlShapeBuilder::init_or_get();
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/eval/expr/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub(crate) enum EvalVarRef {

impl BindEvalExpr for EvalVarRef {
fn bind<const STRICT: bool>(
&self,
self,
_: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
Ok(match self {
Expand Down
4 changes: 2 additions & 2 deletions partiql-eval/src/eval/expr/pattern_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl EvalLikeMatch {

impl BindEvalExpr for EvalLikeMatch {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let pattern = self.pattern.clone();
Expand All @@ -63,7 +63,7 @@ pub(crate) struct EvalLikeNonStringNonLiteralMatch {}

impl BindEvalExpr for EvalLikeNonStringNonLiteralMatch {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let types = [type_string!(), type_string!(), type_string!()];
Expand Down
10 changes: 5 additions & 5 deletions partiql-eval/src/eval/expr/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) enum EvalStringFn {
impl BindEvalExpr for EvalStringFn {
#[inline]
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
#[inline]
Expand Down Expand Up @@ -69,7 +69,7 @@ pub(crate) enum EvalTrimFn {

impl BindEvalExpr for EvalTrimFn {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
let create = |f: for<'a> fn(&'a str, &'a str) -> &'a str| {
Expand Down Expand Up @@ -107,7 +107,7 @@ pub(crate) struct EvalFnPosition {}

impl BindEvalExpr for EvalFnPosition {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
BinaryValueExpr::create_typed::<STRICT, _>(
Expand All @@ -129,7 +129,7 @@ pub(crate) struct EvalFnSubstring {}

impl BindEvalExpr for EvalFnSubstring {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
match args.len() {
Expand Down Expand Up @@ -179,7 +179,7 @@ pub(crate) struct EvalFnOverlay {}

impl BindEvalExpr for EvalFnOverlay {
fn bind<const STRICT: bool>(
&self,
self,
args: Vec<Box<dyn EvalExpr>>,
) -> Result<Box<dyn EvalExpr>, BindError> {
fn overlay(value: &str, replacement: &str, offset: i64, length: usize) -> Value {
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ impl<'c> EvaluatorPlanner<'c> {

Ok(Box::new(ErrorNode::new()) as Box<dyn EvalExpr>)
}
Some(overload) => overload.bind::<{ STRICT }>(args),
Some(overload) => overload.clone().bind::<{ STRICT }>(args),
}
}
FunctionEntryFunction::Aggregate() => {
Expand Down

1 comment on commit d07a7e1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PartiQL (rust) Benchmark

Benchmark suite Current: d07a7e1 Previous: a07bdfc Ratio
arith_agg-avg 770065 ns/iter (± 6886) 765417 ns/iter (± 9720) 1.01
arith_agg-avg_distinct 856721 ns/iter (± 3282) 857628 ns/iter (± 2290) 1.00
arith_agg-count 815223 ns/iter (± 14799) 823325 ns/iter (± 14147) 0.99
arith_agg-count_distinct 858669 ns/iter (± 4273) 849976 ns/iter (± 1321) 1.01
arith_agg-min 821056 ns/iter (± 2841) 825972 ns/iter (± 45164) 0.99
arith_agg-min_distinct 854399 ns/iter (± 4373) 852656 ns/iter (± 2511) 1.00
arith_agg-max 825900 ns/iter (± 41288) 830428 ns/iter (± 5999) 0.99
arith_agg-max_distinct 861984 ns/iter (± 2669) 860720 ns/iter (± 30809) 1.00
arith_agg-sum 821892 ns/iter (± 6469) 826283 ns/iter (± 12568) 0.99
arith_agg-sum_distinct 860284 ns/iter (± 2356) 856047 ns/iter (± 5027) 1.00
arith_agg-avg-count-min-max-sum 973599 ns/iter (± 2729) 995733 ns/iter (± 12537) 0.98
arith_agg-avg-count-min-max-sum-group_by 1226677 ns/iter (± 16934) 1221238 ns/iter (± 30151) 1.00
arith_agg-avg-count-min-max-sum-group_by-group_as 1852614 ns/iter (± 6514) 1843394 ns/iter (± 7066) 1.01
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct 1224367 ns/iter (± 13913) 1202863 ns/iter (± 32389) 1.02
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by 1500889 ns/iter (± 19101) 1478093 ns/iter (± 36300) 1.02
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as 2096925 ns/iter (± 9815) 2072542 ns/iter (± 9664) 1.01
parse-1 6086 ns/iter (± 14) 6165 ns/iter (± 25) 0.99
parse-15 50565 ns/iter (± 77) 51563 ns/iter (± 204) 0.98
parse-30 98481 ns/iter (± 429) 98311 ns/iter (± 355) 1.00
compile-1 4280 ns/iter (± 12) 4246 ns/iter (± 34) 1.01
compile-15 30186 ns/iter (± 115) 30444 ns/iter (± 118) 0.99
compile-30 63029 ns/iter (± 238) 63588 ns/iter (± 140) 0.99
plan-1 71625 ns/iter (± 271) 70683 ns/iter (± 180) 1.01
plan-15 1124229 ns/iter (± 10520) 1101877 ns/iter (± 15617) 1.02
plan-30 2253137 ns/iter (± 14872) 2204988 ns/iter (± 16988) 1.02
eval-1 11911863 ns/iter (± 111520) 11996073 ns/iter (± 261515) 0.99
eval-15 77114178 ns/iter (± 293901) 76529036 ns/iter (± 455327) 1.01
eval-30 147487722 ns/iter (± 486288) 146551997 ns/iter (± 516782) 1.01
join 9733 ns/iter (± 187) 9914 ns/iter (± 122) 0.98
simple 2542 ns/iter (± 44) 2486 ns/iter (± 6) 1.02
simple-no 481 ns/iter (± 1) 460 ns/iter (± 1) 1.05
numbers 57 ns/iter (± 0) 57 ns/iter (± 0) 1
parse-simple 941 ns/iter (± 4) 961 ns/iter (± 4) 0.98
parse-ion 2598 ns/iter (± 15) 2621 ns/iter (± 5) 0.99
parse-group 8131 ns/iter (± 26) 7912 ns/iter (± 24) 1.03
parse-complex 20806 ns/iter (± 57) 20359 ns/iter (± 197) 1.02
parse-complex-fexpr 28512 ns/iter (± 2711) 27825 ns/iter (± 93) 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.