Makes Clippy happy

pull/171/head
Tpt 3 years ago
parent d27d62f973
commit f6dbb96327
  1. 1
      lib/src/model/dataset.rs
  2. 4
      lib/src/model/xsd/date_time.rs
  3. 10
      lib/src/model/xsd/parser.rs
  4. 21
      lib/src/sparql/eval.rs
  5. 23
      lib/src/sparql/mod.rs
  6. 4
      lib/src/sparql/model.rs
  7. 4
      lib/src/sparql/plan_builder.rs
  8. 17
      spargebra/src/parser.rs
  9. 1
      testsuite/src/sparql_evaluator.rs
  10. 3
      wikibase/src/main.rs

@ -66,7 +66,6 @@ use std::{fmt, io};
#[derive(Debug, Default)]
pub struct Dataset {
interner: Interner,
triples: HashMap<InternedTriple, Triple>,
gspo: BTreeSet<(
InternedGraphName,
InternedSubject,

@ -1454,7 +1454,7 @@ fn date_time_plus_duration(
let da = dt.day.unwrap_or(1);
let hr = dt.hour.unwrap_or(0);
let mi = dt.minute.unwrap_or(0);
let se = dt.second.unwrap_or_else(Decimal::default);
let se = dt.second.unwrap_or_default();
let mo = i64::from(mo).checked_add(du.all_months())?;
let (yr, mo) = normalize_month(yr, mo)?;
let da = min(da, days_in_month(Some(yr), mo));
@ -1488,7 +1488,7 @@ fn time_on_timeline(props: &DateTimeSevenPropertyModel) -> Option<Decimal> {
.unwrap_or_else(TimezoneOffset::utc)
.offset,
);
let se = props.second.unwrap_or_else(Decimal::default);
let se = props.second.unwrap_or_default();
Decimal::try_from(
31_536_000 * i128::from(yr)

@ -216,13 +216,13 @@ fn du_time_frag(input: &str) -> XsdResult<'_, Decimal> {
tuple((du_hour_frag, opt(du_minute_frag), opt(du_second_frag))),
|(h, m, s)| {
Decimal::from(3600 * h + 60 * m.unwrap_or(0))
.checked_add(s.unwrap_or_else(Decimal::default))
.checked_add(s.unwrap_or_default())
.ok_or(OVERFLOW_ERROR)
},
),
map_res(tuple((du_minute_frag, opt(du_second_frag))), |(m, s)| {
Decimal::from(m * 60)
.checked_add(s.unwrap_or_else(Decimal::default))
.checked_add(s.unwrap_or_default())
.ok_or(OVERFLOW_ERROR)
}),
du_second_frag,
@ -237,7 +237,7 @@ fn du_day_time_frag(input: &str) -> XsdResult<'_, Decimal> {
Decimal::from(d)
.checked_mul(Decimal::from(86400))
.ok_or(OVERFLOW_ERROR)?
.checked_add(t.unwrap_or_else(Decimal::default))
.checked_add(t.unwrap_or_default())
.ok_or(OVERFLOW_ERROR)
}),
du_time_frag,
@ -254,7 +254,7 @@ pub fn duration_lexical_rep(input: &str) -> XsdResult<'_, Duration> {
alt((
map(
tuple((du_year_month_frag, opt(du_day_time_frag))),
|(y, d)| Duration::new(y, d.unwrap_or_else(Decimal::default)),
|(y, d)| Duration::new(y, d.unwrap_or_default()),
),
map(du_day_time_frag, |d| Duration::new(0, d)),
)),
@ -410,7 +410,7 @@ pub fn day_time_duration_lexical_rep(input: &str) -> XsdResult<'_, DayTimeDurati
// [46] unsignedNoDecimalPtNumeral ::= digit+
fn unsigned_no_decimal_pt_numeral(input: &str) -> XsdResult<'_, i64> {
map_res(digit1, |i| i64::from_str(i))(input)
map_res(digit1, i64::from_str)(input)
}
// [56] yearFrag ::= '-'? (([1-9] digit digit digit+)) | ('0' digit digit digit))

