Fixes some formatting

pull/10/head
Tpt 6 years ago
parent a77d08cf03
commit 81cae09eb5
  1. 2
      lib/src/rio/xml.rs
  2. 60
      lib/src/sparql/eval.rs
  3. 8
      lib/src/sparql/plan.rs
  4. 8
      lib/src/sparql/xml_results.rs
  5. 3
      lib/src/store/numeric_encoder.rs
  6. 2
      lib/tests/rdf_test_cases.rs
  7. 2
      lib/tests/sparql_test_cases.rs

@ -292,7 +292,7 @@ impl<R: BufRead> RdfXmlIterator<R> {
None => { None => {
return Err(format_err!( return Err(format_err!(
"No state in the stack: the XML is not balanced" "No state in the stack: the XML is not balanced"
)) ));
} }
}; };

@ -487,37 +487,37 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
EncodedTerm::NaiveDate(date) => Some(date.year().into()), EncodedTerm::NaiveDate(date) => Some(date.year().into()),
EncodedTerm::DateTime(date_time) => Some(date_time.year().into()), EncodedTerm::DateTime(date_time) => Some(date_time.year().into()),
EncodedTerm::NaiveDateTime(date_time) => Some(date_time.year().into()), EncodedTerm::NaiveDateTime(date_time) => Some(date_time.year().into()),
_ => None _ => None,
}, },
PlanExpression::Month(e) => match self.eval_expression(e, tuple)? { PlanExpression::Month(e) => match self.eval_expression(e, tuple)? {
EncodedTerm::NaiveDate(date) => Some(date.month().into()), EncodedTerm::NaiveDate(date) => Some(date.month().into()),
EncodedTerm::DateTime(date_time) => Some(date_time.month().into()), EncodedTerm::DateTime(date_time) => Some(date_time.month().into()),
EncodedTerm::NaiveDateTime(date_time) => Some(date_time.month().into()), EncodedTerm::NaiveDateTime(date_time) => Some(date_time.month().into()),
_ => None _ => None,
}, },
PlanExpression::Day(e) => match self.eval_expression(e, tuple)? { PlanExpression::Day(e) => match self.eval_expression(e, tuple)? {
EncodedTerm::NaiveDate(date) => Some(date.day().into()), EncodedTerm::NaiveDate(date) => Some(date.day().into()),
EncodedTerm::DateTime(date_time) => Some(date_time.day().into()), EncodedTerm::DateTime(date_time) => Some(date_time.day().into()),
EncodedTerm::NaiveDateTime(date_time) => Some(date_time.day().into()), EncodedTerm::NaiveDateTime(date_time) => Some(date_time.day().into()),
_ => None _ => None,
}, },
PlanExpression::Hours(e) => match self.eval_expression(e, tuple)? { PlanExpression::Hours(e) => match self.eval_expression(e, tuple)? {
EncodedTerm::NaiveTime(time) => Some(time.hour().into()), EncodedTerm::NaiveTime(time) => Some(time.hour().into()),
EncodedTerm::DateTime(date_time) => Some(date_time.hour().into()), EncodedTerm::DateTime(date_time) => Some(date_time.hour().into()),
EncodedTerm::NaiveDateTime(date_time) => Some(date_time.hour().into()), EncodedTerm::NaiveDateTime(date_time) => Some(date_time.hour().into()),
_ => None _ => None,
}, },
PlanExpression::Minutes(e) => match self.eval_expression(e, tuple)? { PlanExpression::Minutes(e) => match self.eval_expression(e, tuple)? {
EncodedTerm::NaiveTime(time) => Some(time.minute().into()), EncodedTerm::NaiveTime(time) => Some(time.minute().into()),
EncodedTerm::DateTime(date_time) => Some(date_time.minute().into()), EncodedTerm::DateTime(date_time) => Some(date_time.minute().into()),
EncodedTerm::NaiveDateTime(date_time) => Some(date_time.minute().into()), EncodedTerm::NaiveDateTime(date_time) => Some(date_time.minute().into()),
_ => None _ => None,
}, },
PlanExpression::Seconds(e) => match self.eval_expression(e, tuple)? { PlanExpression::Seconds(e) => match self.eval_expression(e, tuple)? {
EncodedTerm::NaiveTime(time) => Some(time.second().into()), EncodedTerm::NaiveTime(time) => Some(time.second().into()),
EncodedTerm::DateTime(date_time) => Some(date_time.second().into()), EncodedTerm::DateTime(date_time) => Some(date_time.second().into()),
EncodedTerm::NaiveDateTime(date_time) => Some(date_time.second().into()), EncodedTerm::NaiveDateTime(date_time) => Some(date_time.second().into()),
_ => None _ => None,
}, },
PlanExpression::UUID() => Some(EncodedTerm::NamedNode { PlanExpression::UUID() => Some(EncodedTerm::NamedNode {
iri_id: self iri_id: self
@ -963,26 +963,34 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
EncodedTerm::DecimalLiteral(b) => a.partial_cmp(&b), EncodedTerm::DecimalLiteral(b) => a.partial_cmp(&b),
_ => None, _ => None,
}, },
EncodedTerm::NaiveDate(a) => if let EncodedTerm::NaiveDate(ref b) = b { EncodedTerm::NaiveDate(a) => {
a.partial_cmp(b) if let EncodedTerm::NaiveDate(ref b) = b {
} else { a.partial_cmp(b)
None } else {
}, None
EncodedTerm::NaiveTime(a) => if let EncodedTerm::NaiveTime(ref b) = b { }
a.partial_cmp(b) }
} else { EncodedTerm::NaiveTime(a) => {
None if let EncodedTerm::NaiveTime(ref b) = b {
}, a.partial_cmp(b)
EncodedTerm::DateTime(a) => if let EncodedTerm::DateTime(ref b) = b { } else {
a.partial_cmp(b) None
} else { }
None }
}, EncodedTerm::DateTime(a) => {
EncodedTerm::NaiveDateTime(a) => if let EncodedTerm::NaiveDateTime(ref b) = b { if let EncodedTerm::DateTime(ref b) = b {
a.partial_cmp(b) a.partial_cmp(b)
} else { } else {
None None
}, }
}
EncodedTerm::NaiveDateTime(a) => {
if let EncodedTerm::NaiveDateTime(ref b) = b {
a.partial_cmp(b)
} else {
None
}
}
_ => None, _ => None,
} }
} }

