Applies new Clippy suggestions

pull/244/head
Tpt 2 years ago committed by Thomas Tanon
parent f3e138f0b4
commit e9bbe8e036
  1. 2
      lib/oxrdf/src/parser.rs
  2. 8
      lib/spargebra/src/algebra.rs
  3. 5
      lib/src/sparql/eval.rs
  4. 6
      lib/src/sparql/model.rs
  5. 68
      lib/src/sparql/plan.rs
  6. 22
      lib/src/sparql/plan_builder.rs
  7. 8
      lib/src/storage/backend/rocksdb.rs
  8. 2
      lib/src/xsd/decimal.rs

@ -241,7 +241,7 @@ fn read_literal(s: &str) -> Result<(Literal, &str), TermParseError> {
return Err(TermParseError::msg("Empty term serialization"));
}
let mut cursor = match input.get(0) {
let mut cursor = match input.first() {
Some(b'+' | b'-') => 1,
_ => 0,
};

@ -1027,19 +1027,19 @@ impl<'a> fmt::Display for SparqlGraphRootPattern<'a> {
match child {
GraphPattern::OrderBy { inner, expression } => {
order = Some(expression);
child = &*inner;
child = inner;
}
GraphPattern::Project { inner, variables } if project.is_empty() => {
project = variables;
child = &*inner;
child = inner;
}
GraphPattern::Distinct { inner } => {
distinct = true;
child = &*inner;
child = inner;
}
GraphPattern::Reduced { inner } => {
reduced = true;
child = &*inner;
child = inner;
}
GraphPattern::Slice {
inner,

@ -32,6 +32,7 @@ use std::str;
const REGEX_SIZE_LIMIT: usize = 1_000_000;
type EncodedTuplesIterator = Box<dyn Iterator<Item = Result<EncodedTuple, EvaluationError>>>;
type CustomFunctionRegistry = HashMap<NamedNode, Rc<dyn Fn(&[Term]) -> Option<Term>>>;
#[derive(Clone)]
pub struct SimpleEvaluator {
@ -39,7 +40,7 @@ pub struct SimpleEvaluator {
base_iri: Option<Rc<Iri<String>>>,
now: DateTime,
service_handler: Rc<dyn ServiceHandler<Error = EvaluationError>>,
custom_functions: Rc<HashMap<NamedNode, Rc<dyn Fn(&[Term]) -> Option<Term>>>>,
custom_functions: Rc<CustomFunctionRegistry>,
}
impl SimpleEvaluator {
@ -47,7 +48,7 @@ impl SimpleEvaluator {
dataset: Rc<DatasetView>,
base_iri: Option<Rc<Iri<String>>>,
service_handler: Rc<dyn ServiceHandler<Error = EvaluationError>>,
custom_functions: Rc<HashMap<NamedNode, Rc<dyn Fn(&[Term]) -> Option<Term>>>>,
custom_functions: Rc<CustomFunctionRegistry>,
) -> Self {
Self {
dataset,

@ -60,7 +60,7 @@ impl QueryResults {
Self::Boolean(value) => {
serializer.write_boolean_result(writer, value)?;
}
QueryResults::Solutions(solutions) => {
Self::Solutions(solutions) => {
let mut writer =
serializer.solutions_writer(writer, solutions.variables().to_vec())?;
for solution in solutions {
@ -68,7 +68,7 @@ impl QueryResults {
}
writer.finish()?;
}
QueryResults::Graph(triples) => {
Self::Graph(triples) => {
let s = VariableRef::new_unchecked("subject");
let p = VariableRef::new_unchecked("predicate");
let o = VariableRef::new_unchecked("object");
@ -115,7 +115,7 @@ impl QueryResults {
write: impl Write,
format: GraphFormat,
) -> Result<(), EvaluationError> {
if let QueryResults::Graph(triples) = self {
if let Self::Graph(triples) = self {
let mut writer = GraphSerializer::from_format(format).triple_writer(write)?;
for triple in triples {
writer.write(&triple?)?;

@ -107,7 +107,7 @@ impl PlanNode {
pub fn lookup_used_variables(&self, callback: &mut impl FnMut(usize)) {
match self {
PlanNode::StaticBindings { tuples } => {
Self::StaticBindings { tuples } => {
for tuple in tuples {
for (key, value) in tuple.iter().enumerate() {
if value.is_some() {
@ -116,7 +116,7 @@ impl PlanNode {
}
}
}
PlanNode::QuadPattern {
Self::QuadPattern {
subject,
predicate,
object,
@ -135,7 +135,7 @@ impl PlanNode {
callback(*var);
}
}
PlanNode::PathPattern {
Self::PathPattern {
subject,
object,
graph_name,
@ -151,23 +151,23 @@ impl PlanNode {
callback(*var);
}
}
PlanNode::Filter { child, expression } => {
Self::Filter { child, expression } => {
expression.lookup_used_variables(callback);
child.lookup_used_variables(callback);
}
PlanNode::Union { children } => {
Self::Union { children } => {
for child in children.iter() {
child.lookup_used_variables(callback);
}
}
PlanNode::HashJoin { left, right }
| PlanNode::ForLoopJoin { left, right, .. }
| PlanNode::AntiJoin { left, right }
| PlanNode::LeftJoin { left, right, .. } => {
Self::HashJoin { left, right }
| Self::ForLoopJoin { left, right, .. }
| Self::AntiJoin { left, right }
| Self::LeftJoin { left, right, .. } => {
left.lookup_used_variables(callback);
right.lookup_used_variables(callback);
}
PlanNode::Extend {
Self::Extend {
child,
position,
expression,
@ -176,12 +176,12 @@ impl PlanNode {
expression.lookup_used_variables(callback);
child.lookup_used_variables(callback);
}
PlanNode::Sort { child, .. }
| PlanNode::HashDeduplicate { child }
| PlanNode::Reduced { child }
| PlanNode::Skip { child, .. }
| PlanNode::Limit { child, .. } => child.lookup_used_variables(callback),
PlanNode::Service {
Self::Sort { child, .. }
| Self::HashDeduplicate { child }
| Self::Reduced { child }
| Self::Skip { child, .. }
| Self::Limit { child, .. } => child.lookup_used_variables(callback),
Self::Service {
child,
service_name,
..
@ -191,7 +191,7 @@ impl PlanNode {
}
child.lookup_used_variables(callback);
}
PlanNode::Project { mapping, child } => {
Self::Project { mapping, child } => {
let child_bound = child.used_variables();
for (child_i, output_i) in mapping.iter() {
if child_bound.contains(child_i) {
@ -199,7 +199,7 @@ impl PlanNode {
}
}
}
PlanNode::Aggregate {
Self::Aggregate {
key_mapping,
aggregates,
..
@ -227,7 +227,7 @@ impl PlanNode {
pub fn lookup_always_bound_variables(&self, callback: &mut impl FnMut(usize)) {
match self {
PlanNode::StaticBindings { tuples } => {
Self::StaticBindings { tuples } => {
let mut variables = BTreeMap::default(); // value true iff always bound
let max_tuple_length = tuples.iter().map(|t| t.capacity()).fold(0, max);
for tuple in tuples {
@ -250,7 +250,7 @@ impl PlanNode {
}
}
}
PlanNode::QuadPattern {
Self::QuadPattern {
subject,
predicate,
object,
@ -269,7 +269,7 @@ impl PlanNode {
callback(*var);
}
}
PlanNode::PathPattern {
Self::PathPattern {
subject,
object,
graph_name,
@ -285,11 +285,11 @@ impl PlanNode {
callback(*var);
}
}
PlanNode::Filter { child, .. } => {
Self::Filter { child, .. } => {
//TODO: have a look at the expression to know if it filters out unbound variables
child.lookup_always_bound_variables(callback);
}
PlanNode::Union { children } => {
Self::Union { children } => {
if let Some(vars) = children
.iter()
.map(|c| c.always_bound_variables())
@ -300,14 +300,14 @@ impl PlanNode {
}
}
}
PlanNode::HashJoin { left, right } | PlanNode::ForLoopJoin { left, right, .. } => {
Self::HashJoin { left, right } | Self::ForLoopJoin { left, right, .. } => {
left.lookup_always_bound_variables(callback);
right.lookup_always_bound_variables(callback);
}
PlanNode::AntiJoin { left, .. } | PlanNode::LeftJoin { left, .. } => {
Self::AntiJoin { left, .. } | Self::LeftJoin { left, .. } => {
left.lookup_always_bound_variables(callback);
}
PlanNode::Extend {
Self::Extend {
child,
position,
expression,
@ -318,19 +318,19 @@ impl PlanNode {
}
child.lookup_always_bound_variables(callback);
}
PlanNode::Sort { child, .. }
| PlanNode::HashDeduplicate { child }
| PlanNode::Reduced { child }
| PlanNode::Skip { child, .. }
| PlanNode::Limit { child, .. } => child.lookup_always_bound_variables(callback),
PlanNode::Service { child, silent, .. } => {
Self::Sort { child, .. }
| Self::HashDeduplicate { child }
| Self::Reduced { child }
| Self::Skip { child, .. }
| Self::Limit { child, .. } => child.lookup_always_bound_variables(callback),
Self::Service { child, silent, .. } => {
if *silent {
// none, might return a null tuple
} else {
child.lookup_always_bound_variables(callback)
}
}
PlanNode::Project { mapping, child } => {
Self::Project { mapping, child } => {
let child_bound = child.always_bound_variables();
for (child_i, output_i) in mapping.iter() {
if child_bound.contains(child_i) {
@ -338,7 +338,7 @@ impl PlanNode {
}
}
}
PlanNode::Aggregate { .. } => {
Self::Aggregate { .. } => {
//TODO
}
}

@ -1079,7 +1079,7 @@ impl<'a> PlanBuilder<'a> {
set.insert(v);
}
});
self.add_left_join_problematic_variables(&*child, set);
self.add_left_join_problematic_variables(child, set);
}
PlanNode::Union { children } => {
for child in children.iter() {
@ -1087,14 +1087,14 @@ impl<'a> PlanBuilder<'a> {
}
}
PlanNode::HashJoin { left, right } | PlanNode::ForLoopJoin { left, right } => {
self.add_left_join_problematic_variables(&*left, set);
self.add_left_join_problematic_variables(&*right, set);
self.add_left_join_problematic_variables(left, set);
self.add_left_join_problematic_variables(right, set);
}
PlanNode::AntiJoin { left, .. } => {
self.add_left_join_problematic_variables(&*left, set);
self.add_left_join_problematic_variables(left, set);
}
PlanNode::LeftJoin { left, right, .. } => {
self.add_left_join_problematic_variables(&*left, set);
self.add_left_join_problematic_variables(left, set);
right.lookup_used_variables(&mut |v| {
set.insert(v);
});
@ -1108,28 +1108,26 @@ impl<'a> PlanBuilder<'a> {
set.insert(v);
}
});
self.add_left_join_problematic_variables(&*child, set);
self.add_left_join_problematic_variables(&*child, set);
self.add_left_join_problematic_variables(child, set);
self.add_left_join_problematic_variables(child, set);
}
PlanNode::Sort { child, .. }
| PlanNode::HashDeduplicate { child }
| PlanNode::Reduced { child }
| PlanNode::Skip { child, .. }
| PlanNode::Limit { child, .. } => {
self.add_left_join_problematic_variables(&*child, set)
}
| PlanNode::Limit { child, .. } => self.add_left_join_problematic_variables(child, set),
PlanNode::Service { child, silent, .. } => {
if *silent {
child.lookup_used_variables(&mut |v| {
set.insert(v);
});
} else {
self.add_left_join_problematic_variables(&*child, set)
self.add_left_join_problematic_variables(child, set)
}
}
PlanNode::Project { mapping, child } => {
let mut child_bound = BTreeSet::new();
self.add_left_join_problematic_variables(&*child, &mut child_bound);
self.add_left_join_problematic_variables(child, &mut child_bound);
for (child_i, output_i) in mapping.iter() {
if child_bound.contains(child_i) {
set.insert(*output_i);

@ -892,13 +892,13 @@ impl Deref for PinnableSlice {
impl AsRef<[u8]> for PinnableSlice {
fn as_ref(&self) -> &[u8] {
&*self
self
}
}
impl Borrow<[u8]> for PinnableSlice {
fn borrow(&self) -> &[u8] {
&*self
self
}
}
@ -931,13 +931,13 @@ impl Deref for Buffer {
impl AsRef<[u8]> for Buffer {
fn as_ref(&self) -> &[u8] {
&*self
self
}
}
impl Borrow<[u8]> for Buffer {
fn borrow(&self) -> &[u8] {
&*self
self
}
}

@ -320,7 +320,7 @@ impl FromStr for Decimal {
return Err(PARSE_UNEXPECTED_END);
}
let (sign, mut cursor) = match input.get(0) {
let (sign, mut cursor) = match input.first() {
Some(b'+') => (1, 1),
Some(b'-') => (-1, 1),
_ => (1, 0),

Loading…
Cancel
Save