Format changes with Rust 1.28

pull/10/head
Tpt 6 years ago
parent 39116bf2c9
commit e5a9d7672b
  1. 24
      src/sparql/algebra.rs
  2. 6
      src/store/memory.rs
  3. 5
      src/store/rocksdb/mod.rs
  4. 9
      src/store/rocksdb/storage.rs
  5. 24
      tests/rdf_test_cases.rs

@ -280,7 +280,8 @@ impl fmt::Display for Expression {
Expression::DatatypeFunctionCall(e) => write!(f, "DATATYPE({})", e), Expression::DatatypeFunctionCall(e) => write!(f, "DATATYPE({})", e),
Expression::BoundFunctionCall(v) => write!(f, "BOUND({})", v), Expression::BoundFunctionCall(v) => write!(f, "BOUND({})", v),
Expression::IRIFunctionCall(e) => write!(f, "IRI({})", e), Expression::IRIFunctionCall(e) => write!(f, "IRI({})", e),
Expression::BNodeFunctionCall(v) => v.as_ref() Expression::BNodeFunctionCall(v) => v
.as_ref()
.map(|id| write!(f, "BOUND({})", id)) .map(|id| write!(f, "BOUND({})", id))
.unwrap_or_else(|| write!(f, "BOUND()")), .unwrap_or_else(|| write!(f, "BOUND()")),
Expression::RandFunctionCall() => write!(f, "RAND()"), Expression::RandFunctionCall() => write!(f, "RAND()"),
@ -296,11 +297,13 @@ impl fmt::Display for Expression {
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(", ") .join(", ")
), ),
Expression::SubStrFunctionCall(a, b, c) => c.as_ref() Expression::SubStrFunctionCall(a, b, c) => c
.as_ref()
.map(|cv| write!(f, "SUBSTR({}, {}, {})", a, b, cv)) .map(|cv| write!(f, "SUBSTR({}, {}, {})", a, b, cv))
.unwrap_or_else(|| write!(f, "SUBSTR({}, {})", a, b)), .unwrap_or_else(|| write!(f, "SUBSTR({}, {})", a, b)),
Expression::StrLenFunctionCall(e) => write!(f, "STRLEN({})", e), Expression::StrLenFunctionCall(e) => write!(f, "STRLEN({})", e),
Expression::ReplaceFunctionCall(a, b, c, d) => d.as_ref() Expression::ReplaceFunctionCall(a, b, c, d) => d
.as_ref()
.map(|dv| write!(f, "REPLACE({}, {}, {}, {})", a, b, c, dv)) .map(|dv| write!(f, "REPLACE({}, {}, {}, {})", a, b, c, dv))
.unwrap_or_else(|| write!(f, "REPLACE({}, {}, {})", a, b, c)), .unwrap_or_else(|| write!(f, "REPLACE({}, {}, {})", a, b, c)),
Expression::UCaseFunctionCall(e) => write!(f, "UCASE({})", e), Expression::UCaseFunctionCall(e) => write!(f, "UCASE({})", e),
@ -342,7 +345,8 @@ impl fmt::Display for Expression {
Expression::IsBlankFunctionCall(e) => write!(f, "isBLANK({})", e), Expression::IsBlankFunctionCall(e) => write!(f, "isBLANK({})", e),
Expression::IsLiteralFunctionCall(e) => write!(f, "isLITERAL({})", e), Expression::IsLiteralFunctionCall(e) => write!(f, "isLITERAL({})", e),
Expression::IsNumericFunctionCall(e) => write!(f, "isNUMERIC({})", e), Expression::IsNumericFunctionCall(e) => write!(f, "isNUMERIC({})", e),
Expression::RegexFunctionCall(a, b, c) => c.as_ref() Expression::RegexFunctionCall(a, b, c) => c
.as_ref()
.map(|cv| write!(f, "REGEX({}, {}, {})", a, b, cv)) .map(|cv| write!(f, "REGEX({}, {}, {})", a, b, cv))
.unwrap_or_else(|| write!(f, "REGEX({}, {})", a, b)), .unwrap_or_else(|| write!(f, "REGEX({}, {})", a, b)),
Expression::CustomFunctionCall(iri, args) => write!( Expression::CustomFunctionCall(iri, args) => write!(
@ -471,7 +475,8 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
Expression::DatatypeFunctionCall(e) => write!(f, "DATATYPE({})", SparqlExpression(&*e)), Expression::DatatypeFunctionCall(e) => write!(f, "DATATYPE({})", SparqlExpression(&*e)),
Expression::BoundFunctionCall(v) => write!(f, "BOUND({})", v), Expression::BoundFunctionCall(v) => write!(f, "BOUND({})", v),
Expression::IRIFunctionCall(e) => write!(f, "IRI({})", SparqlExpression(&*e)), Expression::IRIFunctionCall(e) => write!(f, "IRI({})", SparqlExpression(&*e)),
Expression::BNodeFunctionCall(v) => v.as_ref() Expression::BNodeFunctionCall(v) => v
.as_ref()
.map(|id| write!(f, "BOUND({})", SparqlExpression(&*id))) .map(|id| write!(f, "BOUND({})", SparqlExpression(&*id)))
.unwrap_or_else(|| write!(f, "BOUND()")), .unwrap_or_else(|| write!(f, "BOUND()")),
Expression::RandFunctionCall() => write!(f, "RAND()"), Expression::RandFunctionCall() => write!(f, "RAND()"),
@ -487,7 +492,8 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(", ") .join(", ")
), ),
Expression::SubStrFunctionCall(a, b, c) => c.as_ref() Expression::SubStrFunctionCall(a, b, c) => c
.as_ref()
.map(|cv| { .map(|cv| {
write!( write!(
f, f,
@ -506,7 +512,8 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
) )
}), }),
Expression::StrLenFunctionCall(e) => write!(f, "STRLEN({})", SparqlExpression(&*e)), Expression::StrLenFunctionCall(e) => write!(f, "STRLEN({})", SparqlExpression(&*e)),
Expression::ReplaceFunctionCall(a, b, c, d) => d.as_ref() Expression::ReplaceFunctionCall(a, b, c, d) => d
.as_ref()
.map(|dv| { .map(|dv| {
write!( write!(
f, f,
@ -617,7 +624,8 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
Expression::IsNumericFunctionCall(e) => { Expression::IsNumericFunctionCall(e) => {
write!(f, "isNUMERIC({})", SparqlExpression(&*e)) write!(f, "isNUMERIC({})", SparqlExpression(&*e))
} }
Expression::RegexFunctionCall(a, b, c) => c.as_ref() Expression::RegexFunctionCall(a, b, c) => c
.as_ref()
.map(|cv| { .map(|cv| {
write!( write!(
f, f,

@ -166,10 +166,12 @@ impl<'a> Iterator for ListIterator<'a> {
fn next(&mut self) -> Option<Term> { fn next(&mut self) -> Option<Term> {
match self.current_node.clone() { match self.current_node.clone() {
Some(current) => { Some(current) => {
let result = self.graph let result = self
.graph
.object_for_subject_predicate(&current, &rdf::FIRST)? .object_for_subject_predicate(&current, &rdf::FIRST)?
.clone(); .clone();
self.current_node = match self.graph self.current_node = match self
.graph
.object_for_subject_predicate(&current, &rdf::REST) .object_for_subject_predicate(&current, &rdf::REST)
{ {
Some(Term::NamedNode(n)) if *n == *rdf::NIL => None, Some(Term::NamedNode(n)) if *n == *rdf::NIL => None,

@ -40,12 +40,13 @@ impl RocksDbDataset {
}) })
} }
fn quads_for_subject( pub fn quads_for_subject(
&self, &self,
subject: &NamedOrBlankNode, subject: &NamedOrBlankNode,
) -> Result<QuadsIterator<FilteringEncodedQuadsIterator<SPOGIndexIterator>>> { ) -> Result<QuadsIterator<FilteringEncodedQuadsIterator<SPOGIndexIterator>>> {
Ok(QuadsIterator { Ok(QuadsIterator {
iter: self.store iter: self
.store
.quads_for_subject(self.store.encoder().encode_named_or_blank_node(subject)?)?, .quads_for_subject(self.store.encoder().encode_named_or_blank_node(subject)?)?,
encoder: self.store.encoder(), encoder: self.store.encoder(),
}) })

@ -180,11 +180,13 @@ impl<'a> BytesStore for RocksDbBytesStore<'a> {
match self.0.db.get_cf(self.0.str2id_cf, value)? { match self.0.db.get_cf(self.0.str2id_cf, value)? {
Some(id) => id_buffer.copy_from_slice(&id), Some(id) => id_buffer.copy_from_slice(&id),
None => { None => {
let id = to_bytes(self.0 let id = to_bytes(
self.0
.str_id_counter .str_id_counter
.lock() .lock()
.unwrap() .unwrap()
.get_and_increment(&self.0.db)?); .get_and_increment(&self.0.db)?,
);
let mut batch = WriteBatch::default(); let mut batch = WriteBatch::default();
batch.put_cf(self.0.id2str_cf, &id, value)?; batch.put_cf(self.0.id2str_cf, &id, value)?;
batch.put_cf(self.0.str2id_cf, value, &id)?; batch.put_cf(self.0.str2id_cf, value, &id)?;
@ -210,7 +212,8 @@ impl RocksDBCounter {
} }
fn get_and_increment(&self, db: &DB) -> Result<usize> { fn get_and_increment(&self, db: &DB) -> Result<usize> {
let value = db.get(self.name.as_bytes())? let value = db
.get(self.name.as_bytes())?
.map(|b| { .map(|b| {
let mut buf = [0 as u8; size_of::<usize>()]; let mut buf = [0 as u8; size_of::<usize>()];
buf.copy_from_slice(&b); buf.copy_from_slice(&b);

@ -88,7 +88,8 @@ fn turtle_w3c_testsuite() {
} }
} else if test.kind == "TestTurtleNegativeEval" { } else if test.kind == "TestTurtleNegativeEval" {
let action_graph = client.load_turtle(test.action.clone()); let action_graph = client.load_turtle(test.action.clone());
let result_graph = test.result let result_graph = test
.result
.clone() .clone()
.map(|r| client.load_turtle(r)) .map(|r| client.load_turtle(r))
.unwrap_or_else(|| Ok(MemoryGraph::default())); .unwrap_or_else(|| Ok(MemoryGraph::default()));
@ -272,7 +273,8 @@ impl<'a> Iterator for TestManifest<'a> {
match self.tests_to_do.pop() { match self.tests_to_do.pop() {
Some(Term::NamedNode(test_node)) => { Some(Term::NamedNode(test_node)) => {
let test_subject = NamedOrBlankNode::from(test_node.clone()); let test_subject = NamedOrBlankNode::from(test_node.clone());
let kind = match self.graph let kind = match self
.graph
.object_for_subject_predicate(&test_subject, &rdf::TYPE) .object_for_subject_predicate(&test_subject, &rdf::TYPE)
{ {
Some(Term::NamedNode(c)) => match c.value().split("#").last() { Some(Term::NamedNode(c)) => match c.value().split("#").last() {
@ -281,26 +283,30 @@ impl<'a> Iterator for TestManifest<'a> {
}, },
_ => return Some(Err("no type".into())), _ => return Some(Err("no type".into())),
}; };
let name = match self.graph let name = match self
.graph
.object_for_subject_predicate(&test_subject, &mf::NAME) .object_for_subject_predicate(&test_subject, &mf::NAME)
{ {
Some(Term::Literal(c)) => Some(c.value().to_string()), Some(Term::Literal(c)) => Some(c.value().to_string()),
_ => None, _ => None,
}; };
let comment = match self.graph let comment = match self
.graph
.object_for_subject_predicate(&test_subject, &rdfs::COMMENT) .object_for_subject_predicate(&test_subject, &rdfs::COMMENT)
{ {
Some(Term::Literal(c)) => Some(c.value().to_string()), Some(Term::Literal(c)) => Some(c.value().to_string()),
_ => None, _ => None,
}; };
let action = match self.graph let action = match self
.graph
.object_for_subject_predicate(&test_subject, &*mf::ACTION) .object_for_subject_predicate(&test_subject, &*mf::ACTION)
{ {
Some(Term::NamedNode(n)) => n.url().clone(), Some(Term::NamedNode(n)) => n.url().clone(),
Some(_) => return Some(Err("invalid action".into())), Some(_) => return Some(Err("invalid action".into())),
None => return Some(Err("action not found".into())), None => return Some(Err("action not found".into())),
}; };
let result = match self.graph let result = match self
.graph
.object_for_subject_predicate(&test_subject, &*mf::RESULT) .object_for_subject_predicate(&test_subject, &*mf::RESULT)
{ {
Some(Term::NamedNode(n)) => Some(n.url().clone()), Some(Term::NamedNode(n)) => Some(n.url().clone()),
@ -327,7 +333,8 @@ impl<'a> Iterator for TestManifest<'a> {
} }
// New manifests // New manifests
match self.graph match self
.graph
.object_for_subject_predicate(&manifest, &*mf::INCLUDE) .object_for_subject_predicate(&manifest, &*mf::INCLUDE)
{ {
Some(Term::BlankNode(list)) => { Some(Term::BlankNode(list)) => {
@ -345,7 +352,8 @@ impl<'a> Iterator for TestManifest<'a> {
} }
// New tests // New tests
match self.graph match self
.graph
.object_for_subject_predicate(&manifest, &*mf::ENTRIES) .object_for_subject_predicate(&manifest, &*mf::ENTRIES)
{ {
Some(Term::BlankNode(list)) => { Some(Term::BlankNode(list)) => {

Loading…
Cancel
Save