Renames QueryResult::Bindings into QueryResult::Solutions

pull/41/head
Tpt 5 years ago
parent 827667e495
commit 3926fdc219
  1. 2
      js/src/store.rs
  2. 2
      lib/src/lib.rs
  3. 2
      lib/src/sparql/eval.rs
  4. 2
      lib/src/sparql/json_results.rs
  5. 6
      lib/src/sparql/model.rs
  6. 2
      lib/src/sparql/plan_builder.rs
  7. 6
      lib/src/sparql/xml_results.rs
  8. 4
      lib/src/store/memory.rs
  9. 2
      lib/src/store/rocksdb.rs
  10. 2
      lib/src/store/sled.rs
  11. 4
      lib/tests/service_test_cases.rs
  12. 4
      lib/tests/wasm.rs
  13. 4
      testsuite/src/sparql_evaluator.rs

@ -114,7 +114,7 @@ impl JsMemoryStore {
.map_err(to_err)?;
let results = query.exec().map_err(to_err)?;
let output = match results {
QueryResult::Bindings(solutions) => {
QueryResult::Solutions(solutions) => {
let results = Array::new();
for solution in solutions {
let solution = solution.map_err(to_err)?;

@ -33,7 +33,7 @@
//!
//! // SPARQL query
//! let prepared_query = store.prepare_query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())?;
//! if let QueryResult::Bindings(mut solutions) = prepared_query.exec()? {
//! if let QueryResult::Solutions(mut solutions) = prepared_query.exec()? {
//! assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
//! }
//! # Result::Ok(())

@ -63,7 +63,7 @@ impl<'a, S: ReadableEncodedStore + 'a> SimpleEvaluator<S> {
'a: 'b,
{
let iter = self.eval_plan(plan, EncodedTuple::with_capacity(variables.len()));
Ok(QueryResult::Bindings(
Ok(QueryResult::Solutions(
self.decode_bindings(iter, variables.to_vec()),
))
}

@ -13,7 +13,7 @@ pub fn write_json_results<W: Write>(results: QueryResult<'_>, mut sink: W) -> Re
sink.write_all(if value { b"true" } else { b"false" })?;
sink.write_all(b"}")?;
}
QueryResult::Bindings(solutions) => {
QueryResult::Solutions(solutions) => {
sink.write_all(b"{\"head\":{\"vars\":[")?;
let mut start_vars = true;
for variable in solutions.variables() {

@ -14,7 +14,7 @@ use std::rc::Rc;
/// Results of a [SPARQL query](https://www.w3.org/TR/sparql11-query/)
pub enum QueryResult<'a> {
/// Results of a [SELECT](https://www.w3.org/TR/sparql11-query/#select) query
Bindings(QuerySolutionsIterator<'a>),
Solutions(QuerySolutionsIterator<'a>),
/// Result of a [ASK](https://www.w3.org/TR/sparql11-query/#ask) query
Boolean(bool),
/// Results of a [CONSTRUCT](https://www.w3.org/TR/sparql11-query/#construct) or [DESCRIBE](https://www.w3.org/TR/sparql11-query/#describe) query
@ -128,7 +128,7 @@ impl FileSyntax for QueryResultSyntax {
///
/// let store = MemoryStore::new();
/// let prepared_query = store.prepare_query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())?;
/// if let QueryResult::Bindings(solutions) = prepared_query.exec()? {
/// if let QueryResult::Solutions(solutions) = prepared_query.exec()? {
/// for solution in solutions {
/// println!("{:?}", solution?.get("s"));
/// }
@ -159,7 +159,7 @@ impl<'a> QuerySolutionsIterator<'a> {
///
/// let store = MemoryStore::new();
/// let prepared_query = store.prepare_query("SELECT ?s ?o WHERE { ?s ?p ?o }", QueryOptions::default())?;
/// if let QueryResult::Bindings(solutions) = prepared_query.exec()? {
/// if let QueryResult::Solutions(solutions) = prepared_query.exec()? {
/// assert_eq!(solutions.variables(), &[Variable::new("s"), Variable::new("o")]);
/// }
/// # Result::Ok(())

@ -46,7 +46,7 @@ impl<E: Encoder> PlanBuilder<E> {
let left = self.build_for_graph_pattern(a, variables, graph_name)?;
let right = self.build_for_graph_pattern(b, variables, graph_name)?;
let mut possible_problem_vars = ::new();
let mut possible_problem_vars = BTreeSet::new();
self.add_left_join_problematic_variables(&right, &mut possible_problem_vars);
//We add the extra filter if needed

@ -35,7 +35,7 @@ pub fn write_xml_results<W: Write>(results: QueryResult<'_>, sink: W) -> Result<
writer.write_event(Event::End(BytesEnd::borrowed(b"boolean")))?;
writer.write_event(Event::End(BytesEnd::borrowed(b"sparql")))?;
}
QueryResult::Bindings(solutions) => {
QueryResult::Solutions(solutions) => {
writer.write_event(Event::Decl(BytesDecl::new(b"1.0", None, None)))?;
let mut sparql_open = BytesStart::borrowed_name(b"sparql");
sparql_open.push_attribute(("xmlns", "http://www.w3.org/2005/sparql-results#"));
@ -170,7 +170,7 @@ pub fn read_xml_results<'a>(source: impl BufRead + 'a) -> Result<QueryResult<'a>
for (i,var) in variables.iter().enumerate() {
mapping.insert(var.as_bytes().to_vec(), i);
}
return Ok(QueryResult::Bindings(QuerySolutionsIterator::new(
return Ok(QueryResult::Solutions(QuerySolutionsIterator::new(
variables.into_iter().map(Variable::new).collect(),
Box::new(ResultsIterator {
reader,
@ -209,7 +209,7 @@ pub fn read_xml_results<'a>(source: impl BufRead + 'a) -> Result<QueryResult<'a>
},
State::AfterHead => {
if event.name() == b"results" {
return Ok(QueryResult::Bindings(QuerySolutionsIterator::new(
return Ok(QueryResult::Solutions(QuerySolutionsIterator::new(
variables.into_iter().map(Variable::new).collect(),
Box::new(empty()),
)))

@ -37,7 +37,7 @@ use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
///
/// // SPARQL query
/// let prepared_query = store.prepare_query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())?;
/// if let QueryResult::Bindings(mut solutions) = prepared_query.exec()? {
/// if let QueryResult::Solutions(mut solutions) = prepared_query.exec()? {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// }
/// # Result::Ok(())
@ -95,7 +95,7 @@ impl MemoryStore {
///
/// // SPARQL query
/// let prepared_query = store.prepare_query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())?;
/// if let QueryResult::Bindings(mut solutions) = prepared_query.exec()? {
/// if let QueryResult::Solutions(mut solutions) = prepared_query.exec()? {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// }
/// # Result::Ok(())

@ -39,7 +39,7 @@ use std::sync::Arc;
/// // SPARQL query
/// let prepared_query = store.prepare_query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())?;
/// let results = prepared_query.exec()?;
/// if let QueryResult::Bindings(mut solutions) = results {
/// if let QueryResult::Solutions(mut solutions) = results {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// }
/// #

@ -38,7 +38,7 @@ use std::str;
///
/// // SPARQL query
/// let prepared_query = store.prepare_query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())?;
/// if let QueryResult::Bindings(mut solutions) = prepared_query.exec()? {
/// if let QueryResult::Solutions(mut solutions) = prepared_query.exec()? {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// }
/// #

@ -205,7 +205,7 @@ fn query_store<'a>(
options: QueryOptions<'a>,
) -> Result<QuerySolutionsIterator<'a>> {
match store.prepare_query(&query, options)?.exec()? {
QueryResult::Bindings(iterator) => {
QueryResult::Solutions(iterator) => {
let (variables, iter) = iterator.destruct();
let collected = iter.collect::<Vec<_>>();
Ok(QuerySolutionsIterator::new(
@ -226,7 +226,7 @@ fn pattern_store<'a>(
.prepare_query_from_pattern(&pattern, options)?
.exec()?
{
QueryResult::Bindings(iterator) => {
QueryResult::Solutions(iterator) => {
let (varaibles, iter) = iterator.destruct();
let collected = iter.collect::<Vec<_>>();
Ok(QuerySolutionsIterator::new(

@ -23,7 +23,7 @@ mod test {
.prepare_query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())
.unwrap();
let results = prepared_query.exec().unwrap();
if let QueryResult::Bindings(mut solutions) = results {
if let QueryResult::Solutions(mut solutions) = results {
assert_eq!(
solutions.next().unwrap().unwrap().get("s"),
Some(&ex.into())
@ -41,7 +41,7 @@ mod test {
)
.unwrap();
let results = prepared_query.exec().unwrap();
if let QueryResult::Bindings(mut solutions) = results {
if let QueryResult::Solutions(mut solutions) = results {
if let Some(Term::Literal(l)) = solutions.next().unwrap().unwrap().get(0) {
let year = i64::from_str(l.value()).unwrap();
assert!(2020 <= year && year <= 2100);

@ -180,7 +180,7 @@ impl ServiceHandler for StaticServiceHandler {
service_name: &NamedNode,
graph_pattern: &'a GraphPattern,
) -> Result<QuerySolutionsIterator<'a>> {
if let QueryResult::Bindings(iterator) = self
if let QueryResult::Solutions(iterator) = self
.services
.get(service_name)
.ok_or_else(|| Error::msg(format!("Service {} not found", service_name)))?
@ -223,7 +223,7 @@ fn to_dataset(result: QueryResult<'_>, with_order: bool) -> Result<MemoryStore>
));
Ok(store)
}
QueryResult::Bindings(solutions) => {
QueryResult::Solutions(solutions) => {
let store = MemoryStore::new();
let result_set = BlankNode::default();
store.insert(Quad::new(

Loading…
Cancel
Save