Upgrades formatting to 1.31

pull/10/head
Tpt 6 years ago
parent d537a54f0b
commit 0ba67d9614
  1. 283
      lib/src/sparql/algebra.rs
  2. 70
      lib/src/sparql/eval.rs
  3. 17
      lib/src/sparql/parser.rs
  4. 109
      lib/src/sparql/plan.rs
  5. 62
      lib/src/sparql/xml_results.rs
  6. 3
      lib/src/store/encoded.rs
  7. 12
      lib/src/store/numeric_encoder.rs
  8. 22
      lib/tests/rdf_test_cases.rs
  9. 22
      lib/tests/sparql_test_cases.rs
  10. 5
      python/src/lib.rs
  11. 15
      server/src/main.rs

@ -747,7 +747,8 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
SparqlExpression(&*b),
SparqlExpression(cv)
)
}).unwrap_or_else(|| {
})
.unwrap_or_else(|| {
write!(
f,
"SUBSTR({}, {})",
@ -1130,31 +1131,35 @@ impl<'a> fmt::Display for SparqlGraphPattern<'a> {
SparqlGraphPattern(&*a),
SparqlGraphPattern(&*b)
),
GraphPattern::Service(n, p, s) => if *s {
write!(f, "SERVICE SILENT {} {{ {} }}", n, SparqlGraphPattern(&*p))
} else {
write!(f, "SERVICE {} {{ {} }}", n, SparqlGraphPattern(&*p))
},
GraphPattern::Data(bs) => if bs.is_empty() {
Ok(())
} else {
write!(f, "VALUES ( ")?;
for var in bs.variables() {
write!(f, "{} ", var)?;
GraphPattern::Service(n, p, s) => {
if *s {
write!(f, "SERVICE SILENT {} {{ {} }}", n, SparqlGraphPattern(&*p))
} else {
write!(f, "SERVICE {} {{ {} }}", n, SparqlGraphPattern(&*p))
}
write!(f, ") {{ ")?;
for values in bs.values_iter() {
write!(f, "( ")?;
for val in values {
match val {
Some(val) => write!(f, "{} ", val),
None => write!(f, "UNDEF "),
}?;
}
GraphPattern::Data(bs) => {
if bs.is_empty() {
Ok(())
} else {
write!(f, "VALUES ( ")?;
for var in bs.variables() {
write!(f, "{} ", var)?;
}
write!(f, ") ")?;
write!(f, ") {{ ")?;
for values in bs.values_iter() {
write!(f, "( ")?;
for val in values {
match val {
Some(val) => write!(f, "{} ", val),
None => write!(f, "UNDEF "),
}?;
}
write!(f, ") ")?;
}
write!(f, " }}")
}
write!(f, " }}")
},
}
GraphPattern::AggregateJoin(GroupPattern(group, p), agg) => write!(
f,
"{{ SELECT {} WHERE {{ {} }} GROUP BY {} }}",
@ -1301,63 +1306,81 @@ pub enum Aggregation {
impl fmt::Display for Aggregation {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Aggregation::Count(e, distinct) => if *distinct {
e.as_ref()
.map(|ex| write!(f, "COUNT(DISTINCT {})", ex))
.unwrap_or_else(|| write!(f, "COUNT(DISTINCT *)"))
} else {
e.as_ref()
.map(|ex| write!(f, "COUNT({})", ex))
.unwrap_or_else(|| write!(f, "COUNT(*)"))
},
Aggregation::Sum(e, distinct) => if *distinct {
write!(f, "Aggregation(Distinct({}), Sum, {{}})", e)
} else {
write!(f, "Aggregation({}, Sum, {{}})", e)
},
Aggregation::Min(e, distinct) => if *distinct {
write!(f, "Aggregation(Distinct({}), Min, {{}})", e)
} else {
write!(f, "Aggregation({}, Min, {{}})", e)
},
Aggregation::Max(e, distinct) => if *distinct {
write!(f, "Aggregation(Distinct({}), Max, {{}})", e)
} else {
write!(f, "Aggregation({}, Max, {{}})", e)
},
Aggregation::Avg(e, distinct) => if *distinct {
write!(f, "Aggregation(Distinct({}), Avg, {{}})", e)
} else {
write!(f, "Aggregation({}, Avg, {{}})", e)
},
Aggregation::Sample(e, distinct) => if *distinct {
write!(f, "Aggregation(Distinct({}), Sum, {{}})", e)
} else {
write!(f, "Aggregation({}, Sample, {{}})", e)
},
Aggregation::GroupConcat(e, distinct, sep) => if *distinct {
sep.as_ref()
.map(|s| {
write!(
Aggregation::Count(e, distinct) => {
if *distinct {
e.as_ref()
.map(|ex| write!(f, "COUNT(DISTINCT {})", ex))
.unwrap_or_else(|| write!(f, "COUNT(DISTINCT *)"))
} else {
e.as_ref()
.map(|ex| write!(f, "COUNT({})", ex))
.unwrap_or_else(|| write!(f, "COUNT(*)"))
}
}
Aggregation::Sum(e, distinct) => {
if *distinct {
write!(f, "Aggregation(Distinct({}), Sum, {{}})", e)
} else {
write!(f, "Aggregation({}, Sum, {{}})", e)
}
}
Aggregation::Min(e, distinct) => {
if *distinct {
write!(f, "Aggregation(Distinct({}), Min, {{}})", e)
} else {
write!(f, "Aggregation({}, Min, {{}})", e)
}
}
Aggregation::Max(e, distinct) => {
if *distinct {
write!(f, "Aggregation(Distinct({}), Max, {{}})", e)
} else {
write!(f, "Aggregation({}, Max, {{}})", e)
}
}
Aggregation::Avg(e, distinct) => {
if *distinct {
write!(f, "Aggregation(Distinct({}), Avg, {{}})", e)
} else {
write!(f, "Aggregation({}, Avg, {{}})", e)
}
}
Aggregation::Sample(e, distinct) => {
if *distinct {
write!(f, "Aggregation(Distinct({}), Sum, {{}})", e)
} else {
write!(f, "Aggregation({}, Sample, {{}})", e)
}
}
Aggregation::GroupConcat(e, distinct, sep) => {
if *distinct {
sep.as_ref()
.map(|s| {
write!(
f,
"Aggregation(Distinct({}), GroupConcat, {{\"separator\" → \"{}\"}})",
e,
s.escape()
)
})
.unwrap_or_else(|| write!(f, "Aggregation(Distinct({}), GroupConcat, {{}})", e))
} else {
sep.as_ref()
.map(|s| {
write!(
f,
"Aggregation({}, GroupConcat, {{\"separator\" → \"{}\"}})",
e,
s.escape()
)
})
.unwrap_or_else(|| write!(f, "Aggregation(Distinct({}), GroupConcat, {{}})", e))
},
})
.unwrap_or_else(|| {
write!(f, "Aggregation(Distinct({}), GroupConcat, {{}})", e)
})
} else {
sep.as_ref()
.map(|s| {
write!(
f,
"Aggregation({}, GroupConcat, {{\"separator\" → \"{}\"}})",
e,
s.escape()
)
})
.unwrap_or_else(|| {
write!(f, "Aggregation(Distinct({}), GroupConcat, {{}})", e)
})
}
}
}
}
}
@ -1367,63 +1390,77 @@ struct SparqlAggregation<'a>(&'a Aggregation);
impl<'a> fmt::Display for SparqlAggregation<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
Aggregation::Count(e, distinct) => if *distinct {
if let Some(e) = e {
write!(f, "COUNT(DISTINCT {})", SparqlExpression(e))
Aggregation::Count(e, distinct) => {
if *distinct {
if let Some(e) = e {
write!(f, "COUNT(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "COUNT(DISTINCT *)")
}
} else if let Some(e) = e {
write!(f, "COUNT({})", SparqlExpression(e))
} else {
write!(f, "COUNT(DISTINCT *)")
write!(f, "COUNT(*)")
}
} else if let Some(e) = e {
write!(f, "COUNT({})", SparqlExpression(e))
} else {
write!(f, "COUNT(*)")
},
Aggregation::Sum(e, distinct) => if *distinct {
write!(f, "SUM(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "SUM({})", SparqlExpression(e))
},
Aggregation::Min(e, distinct) => if *distinct {
write!(f, "MIN(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "MIN({})", SparqlExpression(e))
},
Aggregation::Max(e, distinct) => if *distinct {
write!(f, "MAX(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "MAX({})", SparqlExpression(e))
},
Aggregation::Avg(e, distinct) => if *distinct {
write!(f, "AVG(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "AVG({})", SparqlExpression(e))
},
Aggregation::Sample(e, distinct) => if *distinct {
write!(f, "SAMPLE(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "SAMPLE({})", SparqlExpression(e))
},
Aggregation::GroupConcat(e, distinct, sep) => if *distinct {
if let Some(sep) = sep {
}
Aggregation::Sum(e, distinct) => {
if *distinct {
write!(f, "SUM(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "SUM({})", SparqlExpression(e))
}
}
Aggregation::Min(e, distinct) => {
if *distinct {
write!(f, "MIN(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "MIN({})", SparqlExpression(e))
}
}
Aggregation::Max(e, distinct) => {
if *distinct {
write!(f, "MAX(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "MAX({})", SparqlExpression(e))
}
}
Aggregation::Avg(e, distinct) => {
if *distinct {
write!(f, "AVG(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "AVG({})", SparqlExpression(e))
}
}
Aggregation::Sample(e, distinct) => {
if *distinct {
write!(f, "SAMPLE(DISTINCT {})", SparqlExpression(e))
} else {
write!(f, "SAMPLE({})", SparqlExpression(e))
}
}
Aggregation::GroupConcat(e, distinct, sep) => {
if *distinct {
if let Some(sep) = sep {
write!(
f,
"GROUP_CONCAT(DISTINCT {}; SEPARATOR = \"{}\")",
SparqlExpression(e),
sep.escape()
)
} else {
write!(f, "GROUP_CONCAT(DISTINCT {})", SparqlExpression(e))
}
} else if let Some(sep) = sep {
write!(
f,
"GROUP_CONCAT(DISTINCT {}; SEPARATOR = \"{}\")",
"GROUP_CONCAT({}; SEPARATOR = \"{}\")",
SparqlExpression(e),
sep.escape()
)
} else {
write!(f, "GROUP_CONCAT(DISTINCT {})", SparqlExpression(e))
write!(f, "GROUP_CONCAT({})", SparqlExpression(e))
}
} else if let Some(sep) = sep {
write!(
f,
"GROUP_CONCAT({}; SEPARATOR = \"{}\")",
SparqlExpression(e),
sep.escape()
)
} else {
write!(f, "GROUP_CONCAT({})", SparqlExpression(e))
},
}
}
}
}

@ -358,7 +358,8 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
)? {
Ordering::Greater | Ordering::Equal => true,
Ordering::Less => false,
}.into(),
}
.into(),
),
PlanExpression::Lower(a, b) => Some(
(self.partial_cmp_literals(
@ -374,7 +375,8 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
)? {
Ordering::Less | Ordering::Equal => true,
Ordering::Greater => false,
}.into(),
}
.into(),
),
PlanExpression::In(e, l) => {
let needed = self.eval_expression(e, tuple)?;
@ -493,11 +495,13 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
}
None
}
PlanExpression::If(a, b, c) => if self.to_bool(self.eval_expression(a, tuple)?)? {
self.eval_expression(b, tuple)
} else {
self.eval_expression(c, tuple)
},
PlanExpression::If(a, b, c) => {
if self.to_bool(self.eval_expression(a, tuple)?)? {
self.eval_expression(b, tuple)
} else {
self.eval_expression(c, tuple)
}
}
PlanExpression::StrLang(lexical_form, lang_tag) => {
Some(EncodedTerm::LangStringLiteral {
value_id: self
@ -525,7 +529,8 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
| EncodedTerm::IntegerLiteral(_)
| EncodedTerm::DecimalLiteral(_) => true,
_ => false,
}.into(),
}
.into(),
),
PlanExpression::LangMatches(language_tag, language_range) => {
let language_tag =
@ -539,7 +544,8 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
LanguageTag::from_str(&language_range)
.ok()?
.matches(&LanguageTag::from_str(&language_tag).ok()?)
}.into(),
}
.into(),
)
}
PlanExpression::Regex(text, pattern, flags) => {
@ -634,7 +640,8 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
Decimal::one()
} else {
Decimal::zero()
}.into(),
}
.into(),
),
EncodedTerm::SimpleLiteral { value_id }
| EncodedTerm::StringLiteral { value_id } => Some(EncodedTerm::DecimalLiteral(
@ -802,7 +809,8 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
Some(term) => Some(encoder.decode_term(term)?),
None => None,
})
}).collect()
})
.collect()
})),
)
}
@ -826,11 +834,13 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
self.eval_expression(expression, tuple_b),
) {
(Some(a), Some(b)) => match a {
EncodedTerm::BlankNode(a) => if let EncodedTerm::BlankNode(b) = b {
a.cmp(&b)
} else {
Ordering::Less
},
EncodedTerm::BlankNode(a) => {
if let EncodedTerm::BlankNode(b) = b {
a.cmp(&b)
} else {
Ordering::Less
}
}
EncodedTerm::NamedNode { iri_id: a } => match b {
EncodedTerm::NamedNode { iri_id: b } => {
self.compare_str_ids(a, b).unwrap_or(Ordering::Equal)
@ -970,9 +980,11 @@ fn combine_tuples(a: &[Option<EncodedTerm>], b: &[Option<EncodedTerm>]) -> Optio
for (key, a_value) in a.into_iter().enumerate() {
if let Some(a_value) = a_value {
match b[key] {
Some(ref b_value) => if a_value != b_value {
return None;
},
Some(ref b_value) => {
if a_value != b_value {
return None;
}
}
None => result[key] = Some(*a_value),
}
}
@ -983,9 +995,11 @@ fn combine_tuples(a: &[Option<EncodedTerm>], b: &[Option<EncodedTerm>]) -> Optio
for (key, b_value) in b.into_iter().enumerate() {
if let Some(b_value) = b_value {
match a[key] {
Some(ref a_value) => if a_value != b_value {
return None;
},
Some(ref a_value) => {
if a_value != b_value {
return None;
}
}
None => result[key] = Some(*b_value),
}
}
@ -1128,11 +1142,13 @@ impl<'a> Iterator for HashDeduplicateIterator<'a> {
fn next(&mut self) -> Option<Result<EncodedTuple>> {
match self.iter.next()? {
Ok(tuple) => if self.already_seen.insert(tuple.clone()) {
Some(Ok(tuple))
} else {
self.next()
},
Ok(tuple) => {
if self.already_seen.insert(tuple.clone()) {
Some(Ok(tuple))
} else {
self.next()
}
}
Err(error) => Some(Err(error)),
}
}

@ -179,7 +179,8 @@ mod grammar {
iter.fold(None, |a, b| match a {
Some(av) => Some(combine(av, b)),
None => Some(b),
}).ok_or("The iterator should not be empty")
})
.ok_or("The iterator should not be empty")
}
enum SelectionOption {
@ -253,12 +254,14 @@ mod grammar {
for sel_item in sel_items {
match sel_item {
SelectionMember::Variable(v) => pv.push(v),
SelectionMember::Expression(e, v) => if pv.contains(&v) {
//TODO: fail
} else {
p = GraphPattern::Extend(Box::new(p), v.clone(), e);
pv.push(v);
},
SelectionMember::Expression(e, v) => {
if pv.contains(&v) {
//TODO: fail
} else {
p = GraphPattern::Extend(Box::new(p), v.clone(), e);
pv.push(v);
}
}
}
}
}

@ -483,7 +483,8 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> {
OrderComparator::Desc(e) => {
Ok(Comparator::Desc(self.build_for_expression(e, variables)?))
}
}).collect();
})
.collect();
PlanNode::Sort {
child: Box::new(self.build_for_graph_pattern(l, input, variables, graph_name)?),
by: by?,
@ -662,43 +663,45 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> {
None => None,
},
),
Expression::CustomFunctionCall(name, parameters) => if *name == *xsd::BOOLEAN {
self.build_cast(
parameters,
PlanExpression::BooleanCast,
variables,
"boolean",
)?
} else if *name == *xsd::DOUBLE {
self.build_cast(parameters, PlanExpression::DoubleCast, variables, "double")?
} else if *name == *xsd::FLOAT {
self.build_cast(parameters, PlanExpression::FloatCast, variables, "float")?
} else if *name == *xsd::DECIMAL {
self.build_cast(
parameters,
PlanExpression::DecimalCast,
variables,
"decimal",
)?
} else if *name == *xsd::INTEGER {
self.build_cast(
parameters,
PlanExpression::IntegerCast,
variables,
"integer",
)?
} else if *name == *xsd::DATE_TIME {
self.build_cast(
parameters,
PlanExpression::DateTimeCast,
variables,
"dateTime",
)?
} else if *name == *xsd::STRING {
self.build_cast(parameters, PlanExpression::StringCast, variables, "string")?
} else {
Err(format_err!("Not supported custom function {}", expression))?
},
Expression::CustomFunctionCall(name, parameters) => {
if *name == *xsd::BOOLEAN {
self.build_cast(
parameters,
PlanExpression::BooleanCast,
variables,
"boolean",
)?
} else if *name == *xsd::DOUBLE {
self.build_cast(parameters, PlanExpression::DoubleCast, variables, "double")?
} else if *name == *xsd::FLOAT {
self.build_cast(parameters, PlanExpression::FloatCast, variables, "float")?
} else if *name == *xsd::DECIMAL {
self.build_cast(
parameters,
PlanExpression::DecimalCast,
variables,
"decimal",
)?
} else if *name == *xsd::INTEGER {
self.build_cast(
parameters,
PlanExpression::IntegerCast,
variables,
"integer",
)?
} else if *name == *xsd::DATE_TIME {
self.build_cast(
parameters,
PlanExpression::DateTimeCast,
variables,
"dateTime",
)?
} else if *name == *xsd::STRING {
self.build_cast(parameters, PlanExpression::StringCast, variables, "string")?
} else {
Err(format_err!("Not supported custom function {}", expression))?
}
}
_ => unimplemented!(),
})
}
@ -780,7 +783,8 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> {
}
}
Ok(result)
}).collect()
})
.collect()
}
fn build_for_graph_template(
@ -809,7 +813,8 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> {
&mut bnodes,
)?,
})
}).collect()
})
.collect()
}
fn template_value_from_term_or_variable(
@ -822,11 +827,13 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> {
TermOrVariable::Term(term) => {
TripleTemplateValue::Constant(self.store.encoder().encode_term(term)?)
}
TermOrVariable::Variable(variable) => if variable.has_name() {
TripleTemplateValue::Variable(variable_key(variables, variable))
} else {
TripleTemplateValue::BlankNode(variable_key(bnodes, variable))
},
TermOrVariable::Variable(variable) => {
if variable.has_name() {
TripleTemplateValue::Variable(variable_key(variables, variable))
} else {
TripleTemplateValue::BlankNode(variable_key(bnodes, variable))
}
}
})
}
@ -840,11 +847,13 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> {
NamedNodeOrVariable::NamedNode(term) => {
TripleTemplateValue::Constant(self.store.encoder().encode_named_node(term)?)
}
NamedNodeOrVariable::Variable(variable) => if variable.has_name() {
TripleTemplateValue::Variable(variable_key(variables, variable))
} else {
TripleTemplateValue::BlankNode(variable_key(bnodes, variable))
},
NamedNodeOrVariable::Variable(variable) => {
if variable.has_name() {
TripleTemplateValue::Variable(variable_key(variables, variable))
} else {
TripleTemplateValue::BlankNode(variable_key(bnodes, variable))
}
}
})
}
}

