diff --git a/lib/src/sparql/eval.rs b/lib/src/sparql/eval.rs index 15419ef5..f3d94637 100644 --- a/lib/src/sparql/eval.rs +++ b/lib/src/sparql/eval.rs @@ -992,31 +992,6 @@ impl SimpleEvaluator { ) }) } - PlanExpression::In(e, l) => { - let e = self.expression_evaluator(e); - let l: Vec<_> = l - .iter() - .map(|possible| self.expression_evaluator(possible)) - .collect(); - Rc::new(move |tuple| { - let needed = e(tuple)?; - let mut error = false; - for possible in &l { - if let Some(possible) = possible(tuple) { - if Some(true) == equals(&needed, &possible) { - return Some(true.into()); - } - } else { - error = true; - } - } - if error { - None - } else { - Some(false.into()) - } - }) - } PlanExpression::Add(a, b) => { let a = self.expression_evaluator(a); let b = self.expression_evaluator(b); diff --git a/lib/src/sparql/plan.rs b/lib/src/sparql/plan.rs index b5fa317b..6291ad43 100644 --- a/lib/src/sparql/plan.rs +++ b/lib/src/sparql/plan.rs @@ -216,7 +216,6 @@ pub enum PlanExpression { GreaterOrEqual(Box, Box), Less(Box, Box), LessOrEqual(Box, Box), - In(Box, Vec), Add(Box, Box), Subtract(Box, Box), Multiply(Box, Box), @@ -400,12 +399,6 @@ impl PlanExpression { e.add_maybe_bound_variables(set); } } - PlanExpression::In(a, bs) => { - a.add_maybe_bound_variables(set); - for b in bs { - b.add_maybe_bound_variables(set); - } - } PlanExpression::Exists(e) => { e.add_maybe_bound_variables(set); } diff --git a/lib/src/sparql/plan_builder.rs b/lib/src/sparql/plan_builder.rs index 09086df6..e52811e4 100644 --- a/lib/src/sparql/plan_builder.rs +++ b/lib/src/sparql/plan_builder.rs @@ -363,10 +363,20 @@ impl<'a> PlanBuilder<'a> { Box::new(self.build_for_expression(a, variables, graph_name)?), Box::new(self.build_for_expression(b, variables, graph_name)?), ), - Expression::In(e, l) => PlanExpression::In( - Box::new(self.build_for_expression(e, variables, graph_name)?), - self.expression_list(l, variables, graph_name)?, - ), + Expression::In(e, l) => { + let e = self.build_for_expression(e, variables, graph_name)?; + l.iter() + .map(|v| { + Ok(PlanExpression::Equal( + Box::new(e.clone()), + Box::new(self.build_for_expression(v, variables, graph_name)?), + )) + }) + .reduce(|a: Result<_, EvaluationError>, b| { + Ok(PlanExpression::Or(Box::new(a?), Box::new(b?))) + }) + .unwrap_or_else(|| Ok(PlanExpression::Constant(false.into())))? + } Expression::Add(a, b) => PlanExpression::Add( Box::new(self.build_for_expression(a, variables, graph_name)?), Box::new(self.build_for_expression(b, variables, graph_name)?),