@ -3350,7 +3350,7 @@ fn transitive_closure<T: Clone + Eq + Hash, NI: Iterator<Item = Result<T, Evalua
while !current.is_empty() {
current = current
.into_iter()
.flat_map(|e| next(e))
.flat_map(&next)
.filter_map(|e| match e {
Ok(e) => {
if all.contains(&e) {
@ -3532,21 +3532,12 @@ impl Accumulator for SumAccumulator {
}
}
#[derive(Debug)]
#[derive(Debug, Default)]
struct AvgAccumulator {
sum: SumAccumulator,
count: CountAccumulator,
}
impl Default for AvgAccumulator {
fn default() -> Self {
Self {
sum: SumAccumulator::default(),
count: CountAccumulator::default(),
}
}
}
impl Accumulator for AvgAccumulator {
fn add(&mut self, element: Option<EncodedTerm>) {
self.sum.add(element.clone());
@ -3630,17 +3621,11 @@ impl Accumulator for MaxAccumulator {
}
}
#[derive(Debug)]
#[derive(Debug, Default)]
struct SampleAccumulator {
value: Option<EncodedTerm>,
}
impl Default for SampleAccumulator {
fn default() -> Self {
Self { value: None }
}
}
impl Accumulator for SampleAccumulator {
fn add(&mut self, element: Option<EncodedTerm>) {
if element.is_some() {

@ -109,22 +109,12 @@ pub(crate) fn evaluate_query(
///
/// If the `"http_client"` optional feature is enabled,
/// a simple HTTP 1.1 client is used to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls.
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct QueryOptions {
pub(crate) service_handler: Option<Rc<dyn ServiceHandler<Error = EvaluationError>>>,
http_timeout: Option<Duration>,
}
impl Default for QueryOptions {
#[inline]
fn default() -> Self {
Self {
service_handler: None,
http_timeout: None,
}
}
}
impl QueryOptions {
/// Use a given [`ServiceHandler`] to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls.
#[inline]
@ -161,7 +151,7 @@ impl QueryOptions {
}
/// Options for SPARQL update evaluation
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct UpdateOptions {
query_options: QueryOptions,
}
@ -180,15 +170,6 @@ impl UpdateOptions {
}
}
impl Default for UpdateOptions {
#[inline]
fn default() -> Self {
Self {
query_options: QueryOptions::default(),
}
}
}
impl From<QueryOptions> for UpdateOptions {
#[inline]
fn from(query_options: QueryOptions) -> Self {

@ -385,11 +385,11 @@ impl Iterator for QueryTripleIter {
}
#[inline]
fn fold<Acc, G>(self, init: Acc, mut g: G) -> Acc
fn fold<Acc, G>(self, init: Acc, g: G) -> Acc
where
G: FnMut(Acc, Self::Item) -> Acc,
{
self.iter.fold(init, |acc, elt| g(acc, elt))
self.iter.fold(init, g)
}
}

@ -1189,9 +1189,7 @@ impl<'a> PlanBuilder<'a> {
PlanNode::Filter { child, .. } | PlanNode::Extend { child, .. } => {
Self::is_fit_for_for_loop_join(child)
}
PlanNode::Union { children } => {
children.iter().all(|c| Self::is_fit_for_for_loop_join(c))
}
PlanNode::Union { children } => children.iter().all(Self::is_fit_for_for_loop_join),
PlanNode::AntiJoin { .. }
| PlanNode::LeftJoin { .. }
| PlanNode::Service { .. }

@ -277,10 +277,7 @@ fn build_bgp(patterns: Vec<TripleOrPathPattern>) -> GraphPattern {
if !bgp.is_empty() {
elements.push(GraphPattern::Bgp { patterns: bgp });
}
elements
.into_iter()
.reduce(new_join)
.unwrap_or_else(GraphPattern::default)
elements.into_iter().reduce(new_join).unwrap_or_default()
}
enum TripleOrPathPattern {
@ -444,7 +441,7 @@ fn build_select(
let mut with_aggregate = false;
//GROUP BY
let aggregates = state.aggregates.pop().unwrap_or_else(Vec::default);
let aggregates = state.aggregates.pop().unwrap_or_default();
if group.is_none() && !aggregates.is_empty() {
group = Some((vec![], vec![]));
}
@ -987,7 +984,7 @@ parser! {
i("DESCRIBE") _ "*" _ d:DatasetClauses() w:WhereClause()? _ g:GroupClause()? _ h:HavingClause()? _ o:OrderClause()? _ l:LimitOffsetClauses()? _ v:ValuesClause() {?
Ok(Query::Describe {
dataset: d,
pattern: build_select(Selection::no_op(), w.unwrap_or_else(GraphPattern::default), g, h, o, l, v, state)?,
pattern: build_select(Selection::no_op(), w.unwrap_or_default(), g, h, o, l, v, state)?,
base_iri: state.base_iri.clone()
})
} /
@ -1000,7 +997,7 @@ parser! {
NamedNodePattern::NamedNode(n) => SelectionMember::Expression(n.into(), variable()),
NamedNodePattern::Variable(v) => SelectionMember::Variable(v)
}).collect())
}, w.unwrap_or_else(GraphPattern::default), g, h, o, l, v, state)?,
}, w.unwrap_or_default(), g, h, o, l, v, state)?,
base_iri: state.base_iri.clone()
})
}
@ -1198,7 +1195,7 @@ parser! {
GraphNamePattern::DefaultGraph => bgp,
GraphNamePattern::Variable(graph_name) => GraphPattern::Graph { name: graph_name.clone().into(), inner: Box::new(bgp) },
}
}).reduce(new_join).unwrap_or_else(GraphPattern::default);
}).reduce(new_join).unwrap_or_default();
let delete = d.into_iter().map(GroundQuadPattern::try_from).collect::<Result<Vec<_>,_>>().map_err(|_| "Blank nodes are not allowed in DELETE WHERE")?;
Ok(vec![GraphUpdateOperation::DeleteInsert {
delete,
@ -1343,7 +1340,7 @@ parser! {
triples
}
rule TriplesTemplate_tail() -> Vec<TriplePattern> = "." _ t:TriplesTemplate()? _ {
t.unwrap_or_else(Vec::default)
t.unwrap_or_default()
}
//[53]
@ -1412,7 +1409,7 @@ parser! {
triples
}
rule TriplesBlock_tail() -> Vec<TripleOrPathPattern> = "." _ t:TriplesBlock()? _ {
t.unwrap_or_else(Vec::default)
t.unwrap_or_default()
}
//[56]

@ -449,6 +449,7 @@ fn compare_terms<'a>(
}
}
#[allow(clippy::large_enum_variant)]
enum StaticQueryResults {
Graph(Graph),
Solutions {

@ -83,7 +83,6 @@ pub async fn main() -> Result<()> {
let mediawiki_base_url = matches.value_of("mediawiki_base_url").unwrap();
let namespaces = matches
.value_of("namespaces")
.as_deref()
.unwrap_or("")
.split(',')
.flat_map(|t| {
@ -108,7 +107,7 @@ pub async fn main() -> Result<()> {
mediawiki_api,
mediawiki_base_url,
&namespaces,
slot.as_deref(),
slot,
Duration::new(10, 0),
)
.unwrap();

Loading…
Cancel
Save