@ -720,10 +720,10 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> {
"integer", "integer",
)? )?
} else if *name == *xsd::DATE { } else if *name == *xsd::DATE {
self.build_cast(parameters, PlanExpression::DateCast, variables, "date")? self.build_cast(parameters, PlanExpression::DateCast, variables, "date")?
} else if *name == *xsd::TIME { } else if *name == *xsd::TIME {
self.build_cast(parameters, PlanExpression::TimeCast, variables, "time")? self.build_cast(parameters, PlanExpression::TimeCast, variables, "time")?
} else if *name == *xsd::DATE_TIME { } else if *name == *xsd::DATE_TIME {
self.build_cast( self.build_cast(
parameters, parameters,
PlanExpression::DateTimeCast, PlanExpression::DateTimeCast,

@ -104,7 +104,7 @@ pub fn write_xml_results<W: Write>(results: QueryResult<'_>, sink: W) -> Result<
QueryResult::Graph(_) => { QueryResult::Graph(_) => {
return Err(format_err!( return Err(format_err!(
"Graphs could not be formatted to SPARQL query results XML format" "Graphs could not be formatted to SPARQL query results XML format"
)) ));
} }
} }
Ok(writer.into_inner()) Ok(writer.into_inner())
@ -310,7 +310,7 @@ impl<R: BufRead> Iterator for ResultsIterator<R> {
None => { None => {
return Some(Err(format_err!( return Some(Err(format_err!(
"No name attribute found for the <binding> tag" "No name attribute found for the <binding> tag"
))) )));
} }
} }
state = State::Binding; state = State::Binding;
@ -386,7 +386,7 @@ impl<R: BufRead> Iterator for ResultsIterator<R> {
return Some(Err(format_err!( return Some(Err(format_err!(
"Unexpected textual value found: {}", "Unexpected textual value found: {}",
self.reader.decode(&data) self.reader.decode(&data)
))) )));
} }
}, },
Err(error) => return Some(Err(error.into())), Err(error) => return Some(Err(error.into())),
@ -403,7 +403,7 @@ impl<R: BufRead> Iterator for ResultsIterator<R> {
return Some(Err(format_err!( return Some(Err(format_err!(
"No variable found for variable {}", "No variable found for variable {}",
self.reader.decode(&var) self.reader.decode(&var)
))) )));
} }
_ => return Some(Err(format_err!("No name found for <binding> tag"))), _ => return Some(Err(format_err!("No name found for <binding> tag"))),
} }

@ -427,7 +427,8 @@ impl<R: Read> TermReader for R {
NaiveTime::from_num_seconds_from_midnight_opt( NaiveTime::from_num_seconds_from_midnight_opt(
self.read_u32::<LittleEndian>()?, self.read_u32::<LittleEndian>()?,
self.read_u32::<LittleEndian>()?, self.read_u32::<LittleEndian>()?,
).ok_or_else(|| format_err!("Invalid time serialization"))?, )
.ok_or_else(|| format_err!("Invalid time serialization"))?,
)), )),
TYPE_DATE_TIME_LITERAL => Ok(EncodedTerm::DateTime(DateTime::from_utc( TYPE_DATE_TIME_LITERAL => Ok(EncodedTerm::DateTime(DateTime::from_utc(
NaiveDateTime::from_timestamp_opt( NaiveDateTime::from_timestamp_opt(

@ -388,7 +388,7 @@ impl<'a> Iterator for TestManifest<'a> {
return Some(Err(format_err!( return Some(Err(format_err!(
"Invalid tests list. Got term {}", "Invalid tests list. Got term {}",
term term
))) )));
} }
None => (), None => (),
} }

@ -591,7 +591,7 @@ impl<'a> Iterator for TestManifest<'a> {
return Some(Err(format_err!( return Some(Err(format_err!(
"action not found for test {}", "action not found for test {}",
test_subject test_subject
))) )));
} }
}; };
let result = match self let result = match self

Loading…
Cancel
Save