Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copr: improve in performance using lookup set in metadata #6000

Merged
merged 10 commits into from Nov 27, 2019
45 changes: 0 additions & 45 deletions components/tidb_query/src/rpn_expr/impl_compare.rs
Expand Up @@ -207,32 +207,6 @@ pub fn coalesce<T: Evaluable>(args: &[&Option<T>]) -> Result<Option<T>> {
Ok(None)
}

#[rpn_fn(varg, min_args = 1)]
#[inline]
pub fn compare_in<T: Evaluable + Eq>(args: &[&Option<T>]) -> Result<Option<Int>> {
assert!(!args.is_empty());
let base_val = args[0];
match base_val {
None => Ok(None),
Some(base_val) => {
let mut default_ret = Some(0);
for arg in &args[1..] {
match arg {
None => {
default_ret = None;
}
Some(v) => {
if v == base_val {
return Ok(Some(1));
}
}
}
}
Ok(default_ret)
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -666,23 +640,4 @@ mod tests {
assert_eq!(output, expected);
}
}

#[test]
fn test_in() {
let cases = vec![
(vec![Some(1)], Some(0)),
(vec![Some(1), Some(2)], Some(0)),
(vec![Some(1), Some(2), Some(1)], Some(1)),
(vec![Some(1), Some(2), None], None),
(vec![Some(1), Some(2), None, Some(1)], Some(1)),
(vec![None, Some(2), Some(1)], None),
];
for (args, expected) in cases {
let output = RpnFnScalarEvaluator::new()
.push_params(args)
.evaluate(ScalarFuncSig::InInt)
.unwrap();
assert_eq!(output, expected);
}
}
}