diff --git a/lib/spargebra/src/rule.rs b/lib/spargebra/src/rule.rs index 36dfe52d..470337a6 100644 --- a/lib/spargebra/src/rule.rs +++ b/lib/spargebra/src/rule.rs @@ -20,8 +20,7 @@ impl RuleSet { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub fn to_sse(&self) -> String { let mut buffer = String::new(); - self.fmt_sse(&mut buffer) - .expect("Unexpected error during SSE formatting"); + self.fmt_sse(&mut buffer).unwrap(); buffer } @@ -84,8 +83,7 @@ impl Rule { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub fn to_sse(&self) -> String { let mut buffer = String::new(); - self.fmt_sse(&mut buffer) - .expect("Unexpected error during SSE formatting"); + self.fmt_sse(&mut buffer).unwrap(); buffer } @@ -110,11 +108,11 @@ impl Rule { impl fmt::Display for Rule { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "IF {{ ")?; - for triple in self.body.iter() { + for triple in &self.body { write!(f, "{triple} . ")?; } write!(f, "}} THEN {{ ")?; - for triple in self.head.iter() { + for triple in &self.head { write!(f, "{triple} . ")?; } write!(f, "}}") diff --git a/lib/sparopt/src/algebra.rs b/lib/sparopt/src/algebra.rs index b28fd693..6c6d1899 100644 --- a/lib/sparopt/src/algebra.rs +++ b/lib/sparopt/src/algebra.rs @@ -1371,7 +1371,7 @@ impl FixedPointGraphPattern { let mut constant = Self::empty(); let mut recursive = Self::empty(); for child in children { - if child.is_recursion_used(&id) { + if child.is_recursion_used(id) { recursive = Self::union(recursive, child); } else { constant = Self::union(constant, child); @@ -1388,7 +1388,7 @@ impl FixedPointGraphPattern { } } - fn is_recursion_used(&self, id: &FixedPointId) -> bool { + fn is_recursion_used(&self, id: FixedPointId) -> bool { match self { Self::QuadPattern { .. } | Self::Values { .. } => false, Self::Filter { inner, .. } @@ -1403,13 +1403,13 @@ impl FixedPointGraphPattern { recursive, .. } => Self::is_recursion_used(constant, id) || Self::is_recursion_used(recursive, id), - Self::FixedPointEntry(tid) => id == tid, + Self::FixedPointEntry(tid) => id == *tid, } } pub(crate) fn lookup_used_variables(&self, callback: &mut impl FnMut(&Variable)) { match self { - FixedPointGraphPattern::QuadPattern { + Self::QuadPattern { subject, predicate, object, @@ -1424,34 +1424,34 @@ impl FixedPointGraphPattern { callback(v); } } - FixedPointGraphPattern::Join { left, right } => { + Self::Join { left, right } => { left.lookup_used_variables(callback); right.lookup_used_variables(callback); } - FixedPointGraphPattern::Filter { inner, .. } => { + Self::Filter { inner, .. } => { inner.lookup_used_variables(callback); // TODO: we assume all expression variables are bound } - FixedPointGraphPattern::Union { inner } => { + Self::Union { inner } => { for inner in inner { inner.lookup_used_variables(callback); } } - FixedPointGraphPattern::Extend { + Self::Extend { inner, variable, .. } => { inner.lookup_used_variables(callback); callback(variable); // TODO: we assume all expression variables are bound } - FixedPointGraphPattern::Values { variables, .. } - | FixedPointGraphPattern::Project { variables, .. } - | FixedPointGraphPattern::FixedPoint { variables, .. } => { + Self::Values { variables, .. } + | Self::Project { variables, .. } + | Self::FixedPoint { variables, .. } => { for v in variables { callback(v); } } - FixedPointGraphPattern::FixedPointEntry(_) => { + Self::FixedPointEntry(_) => { //TODO } } diff --git a/lib/sparopt/src/reasoning.rs b/lib/sparopt/src/reasoning.rs index 07641563..4ad3d464 100644 --- a/lib/sparopt/src/reasoning.rs +++ b/lib/sparopt/src/reasoning.rs @@ -1009,7 +1009,7 @@ impl QueryRewriter { }]), }, GroundTermPattern::Literal(from) => match to { - GroundTermPattern::NamedNode(_) => None, + GroundTermPattern::NamedNode(_) | GroundTermPattern::Triple(_) => None, GroundTermPattern::Literal(to) => { if from == to { Some(Vec::new()) @@ -1017,7 +1017,6 @@ impl QueryRewriter { None } } - GroundTermPattern::Triple(_) => None, GroundTermPattern::Variable(to) => Some(vec![Replacement::ConstToVar { from: from.into(), to, diff --git a/testsuite/src/sparql_evaluator.rs b/testsuite/src/sparql_evaluator.rs index ebb00f40..62d1109e 100644 --- a/testsuite/src/sparql_evaluator.rs +++ b/testsuite/src/sparql_evaluator.rs @@ -152,6 +152,12 @@ fn result_syntax_check(test: &Test, format: QueryResultsFormat) -> Result<()> { } fn evaluate_evaluation_test(test: &Test) -> Result<()> { + enum Mode { + Base, + WithoutOptimizer, + WithInferenceRules, + } + let store = Store::new()?; if let Some(data) = &test.data { load_dataset_to_store(data, &store)?; @@ -198,11 +204,6 @@ fn evaluate_evaluation_test(test: &Test) -> Result<()> { false }; - enum Mode { - Base, - WithoutOptimizer, - WithInferenceRules, - } for mode in [Mode::Base, Mode::WithoutOptimizer, Mode::WithInferenceRules] { let options = match mode { Mode::Base => options.clone(),