@ -285,37 +285,41 @@ impl<R: BufRead> Iterator for ResultsIterator<R> {
}
match event {
Event::Start(event) => match state {
State::Start => if event.name() == b"result" {
state = State::Result;
} else {
return Some(Err(format_err!(
"Expecting <result>, found {}",
self.reader.decode(event.name())
)));
},
State::Result => if event.name() == b"binding" {
match event
.attributes()
.filter_map(|attr| attr.ok())
.find(|attr| attr.key == b"name")
{
Some(attr) => match attr.unescaped_value() {
Ok(var) => current_var = Some(var.to_vec()),
Err(error) => return Some(Err(error.into())),
},
None => {
return Some(Err(format_err!(
"No name attribute found for the <binding> tag"
)))
State::Start => {
if event.name() == b"result" {
state = State::Result;
} else {
return Some(Err(format_err!(
"Expecting <result>, found {}",
self.reader.decode(event.name())
)));
}
}
State::Result => {
if event.name() == b"binding" {
match event
.attributes()
.filter_map(|attr| attr.ok())
.find(|attr| attr.key == b"name")
{
Some(attr) => match attr.unescaped_value() {
Ok(var) => current_var = Some(var.to_vec()),
Err(error) => return Some(Err(error.into())),
},
None => {
return Some(Err(format_err!(
"No name attribute found for the <binding> tag"
)))
}
}
state = State::Binding;
} else {
return Some(Err(format_err!(
"Expecting <binding>, found {}",
self.reader.decode(event.name())
)));
}
state = State::Binding;
} else {
return Some(Err(format_err!(
"Expecting <binding>, found {}",
self.reader.decode(event.name())
)));
},
}
State::Binding => {
if term.is_some() {
return Some(Err(format_err!(

@ -845,7 +845,8 @@ impl<S: EncodedQuadsStore> Graph for StoreUnionGraph<S> {
encoder.encode_named_or_blank_node(triple.subject())?,
encoder.encode_named_node(triple.predicate())?,
encoder.encode_term(triple.object())?,
)?.any(|_| true))
)?
.any(|_| true))
}
fn insert(&self, _triple: &Triple) -> Result<()> {

@ -380,7 +380,8 @@ impl<R: Read> TermReader for R {
NaiveDateTime::from_timestamp_opt(
self.read_i64::<LittleEndian>()?,
self.read_u32::<LittleEndian>()?,
).ok_or_else(|| format_err!("Invalid date time serialization"))?,
)
.ok_or_else(|| format_err!("Invalid date time serialization"))?,
FixedOffset::east_opt(self.read_i32::<LittleEndian>()?)
.ok_or_else(|| format_err!("Invalid timezone offset"))?,
))),
@ -388,7 +389,8 @@ impl<R: Read> TermReader for R {
NaiveDateTime::from_timestamp_opt(
self.read_i64::<LittleEndian>()?,
self.read_u32::<LittleEndian>()?,
).ok_or_else(|| format_err!("Invalid date time serialization"))?,
)
.ok_or_else(|| format_err!("Invalid date time serialization"))?,
)),
_ => Err(format_err!("the term buffer has an invalid type id")),
}
@ -644,14 +646,16 @@ impl<S: StringStore> Encoder<S> {
} => Ok(Literal::new_language_tagged_literal(
self.string_store.get_str(value_id)?,
self.string_store.get_str(language_id)?,
).into()),
)
.into()),
EncodedTerm::TypedLiteral {
value_id,
datatype_id,
} => Ok(Literal::new_typed_literal(
self.string_store.get_str(value_id)?,
NamedNode::from(self.string_store.get_url(datatype_id)?),
).into()),
)
.into()),
EncodedTerm::StringLiteral { value_id } => {
Ok(Literal::from(self.string_store.get_str(value_id)?).into())
}

