WIP: Makes clippy happy

rules
Tpt 2 years ago
parent ea1ec3ede0
commit ecdc106fd5
  1. 10
      lib/spargebra/src/rule.rs
  2. 24
      lib/sparopt/src/algebra.rs
  3. 3
      lib/sparopt/src/reasoning.rs
  4. 11
      testsuite/src/sparql_evaluator.rs

@ -20,8 +20,7 @@ impl RuleSet {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
pub fn to_sse(&self) -> String { pub fn to_sse(&self) -> String {
let mut buffer = String::new(); let mut buffer = String::new();
self.fmt_sse(&mut buffer) self.fmt_sse(&mut buffer).unwrap();
.expect("Unexpected error during SSE formatting");
buffer buffer
} }
@ -84,8 +83,7 @@ impl Rule {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html).
pub fn to_sse(&self) -> String { pub fn to_sse(&self) -> String {
let mut buffer = String::new(); let mut buffer = String::new();
self.fmt_sse(&mut buffer) self.fmt_sse(&mut buffer).unwrap();
.expect("Unexpected error during SSE formatting");
buffer buffer
} }
@ -110,11 +108,11 @@ impl Rule {
impl fmt::Display for Rule { impl fmt::Display for Rule {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "IF {{ ")?; write!(f, "IF {{ ")?;
for triple in self.body.iter() { for triple in &self.body {
write!(f, "{triple} . ")?; write!(f, "{triple} . ")?;
} }
write!(f, "}} THEN {{ ")?; write!(f, "}} THEN {{ ")?;
for triple in self.head.iter() { for triple in &self.head {
write!(f, "{triple} . ")?; write!(f, "{triple} . ")?;
} }
write!(f, "}}") write!(f, "}}")

@ -1371,7 +1371,7 @@ impl FixedPointGraphPattern {
let mut constant = Self::empty(); let mut constant = Self::empty();
let mut recursive = Self::empty(); let mut recursive = Self::empty();
for child in children { for child in children {
if child.is_recursion_used(&id) { if child.is_recursion_used(id) {
recursive = Self::union(recursive, child); recursive = Self::union(recursive, child);
} else { } else {
constant = Self::union(constant, child); 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 { match self {
Self::QuadPattern { .. } | Self::Values { .. } => false, Self::QuadPattern { .. } | Self::Values { .. } => false,
Self::Filter { inner, .. } Self::Filter { inner, .. }
@ -1403,13 +1403,13 @@ impl FixedPointGraphPattern {
recursive, recursive,
.. ..
} => Self::is_recursion_used(constant, id) || Self::is_recursion_used(recursive, id), } => 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)) { pub(crate) fn lookup_used_variables(&self, callback: &mut impl FnMut(&Variable)) {
match self { match self {
FixedPointGraphPattern::QuadPattern { Self::QuadPattern {
subject, subject,
predicate, predicate,
object, object,
@ -1424,34 +1424,34 @@ impl FixedPointGraphPattern {
callback(v); callback(v);
} }
} }
FixedPointGraphPattern::Join { left, right } => { Self::Join { left, right } => {
left.lookup_used_variables(callback); left.lookup_used_variables(callback);
right.lookup_used_variables(callback); right.lookup_used_variables(callback);
} }
FixedPointGraphPattern::Filter { inner, .. } => { Self::Filter { inner, .. } => {
inner.lookup_used_variables(callback); inner.lookup_used_variables(callback);
// TODO: we assume all expression variables are bound // TODO: we assume all expression variables are bound
} }
FixedPointGraphPattern::Union { inner } => { Self::Union { inner } => {
for inner in inner { for inner in inner {
inner.lookup_used_variables(callback); inner.lookup_used_variables(callback);
} }
} }
FixedPointGraphPattern::Extend { Self::Extend {
inner, variable, .. inner, variable, ..
} => { } => {
inner.lookup_used_variables(callback); inner.lookup_used_variables(callback);
callback(variable); callback(variable);
// TODO: we assume all expression variables are bound // TODO: we assume all expression variables are bound
} }
FixedPointGraphPattern::Values { variables, .. } Self::Values { variables, .. }
| FixedPointGraphPattern::Project { variables, .. } | Self::Project { variables, .. }
| FixedPointGraphPattern::FixedPoint { variables, .. } => { | Self::FixedPoint { variables, .. } => {
for v in variables { for v in variables {
callback(v); callback(v);
} }
} }
FixedPointGraphPattern::FixedPointEntry(_) => { Self::FixedPointEntry(_) => {
//TODO //TODO
} }
} }

@ -1009,7 +1009,7 @@ impl QueryRewriter {
}]), }]),
}, },
GroundTermPattern::Literal(from) => match to { GroundTermPattern::Literal(from) => match to {
GroundTermPattern::NamedNode(_) => None, GroundTermPattern::NamedNode(_) | GroundTermPattern::Triple(_) => None,
GroundTermPattern::Literal(to) => { GroundTermPattern::Literal(to) => {
if from == to { if from == to {
Some(Vec::new()) Some(Vec::new())
@ -1017,7 +1017,6 @@ impl QueryRewriter {
None None
} }
} }
GroundTermPattern::Triple(_) => None,
GroundTermPattern::Variable(to) => Some(vec![Replacement::ConstToVar { GroundTermPattern::Variable(to) => Some(vec![Replacement::ConstToVar {
from: from.into(), from: from.into(),
to, to,

@ -152,6 +152,12 @@ fn result_syntax_check(test: &Test, format: QueryResultsFormat) -> Result<()> {
} }
fn evaluate_evaluation_test(test: &Test) -> Result<()> { fn evaluate_evaluation_test(test: &Test) -> Result<()> {
enum Mode {
Base,
WithoutOptimizer,
WithInferenceRules,
}
let store = Store::new()?; let store = Store::new()?;
if let Some(data) = &test.data { if let Some(data) = &test.data {
load_dataset_to_store(data, &store)?; load_dataset_to_store(data, &store)?;
@ -198,11 +204,6 @@ fn evaluate_evaluation_test(test: &Test) -> Result<()> {
false false
}; };
enum Mode {
Base,
WithoutOptimizer,
WithInferenceRules,
}
for mode in [Mode::Base, Mode::WithoutOptimizer, Mode::WithInferenceRules] { for mode in [Mode::Base, Mode::WithoutOptimizer, Mode::WithInferenceRules] {
let options = match mode { let options = match mode {
Mode::Base => options.clone(), Mode::Base => options.clone(),

Loading…
Cancel
Save