|
|
@ -495,7 +495,7 @@ impl SimpleEvaluator { |
|
|
|
stat_children.push(left_stats); |
|
|
|
stat_children.push(left_stats); |
|
|
|
let (right, right_stats) = self.plan_evaluator(right.clone()); |
|
|
|
let (right, right_stats) = self.plan_evaluator(right.clone()); |
|
|
|
stat_children.push(right_stats); |
|
|
|
stat_children.push(right_stats); |
|
|
|
let expression = self.expression_evaluator(expression); |
|
|
|
let expression = self.expression_evaluator(expression, &mut stat_children); |
|
|
|
// Real hash join
|
|
|
|
// Real hash join
|
|
|
|
Rc::new(move |from| { |
|
|
|
Rc::new(move |from| { |
|
|
|
let mut errors = Vec::default(); |
|
|
|
let mut errors = Vec::default(); |
|
|
@ -547,7 +547,7 @@ impl SimpleEvaluator { |
|
|
|
PlanNode::Filter { child, expression } => { |
|
|
|
PlanNode::Filter { child, expression } => { |
|
|
|
let (child, child_stats) = self.plan_evaluator(child.clone()); |
|
|
|
let (child, child_stats) = self.plan_evaluator(child.clone()); |
|
|
|
stat_children.push(child_stats); |
|
|
|
stat_children.push(child_stats); |
|
|
|
let expression = self.expression_evaluator(expression); |
|
|
|
let expression = self.expression_evaluator(expression, &mut stat_children); |
|
|
|
Rc::new(move |from| { |
|
|
|
Rc::new(move |from| { |
|
|
|
let expression = expression.clone(); |
|
|
|
let expression = expression.clone(); |
|
|
|
Box::new(child(from).filter(move |tuple| { |
|
|
|
Box::new(child(from).filter(move |tuple| { |
|
|
@ -586,7 +586,7 @@ impl SimpleEvaluator { |
|
|
|
let (child, child_stats) = self.plan_evaluator(child.clone()); |
|
|
|
let (child, child_stats) = self.plan_evaluator(child.clone()); |
|
|
|
stat_children.push(child_stats); |
|
|
|
stat_children.push(child_stats); |
|
|
|
let position = variable.encoded; |
|
|
|
let position = variable.encoded; |
|
|
|
let expression = self.expression_evaluator(expression); |
|
|
|
let expression = self.expression_evaluator(expression, &mut stat_children); |
|
|
|
Rc::new(move |from| { |
|
|
|
Rc::new(move |from| { |
|
|
|
let expression = expression.clone(); |
|
|
|
let expression = expression.clone(); |
|
|
|
Box::new(child(from).map(move |tuple| { |
|
|
|
Box::new(child(from).map(move |tuple| { |
|
|
@ -604,12 +604,12 @@ impl SimpleEvaluator { |
|
|
|
let by: Vec<_> = by |
|
|
|
let by: Vec<_> = by |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.map(|comp| match comp { |
|
|
|
.map(|comp| match comp { |
|
|
|
Comparator::Asc(expression) => { |
|
|
|
Comparator::Asc(expression) => ComparatorFunction::Asc( |
|
|
|
ComparatorFunction::Asc(self.expression_evaluator(expression)) |
|
|
|
self.expression_evaluator(expression, &mut stat_children), |
|
|
|
} |
|
|
|
), |
|
|
|
Comparator::Desc(expression) => { |
|
|
|
Comparator::Desc(expression) => ComparatorFunction::Desc( |
|
|
|
ComparatorFunction::Desc(self.expression_evaluator(expression)) |
|
|
|
self.expression_evaluator(expression, &mut stat_children), |
|
|
|
} |
|
|
|
), |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(); |
|
|
|
.collect(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
@ -733,7 +733,7 @@ impl SimpleEvaluator { |
|
|
|
aggregate |
|
|
|
aggregate |
|
|
|
.parameter |
|
|
|
.parameter |
|
|
|
.as_ref() |
|
|
|
.as_ref() |
|
|
|
.map(|p| self.expression_evaluator(p)) |
|
|
|
.map(|p| self.expression_evaluator(p, &mut stat_children)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(); |
|
|
|
.collect(); |
|
|
|
let accumulator_builders: Vec<_> = aggregates |
|
|
|
let accumulator_builders: Vec<_> = aggregates |
|
|
@ -933,6 +933,7 @@ impl SimpleEvaluator { |
|
|
|
fn expression_evaluator( |
|
|
|
fn expression_evaluator( |
|
|
|
&self, |
|
|
|
&self, |
|
|
|
expression: &PlanExpression, |
|
|
|
expression: &PlanExpression, |
|
|
|
|
|
|
|
stat_children: &mut Vec<Rc<PlanNodeWithStats>>, |
|
|
|
) -> Rc<dyn Fn(&EncodedTuple) -> Option<EncodedTerm>> { |
|
|
|
) -> Rc<dyn Fn(&EncodedTuple) -> Option<EncodedTerm>> { |
|
|
|
match expression { |
|
|
|
match expression { |
|
|
|
PlanExpression::NamedNode(t) => { |
|
|
|
PlanExpression::NamedNode(t) => { |
|
|
@ -948,12 +949,13 @@ impl SimpleEvaluator { |
|
|
|
Rc::new(move |tuple| tuple.get(v).cloned()) |
|
|
|
Rc::new(move |tuple| tuple.get(v).cloned()) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Exists(plan) => { |
|
|
|
PlanExpression::Exists(plan) => { |
|
|
|
let (eval, _) = self.plan_evaluator(plan.clone()); //TODO: stats
|
|
|
|
let (eval, stats) = self.plan_evaluator(plan.clone()); |
|
|
|
|
|
|
|
stat_children.push(stats); |
|
|
|
Rc::new(move |tuple| Some(eval(tuple.clone()).next().is_some().into())) |
|
|
|
Rc::new(move |tuple| Some(eval(tuple.clone()).next().is_some().into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Or(a, b) => { |
|
|
|
PlanExpression::Or(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new(move |tuple| match a(tuple).and_then(|v| to_bool(&v)) { |
|
|
|
Rc::new(move |tuple| match a(tuple).and_then(|v| to_bool(&v)) { |
|
|
|
Some(true) => Some(true.into()), |
|
|
|
Some(true) => Some(true.into()), |
|
|
|
Some(false) => b(tuple), |
|
|
|
Some(false) => b(tuple), |
|
|
@ -967,8 +969,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::And(a, b) => { |
|
|
|
PlanExpression::And(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new(move |tuple| match a(tuple).and_then(|v| to_bool(&v)) { |
|
|
|
Rc::new(move |tuple| match a(tuple).and_then(|v| to_bool(&v)) { |
|
|
|
Some(true) => b(tuple), |
|
|
|
Some(true) => b(tuple), |
|
|
|
Some(false) => Some(false.into()), |
|
|
|
Some(false) => Some(false.into()), |
|
|
@ -982,13 +984,13 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Equal(a, b) => { |
|
|
|
PlanExpression::Equal(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new(move |tuple| equals(&a(tuple)?, &b(tuple)?).map(|v| v.into())) |
|
|
|
Rc::new(move |tuple| equals(&a(tuple)?, &b(tuple)?).map(|v| v.into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Greater(a, b) => { |
|
|
|
PlanExpression::Greater(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some( |
|
|
|
Some( |
|
|
@ -998,8 +1000,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::GreaterOrEqual(a, b) => { |
|
|
|
PlanExpression::GreaterOrEqual(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some( |
|
|
|
Some( |
|
|
@ -1012,16 +1014,16 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Less(a, b) => { |
|
|
|
PlanExpression::Less(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some((partial_cmp(&dataset, &a(tuple)?, &b(tuple)?)? == Ordering::Less).into()) |
|
|
|
Some((partial_cmp(&dataset, &a(tuple)?, &b(tuple)?)? == Ordering::Less).into()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::LessOrEqual(a, b) => { |
|
|
|
PlanExpression::LessOrEqual(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some( |
|
|
|
Some( |
|
|
@ -1034,8 +1036,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Add(a, b) => { |
|
|
|
PlanExpression::Add(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new( |
|
|
|
Rc::new( |
|
|
|
move |tuple| match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
move |tuple| match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
NumericBinaryOperands::Float(v1, v2) => Some((v1 + v2).into()), |
|
|
|
NumericBinaryOperands::Float(v1, v2) => Some((v1 + v2).into()), |
|
|
@ -1078,8 +1080,8 @@ impl SimpleEvaluator { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Subtract(a, b) => { |
|
|
|
PlanExpression::Subtract(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some(match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
Some(match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
NumericBinaryOperands::Float(v1, v2) => (v1 - v2).into(), |
|
|
|
NumericBinaryOperands::Float(v1, v2) => (v1 - v2).into(), |
|
|
@ -1130,8 +1132,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Multiply(a, b) => { |
|
|
|
PlanExpression::Multiply(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new( |
|
|
|
Rc::new( |
|
|
|
move |tuple| match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
move |tuple| match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
NumericBinaryOperands::Float(v1, v2) => Some((v1 * v2).into()), |
|
|
|
NumericBinaryOperands::Float(v1, v2) => Some((v1 * v2).into()), |
|
|
@ -1143,8 +1145,8 @@ impl SimpleEvaluator { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Divide(a, b) => { |
|
|
|
PlanExpression::Divide(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new( |
|
|
|
Rc::new( |
|
|
|
move |tuple| match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
move |tuple| match NumericBinaryOperands::new(a(tuple)?, b(tuple)?)? { |
|
|
|
NumericBinaryOperands::Float(v1, v2) => Some((v1 / v2).into()), |
|
|
|
NumericBinaryOperands::Float(v1, v2) => Some((v1 / v2).into()), |
|
|
@ -1158,7 +1160,7 @@ impl SimpleEvaluator { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::UnaryPlus(e) => { |
|
|
|
PlanExpression::UnaryPlus(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DoubleLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DoubleLiteral(value) => Some(value.into()), |
|
|
@ -1171,7 +1173,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::UnaryMinus(e) => { |
|
|
|
PlanExpression::UnaryMinus(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::FloatLiteral(value) => Some((-value).into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some((-value).into()), |
|
|
|
EncodedTerm::DoubleLiteral(value) => Some((-value).into()), |
|
|
|
EncodedTerm::DoubleLiteral(value) => Some((-value).into()), |
|
|
@ -1184,11 +1186,11 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Not(e) => { |
|
|
|
PlanExpression::Not(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| to_bool(&e(tuple)?).map(|v| (!v).into())) |
|
|
|
Rc::new(move |tuple| to_bool(&e(tuple)?).map(|v| (!v).into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Str(e) | PlanExpression::StringCast(e) => { |
|
|
|
PlanExpression::Str(e) | PlanExpression::StringCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some(build_string_literal_from_id(to_string_id( |
|
|
|
Some(build_string_literal_from_id(to_string_id( |
|
|
@ -1198,7 +1200,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Lang(e) => { |
|
|
|
PlanExpression::Lang(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::SmallSmallLangStringLiteral { language, .. } |
|
|
|
EncodedTerm::SmallSmallLangStringLiteral { language, .. } |
|
|
@ -1214,8 +1216,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::LangMatches(language_tag, language_range) => { |
|
|
|
PlanExpression::LangMatches(language_tag, language_range) => { |
|
|
|
let language_tag = self.expression_evaluator(language_tag); |
|
|
|
let language_tag = self.expression_evaluator(language_tag, stat_children); |
|
|
|
let language_range = self.expression_evaluator(language_range); |
|
|
|
let language_range = self.expression_evaluator(language_range, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let mut language_tag = to_simple_string(&dataset, &language_tag(tuple)?)?; |
|
|
|
let mut language_tag = to_simple_string(&dataset, &language_tag(tuple)?)?; |
|
|
@ -1240,7 +1242,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Datatype(e) => { |
|
|
|
PlanExpression::Datatype(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| datatype(&dataset, &e(tuple)?)) |
|
|
|
Rc::new(move |tuple| datatype(&dataset, &e(tuple)?)) |
|
|
|
} |
|
|
|
} |
|
|
@ -1249,7 +1251,7 @@ impl SimpleEvaluator { |
|
|
|
Rc::new(move |tuple| Some(tuple.contains(v).into())) |
|
|
|
Rc::new(move |tuple| Some(tuple.contains(v).into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Iri(e) => { |
|
|
|
PlanExpression::Iri(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let base_iri = self.base_iri.clone(); |
|
|
|
let base_iri = self.base_iri.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
@ -1273,7 +1275,7 @@ impl SimpleEvaluator { |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::BNode(id) => match id { |
|
|
|
PlanExpression::BNode(id) => match id { |
|
|
|
Some(id) => { |
|
|
|
Some(id) => { |
|
|
|
let id = self.expression_evaluator(id); |
|
|
|
let id = self.expression_evaluator(id, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some( |
|
|
|
Some( |
|
|
@ -1293,7 +1295,7 @@ impl SimpleEvaluator { |
|
|
|
}, |
|
|
|
}, |
|
|
|
PlanExpression::Rand => Rc::new(|_| Some(random::<f64>().into())), |
|
|
|
PlanExpression::Rand => Rc::new(|_| Some(random::<f64>().into())), |
|
|
|
PlanExpression::Abs(e) => { |
|
|
|
PlanExpression::Abs(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.abs().into()), |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.abs().into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.abs().into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.abs().into()), |
|
|
@ -1303,7 +1305,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Ceil(e) => { |
|
|
|
PlanExpression::Ceil(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.ceil().into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.ceil().into()), |
|
|
@ -1313,7 +1315,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Floor(e) => { |
|
|
|
PlanExpression::Floor(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.floor().into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.floor().into()), |
|
|
@ -1323,7 +1325,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Round(e) => { |
|
|
|
PlanExpression::Round(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.round().into()), |
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.round().into()), |
|
|
@ -1333,7 +1335,10 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Concat(l) => { |
|
|
|
PlanExpression::Concat(l) => { |
|
|
|
let l: Vec<_> = l.iter().map(|e| self.expression_evaluator(e)).collect(); |
|
|
|
let l: Vec<_> = l |
|
|
|
|
|
|
|
.iter() |
|
|
|
|
|
|
|
.map(|e| self.expression_evaluator(e, stat_children)) |
|
|
|
|
|
|
|
.collect(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let mut result = String::default(); |
|
|
|
let mut result = String::default(); |
|
|
@ -1357,9 +1362,11 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::SubStr(source, starting_loc, length) => { |
|
|
|
PlanExpression::SubStr(source, starting_loc, length) => { |
|
|
|
let source = self.expression_evaluator(source); |
|
|
|
let source = self.expression_evaluator(source, stat_children); |
|
|
|
let starting_loc = self.expression_evaluator(starting_loc); |
|
|
|
let starting_loc = self.expression_evaluator(starting_loc, stat_children); |
|
|
|
let length = length.as_ref().map(|l| self.expression_evaluator(l)); |
|
|
|
let length = length |
|
|
|
|
|
|
|
.as_ref() |
|
|
|
|
|
|
|
.map(|l| self.expression_evaluator(l, stat_children)); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (source, language) = to_string_and_language(&dataset, &source(tuple)?)?; |
|
|
|
let (source, language) = to_string_and_language(&dataset, &source(tuple)?)?; |
|
|
@ -1403,16 +1410,16 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StrLen(arg) => { |
|
|
|
PlanExpression::StrLen(arg) => { |
|
|
|
let arg = self.expression_evaluator(arg); |
|
|
|
let arg = self.expression_evaluator(arg, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some((to_string(&dataset, &arg(tuple)?)?.chars().count() as i64).into()) |
|
|
|
Some((to_string(&dataset, &arg(tuple)?)?.chars().count() as i64).into()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StaticReplace(arg, regex, replacement) => { |
|
|
|
PlanExpression::StaticReplace(arg, regex, replacement) => { |
|
|
|
let arg = self.expression_evaluator(arg); |
|
|
|
let arg = self.expression_evaluator(arg, stat_children); |
|
|
|
let regex = regex.clone(); |
|
|
|
let regex = regex.clone(); |
|
|
|
let replacement = self.expression_evaluator(replacement); |
|
|
|
let replacement = self.expression_evaluator(replacement, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (text, language) = to_string_and_language(&dataset, &arg(tuple)?)?; |
|
|
|
let (text, language) = to_string_and_language(&dataset, &arg(tuple)?)?; |
|
|
@ -1425,10 +1432,12 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DynamicReplace(arg, pattern, replacement, flags) => { |
|
|
|
PlanExpression::DynamicReplace(arg, pattern, replacement, flags) => { |
|
|
|
let arg = self.expression_evaluator(arg); |
|
|
|
let arg = self.expression_evaluator(arg, stat_children); |
|
|
|
let pattern = self.expression_evaluator(pattern); |
|
|
|
let pattern = self.expression_evaluator(pattern, stat_children); |
|
|
|
let replacement = self.expression_evaluator(replacement); |
|
|
|
let replacement = self.expression_evaluator(replacement, stat_children); |
|
|
|
let flags = flags.as_ref().map(|flags| self.expression_evaluator(flags)); |
|
|
|
let flags = flags |
|
|
|
|
|
|
|
.as_ref() |
|
|
|
|
|
|
|
.map(|flags| self.expression_evaluator(flags, stat_children)); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let pattern = to_simple_string(&dataset, &pattern(tuple)?)?; |
|
|
|
let pattern = to_simple_string(&dataset, &pattern(tuple)?)?; |
|
|
@ -1448,7 +1457,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::UCase(e) => { |
|
|
|
PlanExpression::UCase(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (value, language) = to_string_and_language(&dataset, &e(tuple)?)?; |
|
|
|
let (value, language) = to_string_and_language(&dataset, &e(tuple)?)?; |
|
|
@ -1460,7 +1469,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::LCase(e) => { |
|
|
|
PlanExpression::LCase(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (value, language) = to_string_and_language(&dataset, &e(tuple)?)?; |
|
|
|
let (value, language) = to_string_and_language(&dataset, &e(tuple)?)?; |
|
|
@ -1472,8 +1481,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StrStarts(arg1, arg2) => { |
|
|
|
PlanExpression::StrStarts(arg1, arg2) => { |
|
|
|
let arg1 = self.expression_evaluator(arg1); |
|
|
|
let arg1 = self.expression_evaluator(arg1, stat_children); |
|
|
|
let arg2 = self.expression_evaluator(arg2); |
|
|
|
let arg2 = self.expression_evaluator(arg2, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (arg1, arg2, _) = |
|
|
|
let (arg1, arg2, _) = |
|
|
@ -1482,7 +1491,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::EncodeForUri(ltrl) => { |
|
|
|
PlanExpression::EncodeForUri(ltrl) => { |
|
|
|
let ltrl = self.expression_evaluator(ltrl); |
|
|
|
let ltrl = self.expression_evaluator(ltrl, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let ltlr = to_string(&dataset, <rl(tuple)?)?; |
|
|
|
let ltlr = to_string(&dataset, <rl(tuple)?)?; |
|
|
@ -1516,8 +1525,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StrEnds(arg1, arg2) => { |
|
|
|
PlanExpression::StrEnds(arg1, arg2) => { |
|
|
|
let arg1 = self.expression_evaluator(arg1); |
|
|
|
let arg1 = self.expression_evaluator(arg1, stat_children); |
|
|
|
let arg2 = self.expression_evaluator(arg2); |
|
|
|
let arg2 = self.expression_evaluator(arg2, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (arg1, arg2, _) = |
|
|
|
let (arg1, arg2, _) = |
|
|
@ -1526,8 +1535,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Contains(arg1, arg2) => { |
|
|
|
PlanExpression::Contains(arg1, arg2) => { |
|
|
|
let arg1 = self.expression_evaluator(arg1); |
|
|
|
let arg1 = self.expression_evaluator(arg1, stat_children); |
|
|
|
let arg2 = self.expression_evaluator(arg2); |
|
|
|
let arg2 = self.expression_evaluator(arg2, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (arg1, arg2, _) = |
|
|
|
let (arg1, arg2, _) = |
|
|
@ -1536,8 +1545,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StrBefore(arg1, arg2) => { |
|
|
|
PlanExpression::StrBefore(arg1, arg2) => { |
|
|
|
let arg1 = self.expression_evaluator(arg1); |
|
|
|
let arg1 = self.expression_evaluator(arg1, stat_children); |
|
|
|
let arg2 = self.expression_evaluator(arg2); |
|
|
|
let arg2 = self.expression_evaluator(arg2, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (arg1, arg2, language) = |
|
|
|
let (arg1, arg2, language) = |
|
|
@ -1550,8 +1559,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StrAfter(arg1, arg2) => { |
|
|
|
PlanExpression::StrAfter(arg1, arg2) => { |
|
|
|
let arg1 = self.expression_evaluator(arg1); |
|
|
|
let arg1 = self.expression_evaluator(arg1, stat_children); |
|
|
|
let arg2 = self.expression_evaluator(arg2); |
|
|
|
let arg2 = self.expression_evaluator(arg2, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let (arg1, arg2, language) = |
|
|
|
let (arg1, arg2, language) = |
|
|
@ -1564,7 +1573,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Year(e) => { |
|
|
|
PlanExpression::Year(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.year().into()), |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.year().into()), |
|
|
|
EncodedTerm::DateLiteral(date) => Some(date.year().into()), |
|
|
|
EncodedTerm::DateLiteral(date) => Some(date.year().into()), |
|
|
@ -1574,7 +1583,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Month(e) => { |
|
|
|
PlanExpression::Month(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.month().into()), |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.month().into()), |
|
|
|
EncodedTerm::DateLiteral(date) => Some(date.month().into()), |
|
|
|
EncodedTerm::DateLiteral(date) => Some(date.month().into()), |
|
|
@ -1585,7 +1594,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Day(e) => { |
|
|
|
PlanExpression::Day(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.day().into()), |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.day().into()), |
|
|
|
EncodedTerm::DateLiteral(date) => Some(date.day().into()), |
|
|
|
EncodedTerm::DateLiteral(date) => Some(date.day().into()), |
|
|
@ -1595,7 +1604,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Hours(e) => { |
|
|
|
PlanExpression::Hours(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.hour().into()), |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.hour().into()), |
|
|
|
EncodedTerm::TimeLiteral(time) => Some(time.hour().into()), |
|
|
|
EncodedTerm::TimeLiteral(time) => Some(time.hour().into()), |
|
|
@ -1603,7 +1612,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Minutes(e) => { |
|
|
|
PlanExpression::Minutes(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.minute().into()), |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.minute().into()), |
|
|
|
EncodedTerm::TimeLiteral(time) => Some(time.minute().into()), |
|
|
|
EncodedTerm::TimeLiteral(time) => Some(time.minute().into()), |
|
|
@ -1611,7 +1620,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Seconds(e) => { |
|
|
|
PlanExpression::Seconds(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.second().into()), |
|
|
|
EncodedTerm::DateTimeLiteral(date_time) => Some(date_time.second().into()), |
|
|
|
EncodedTerm::TimeLiteral(time) => Some(time.second().into()), |
|
|
|
EncodedTerm::TimeLiteral(time) => Some(time.second().into()), |
|
|
@ -1619,7 +1628,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Timezone(e) => { |
|
|
|
PlanExpression::Timezone(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some( |
|
|
|
Some( |
|
|
|
match e(tuple)? { |
|
|
|
match e(tuple)? { |
|
|
@ -1638,7 +1647,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Tz(e) => { |
|
|
|
PlanExpression::Tz(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let timezone_offset = match e(tuple)? { |
|
|
|
let timezone_offset = match e(tuple)? { |
|
|
@ -1662,8 +1671,8 @@ impl SimpleEvaluator { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PlanExpression::Adjust(dt, tz) => { |
|
|
|
PlanExpression::Adjust(dt, tz) => { |
|
|
|
let dt = self.expression_evaluator(dt); |
|
|
|
let dt = self.expression_evaluator(dt, stat_children); |
|
|
|
let tz = self.expression_evaluator(tz); |
|
|
|
let tz = self.expression_evaluator(tz, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let timezone_offset = Some( |
|
|
|
let timezone_offset = Some( |
|
|
|
match tz(tuple)? { |
|
|
|
match tz(tuple)? { |
|
|
@ -1713,13 +1722,16 @@ impl SimpleEvaluator { |
|
|
|
Some(build_string_literal(&dataset, &buffer)) |
|
|
|
Some(build_string_literal(&dataset, &buffer)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Md5(arg) => self.hash::<Md5>(arg), |
|
|
|
PlanExpression::Md5(arg) => self.hash::<Md5>(arg, stat_children), |
|
|
|
PlanExpression::Sha1(arg) => self.hash::<Sha1>(arg), |
|
|
|
PlanExpression::Sha1(arg) => self.hash::<Sha1>(arg, stat_children), |
|
|
|
PlanExpression::Sha256(arg) => self.hash::<Sha256>(arg), |
|
|
|
PlanExpression::Sha256(arg) => self.hash::<Sha256>(arg, stat_children), |
|
|
|
PlanExpression::Sha384(arg) => self.hash::<Sha384>(arg), |
|
|
|
PlanExpression::Sha384(arg) => self.hash::<Sha384>(arg, stat_children), |
|
|
|
PlanExpression::Sha512(arg) => self.hash::<Sha512>(arg), |
|
|
|
PlanExpression::Sha512(arg) => self.hash::<Sha512>(arg, stat_children), |
|
|
|
PlanExpression::Coalesce(l) => { |
|
|
|
PlanExpression::Coalesce(l) => { |
|
|
|
let l: Vec<_> = l.iter().map(|e| self.expression_evaluator(e)).collect(); |
|
|
|
let l: Vec<_> = l |
|
|
|
|
|
|
|
.iter() |
|
|
|
|
|
|
|
.map(|e| self.expression_evaluator(e, stat_children)) |
|
|
|
|
|
|
|
.collect(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
for e in &l { |
|
|
|
for e in &l { |
|
|
|
if let Some(result) = e(tuple) { |
|
|
|
if let Some(result) = e(tuple) { |
|
|
@ -1730,9 +1742,9 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::If(a, b, c) => { |
|
|
|
PlanExpression::If(a, b, c) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
let c = self.expression_evaluator(c); |
|
|
|
let c = self.expression_evaluator(c, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
if to_bool(&a(tuple)?)? { |
|
|
|
if to_bool(&a(tuple)?)? { |
|
|
|
b(tuple) |
|
|
|
b(tuple) |
|
|
@ -1742,8 +1754,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StrLang(lexical_form, lang_tag) => { |
|
|
|
PlanExpression::StrLang(lexical_form, lang_tag) => { |
|
|
|
let lexical_form = self.expression_evaluator(lexical_form); |
|
|
|
let lexical_form = self.expression_evaluator(lexical_form, stat_children); |
|
|
|
let lang_tag = self.expression_evaluator(lang_tag); |
|
|
|
let lang_tag = self.expression_evaluator(lang_tag, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some(build_lang_string_literal_from_id( |
|
|
|
Some(build_lang_string_literal_from_id( |
|
|
@ -1753,8 +1765,8 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StrDt(lexical_form, datatype) => { |
|
|
|
PlanExpression::StrDt(lexical_form, datatype) => { |
|
|
|
let lexical_form = self.expression_evaluator(lexical_form); |
|
|
|
let lexical_form = self.expression_evaluator(lexical_form, stat_children); |
|
|
|
let datatype = self.expression_evaluator(datatype); |
|
|
|
let datatype = self.expression_evaluator(datatype, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let value = to_simple_string(&dataset, &lexical_form(tuple)?)?; |
|
|
|
let value = to_simple_string(&dataset, &lexical_form(tuple)?)?; |
|
|
@ -1770,24 +1782,24 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::SameTerm(a, b) => { |
|
|
|
PlanExpression::SameTerm(a, b) => { |
|
|
|
let a = self.expression_evaluator(a); |
|
|
|
let a = self.expression_evaluator(a, stat_children); |
|
|
|
let b = self.expression_evaluator(b); |
|
|
|
let b = self.expression_evaluator(b, stat_children); |
|
|
|
Rc::new(move |tuple| Some((a(tuple)? == b(tuple)?).into())) |
|
|
|
Rc::new(move |tuple| Some((a(tuple)? == b(tuple)?).into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::IsIri(e) => { |
|
|
|
PlanExpression::IsIri(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_named_node().into())) |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_named_node().into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::IsBlank(e) => { |
|
|
|
PlanExpression::IsBlank(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_blank_node().into())) |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_blank_node().into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::IsLiteral(e) => { |
|
|
|
PlanExpression::IsLiteral(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_literal().into())) |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_literal().into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::IsNumeric(e) => { |
|
|
|
PlanExpression::IsNumeric(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Some( |
|
|
|
Some( |
|
|
|
matches!( |
|
|
|
matches!( |
|
|
@ -1802,7 +1814,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::StaticRegex(text, regex) => { |
|
|
|
PlanExpression::StaticRegex(text, regex) => { |
|
|
|
let text = self.expression_evaluator(text); |
|
|
|
let text = self.expression_evaluator(text, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let regex = regex.clone(); |
|
|
|
let regex = regex.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
@ -1811,9 +1823,11 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DynamicRegex(text, pattern, flags) => { |
|
|
|
PlanExpression::DynamicRegex(text, pattern, flags) => { |
|
|
|
let text = self.expression_evaluator(text); |
|
|
|
let text = self.expression_evaluator(text, stat_children); |
|
|
|
let pattern = self.expression_evaluator(pattern); |
|
|
|
let pattern = self.expression_evaluator(pattern, stat_children); |
|
|
|
let flags = flags.as_ref().map(|flags| self.expression_evaluator(flags)); |
|
|
|
let flags = flags |
|
|
|
|
|
|
|
.as_ref() |
|
|
|
|
|
|
|
.map(|flags| self.expression_evaluator(flags, stat_children)); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let pattern = to_simple_string(&dataset, &pattern(tuple)?)?; |
|
|
|
let pattern = to_simple_string(&dataset, &pattern(tuple)?)?; |
|
|
@ -1828,9 +1842,9 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Triple(s, p, o) => { |
|
|
|
PlanExpression::Triple(s, p, o) => { |
|
|
|
let s = self.expression_evaluator(s); |
|
|
|
let s = self.expression_evaluator(s, stat_children); |
|
|
|
let p = self.expression_evaluator(p); |
|
|
|
let p = self.expression_evaluator(p, stat_children); |
|
|
|
let o = self.expression_evaluator(o); |
|
|
|
let o = self.expression_evaluator(o, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let s = s(tuple)?; |
|
|
|
let s = s(tuple)?; |
|
|
|
let p = p(tuple)?; |
|
|
|
let p = p(tuple)?; |
|
|
@ -1847,7 +1861,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Subject(e) => { |
|
|
|
PlanExpression::Subject(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
if let EncodedTerm::Triple(t) = e(tuple)? { |
|
|
|
if let EncodedTerm::Triple(t) = e(tuple)? { |
|
|
|
Some(t.subject.clone()) |
|
|
|
Some(t.subject.clone()) |
|
|
@ -1857,7 +1871,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Predicate(e) => { |
|
|
|
PlanExpression::Predicate(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
if let EncodedTerm::Triple(t) = e(tuple)? { |
|
|
|
if let EncodedTerm::Triple(t) = e(tuple)? { |
|
|
|
Some(t.predicate.clone()) |
|
|
|
Some(t.predicate.clone()) |
|
|
@ -1867,7 +1881,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::Object(e) => { |
|
|
|
PlanExpression::Object(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
if let EncodedTerm::Triple(t) = e(tuple)? { |
|
|
|
if let EncodedTerm::Triple(t) = e(tuple)? { |
|
|
|
Some(t.object.clone()) |
|
|
|
Some(t.object.clone()) |
|
|
@ -1877,11 +1891,11 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::IsTriple(e) => { |
|
|
|
PlanExpression::IsTriple(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_triple().into())) |
|
|
|
Rc::new(move |tuple| Some(e(tuple)?.is_triple().into())) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::BooleanCast(e) => { |
|
|
|
PlanExpression::BooleanCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::BooleanLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::BooleanLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Boolean::from(value).into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Boolean::from(value).into()), |
|
|
@ -1893,7 +1907,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DoubleCast(e) => { |
|
|
|
PlanExpression::DoubleCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Double::from(value).into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Double::from(value).into()), |
|
|
@ -1909,7 +1923,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::FloatCast(e) => { |
|
|
|
PlanExpression::FloatCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(value.into()), |
|
|
@ -1925,7 +1939,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::IntegerCast(e) => { |
|
|
|
PlanExpression::IntegerCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Integer::try_from(value).ok()?.into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Integer::try_from(value).ok()?.into()), |
|
|
@ -1945,7 +1959,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DecimalCast(e) => { |
|
|
|
PlanExpression::DecimalCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Decimal::try_from(value).ok()?.into()), |
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Decimal::try_from(value).ok()?.into()), |
|
|
@ -1965,7 +1979,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DateCast(e) => { |
|
|
|
PlanExpression::DateCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DateLiteral(value) => Some(value.into()), |
|
|
@ -1978,7 +1992,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::TimeCast(e) => { |
|
|
|
PlanExpression::TimeCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::TimeLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::TimeLiteral(value) => Some(value.into()), |
|
|
@ -1991,7 +2005,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DateTimeCast(e) => { |
|
|
|
PlanExpression::DateTimeCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DateTimeLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DateTimeLiteral(value) => Some(value.into()), |
|
|
@ -2004,7 +2018,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DurationCast(e) => { |
|
|
|
PlanExpression::DurationCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DurationLiteral(value) => Some(value.into()), |
|
|
|
EncodedTerm::DurationLiteral(value) => Some(value.into()), |
|
|
@ -2022,7 +2036,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::YearMonthDurationCast(e) => { |
|
|
|
PlanExpression::YearMonthDurationCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DurationLiteral(value) => { |
|
|
|
EncodedTerm::DurationLiteral(value) => { |
|
|
@ -2037,7 +2051,7 @@ impl SimpleEvaluator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
PlanExpression::DayTimeDurationCast(e) => { |
|
|
|
PlanExpression::DayTimeDurationCast(e) => { |
|
|
|
let e = self.expression_evaluator(e); |
|
|
|
let e = self.expression_evaluator(e, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
Rc::new(move |tuple| match e(tuple)? { |
|
|
|
EncodedTerm::DurationLiteral(value) => { |
|
|
|
EncodedTerm::DurationLiteral(value) => { |
|
|
@ -2055,7 +2069,7 @@ impl SimpleEvaluator { |
|
|
|
if let Some(function) = self.custom_functions.get(function_name).cloned() { |
|
|
|
if let Some(function) = self.custom_functions.get(function_name).cloned() { |
|
|
|
let args = args |
|
|
|
let args = args |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.map(|e| self.expression_evaluator(e)) |
|
|
|
.map(|e| self.expression_evaluator(e, stat_children)) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
@ -2075,8 +2089,9 @@ impl SimpleEvaluator { |
|
|
|
fn hash<H: Digest>( |
|
|
|
fn hash<H: Digest>( |
|
|
|
&self, |
|
|
|
&self, |
|
|
|
arg: &PlanExpression, |
|
|
|
arg: &PlanExpression, |
|
|
|
|
|
|
|
stat_children: &mut Vec<Rc<PlanNodeWithStats>>, |
|
|
|
) -> Rc<dyn Fn(&EncodedTuple) -> Option<EncodedTerm>> { |
|
|
|
) -> Rc<dyn Fn(&EncodedTuple) -> Option<EncodedTerm>> { |
|
|
|
let arg = self.expression_evaluator(arg); |
|
|
|
let arg = self.expression_evaluator(arg, stat_children); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
let dataset = self.dataset.clone(); |
|
|
|
Rc::new(move |tuple| { |
|
|
|
Rc::new(move |tuple| { |
|
|
|
let input = to_simple_string(&dataset, &arg(tuple)?)?; |
|
|
|
let input = to_simple_string(&dataset, &arg(tuple)?)?; |
|
|
|