@ -96,10 +96,11 @@ fn turtle_w3c_testsuite() {
.map(|r| client.load_turtle(r))
.unwrap_or_else(|| Ok(MemoryGraph::default()));
assert!(
action_graph.is_err() || !action_graph
.unwrap()
.is_isomorphic(&result_graph.unwrap())
.unwrap(),
action_graph.is_err()
|| !action_graph
.unwrap()
.is_isomorphic(&result_graph.unwrap())
.unwrap(),
"Failure on {}",
test
);
@ -210,12 +211,13 @@ impl RDFClient {
fn get(&self, url: &Url) -> Result<Response> {
match self.client.get(url.clone()).send() {
Ok(response) => Ok(response),
Err(error) => if error.description() == "parsed HTTP message from remote is incomplete"
{
self.get(url)
} else {
Err(format_err!("HTTP request error: {}", error.description()))
},
Err(error) => {
if error.description() == "parsed HTTP message from remote is incomplete" {
self.get(url)
} else {
Err(format_err!("HTTP request error: {}", error.description()))
}
}
}
}
}

@ -37,7 +37,8 @@ fn sparql_w3c_syntax_testsuite() {
.unwrap();
let manifest_11_url = Url::parse(
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest.ttl",
).unwrap();
)
.unwrap();
let test_blacklist = vec![
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql2/manifest#syntax-form-construct02").unwrap(),
//TODO: Deserialization of the serialization failing:
@ -308,12 +309,13 @@ impl RDFClient {
fn get(&self, url: &Url) -> Result<Response> {
match self.client.get(url.clone()).send() {
Ok(response) => Ok(response),
Err(error) => if error.description() == "parsed HTTP message from remote is incomplete"
{
self.get(url)
} else {
Err(format_err!("HTTP request error: {}", error.description()))
},
Err(error) => {
if error.description() == "parsed HTTP message from remote is incomplete" {
self.get(url)
} else {
Err(format_err!("HTTP request error: {}", error.description()))
}
}
}
}
}
@ -328,7 +330,8 @@ mod rs {
.unwrap();
pub static ref RESULT_VARIABLE: NamedNode = NamedNode::from_str(
"http://www.w3.org/2001/sw/DataAccess/tests/result-set#resultVariable"
).unwrap();
)
.unwrap();
pub static ref SOLUTION: NamedNode =
NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/result-set#solution")
.unwrap();
@ -583,7 +586,8 @@ impl<'a> Iterator for TestManifest<'a> {
.filter_map(|g| match g {
Ok(Term::NamedNode(q)) => Some(q.into()),
_ => None,
}).collect();
})
.collect();
(query, data, graph_data)
}
Some(_) => return Some(Err(format_err!("invalid action"))),

