diff --git a/lib/oxrdf/src/parser.rs b/lib/oxrdf/src/parser.rs index 4e245db3..861be688 100644 --- a/lib/oxrdf/src/parser.rs +++ b/lib/oxrdf/src/parser.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, }; diff --git a/lib/spargebra/src/algebra.rs b/lib/spargebra/src/algebra.rs index fef4ff68..38acb015 100644 --- a/lib/spargebra/src/algebra.rs +++ b/lib/spargebra/src/algebra.rs @@ -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, diff --git a/lib/src/sparql/eval.rs b/lib/src/sparql/eval.rs index 842dbe16..34ba3021 100644 --- a/lib/src/sparql/eval.rs +++ b/lib/src/sparql/eval.rs @@ -32,6 +32,7 @@ use std::str; const REGEX_SIZE_LIMIT: usize = 1_000_000; type EncodedTuplesIterator = Box>>; +type CustomFunctionRegistry = HashMap Option>>; #[derive(Clone)] pub struct SimpleEvaluator { @@ -39,7 +40,7 @@ pub struct SimpleEvaluator { base_iri: Option>>, now: DateTime, service_handler: Rc>, - custom_functions: Rc Option>>>, + custom_functions: Rc, } impl SimpleEvaluator { @@ -47,7 +48,7 @@ impl SimpleEvaluator { dataset: Rc, base_iri: Option>>, service_handler: Rc>, - custom_functions: Rc Option>>>, + custom_functions: Rc, ) -> Self { Self { dataset, diff --git a/lib/src/sparql/model.rs b/lib/src/sparql/model.rs index 087adaa9..8b358d45 100644 --- a/lib/src/sparql/model.rs +++ b/lib/src/sparql/model.rs @@ -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?)?; diff --git a/lib/src/sparql/plan.rs b/lib/src/sparql/plan.rs index 8b39b774..1d99af7b 100644 --- a/lib/src/sparql/plan.rs +++ b/lib/src/sparql/plan.rs @@ -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 } } diff --git a/lib/src/sparql/plan_builder.rs b/lib/src/sparql/plan_builder.rs index 4996c0d3..ca48625b 100644 --- a/lib/src/sparql/plan_builder.rs +++ b/lib/src/sparql/plan_builder.rs @@ -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); diff --git a/lib/src/storage/backend/rocksdb.rs b/lib/src/storage/backend/rocksdb.rs index b346e02c..5a5570b8 100644 --- a/lib/src/storage/backend/rocksdb.rs +++ b/lib/src/storage/backend/rocksdb.rs @@ -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 } } diff --git a/lib/src/xsd/decimal.rs b/lib/src/xsd/decimal.rs index 7955cfeb..3ae70566 100644 --- a/lib/src/xsd/decimal.rs +++ b/lib/src/xsd/decimal.rs @@ -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),