@ -1,7 +1,4 @@
#![cfg_attr(
feature = "cargo-clippy",
allow(zero_ptr, transmute_ptr_to_ptr)
)]
#![cfg_attr(feature = "cargo-clippy", allow(zero_ptr, transmute_ptr_to_ptr))]
#[macro_use]
extern crate cpython;

@ -79,18 +79,21 @@ pub fn main() -> Result<(), failure::Error> {
.long("bind")
.help("Specify a server socket to bind using the format $(HOST):$(PORT)")
.takes_value(true),
).arg(
)
.arg(
Arg::with_name("ntriples")
.long("ntriples")
.help("Load a N-Triples file in the server at startup")
.takes_value(true),
).arg(
)
.arg(
Arg::with_name("file")
.long("file")
.short("f")
.help("File in which persist the dataset")
.takes_value(true),
).get_matches();
)
.get_matches();
let file = matches.value_of("file").map(|v| v.to_string());
if let Some(file) = file {
@ -233,7 +236,8 @@ fn parse_urlencoded_query_request(query: &[u8]) -> Result<QueryRequest, failure:
.find(|(key, _)| key == "query")
.map(|(_, value)| QueryRequest {
query: value.to_string(),
}).ok_or_else(|| format_err!("'query' parameter not found"))
})
.ok_or_else(|| format_err!("'query' parameter not found"))
}
fn evaluate_sparql_query<D: SparqlDataset + Send + Sync + RefUnwindSafe + 'static>(
@ -309,7 +313,8 @@ mod tests {
"http://localhost/query",
"SELECT * WHERE { ?s ?p ?o }",
Mime::from_str("application/sparql-query").unwrap(),
).perform()
)
.perform()
.unwrap();
assert_eq!(response.status(), StatusCode::OK);
}

Loading…
Cancel
Save