Drops QueryOption parameter from the query method

Introduces a query_opt method for that
pull/69/head
Tpt 4 years ago
parent ece760f0c1
commit 773bdb943e
  1. 7
      js/src/store.rs
  2. 4
      lib/src/lib.rs
  3. 27
      lib/src/sparql/mod.rs
  4. 19
      lib/src/sparql/model.rs
  5. 4
      lib/src/sparql/service.rs
  6. 18
      lib/src/store/memory.rs
  7. 12
      lib/src/store/rocksdb.rs
  8. 12
      lib/src/store/sled.rs
  9. 6
      lib/src/store/sophia.rs
  10. 6
      python/src/memory_store.rs
  11. 6
      python/src/sled_store.rs
  12. 5
      server/src/main.rs
  13. 4
      testsuite/src/sparql_evaluator.rs
  14. 5
      wikibase/src/main.rs

@ -4,7 +4,7 @@ use crate::utils::to_err;
use js_sys::{Array, Map}; use js_sys::{Array, Map};
use oxigraph::io::{DatasetFormat, GraphFormat}; use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::model::*; use oxigraph::model::*;
use oxigraph::sparql::{QueryOptions, QueryResults}; use oxigraph::sparql::QueryResults;
use oxigraph::MemoryStore; use oxigraph::MemoryStore;
use std::convert::{TryFrom, TryInto}; use std::convert::{TryFrom, TryInto};
use std::io::Cursor; use std::io::Cursor;
@ -105,10 +105,7 @@ impl JsMemoryStore {
} }
pub fn query(&self, query: &str) -> Result<JsValue, JsValue> { pub fn query(&self, query: &str) -> Result<JsValue, JsValue> {
let results = self let results = self.store.query(query).map_err(to_err)?;
.store
.query(query, QueryOptions::default())
.map_err(to_err)?;
let output = match results { let output = match results {
QueryResults::Solutions(solutions) => { QueryResults::Solutions(solutions) => {
let results = Array::new(); let results = Array::new();

@ -21,7 +21,7 @@
//! ``` //! ```
//! use oxigraph::MemoryStore; //! use oxigraph::MemoryStore;
//! use oxigraph::model::*; //! use oxigraph::model::*;
//! use oxigraph::sparql::{QueryOptions, QueryResults}; //! use oxigraph::sparql::QueryResults;
//! //!
//! let store = MemoryStore::new(); //! let store = MemoryStore::new();
//! //!
@ -35,7 +35,7 @@
//! assert_eq!(vec![quad], results); //! assert_eq!(vec![quad], results);
//! //!
//! // SPARQL query //! // SPARQL query
//! if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())? { //! if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
//! assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into())); //! assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
//! } //! }
//! # Result::<_,Box<dyn std::error::Error>>::Ok(()) //! # Result::<_,Box<dyn std::error::Error>>::Ok(())

@ -90,7 +90,11 @@ pub(crate) fn evaluate_query<R: ReadableEncodedStore + 'static>(
} }
} }
/// Options for SPARQL query evaluation /// Options for SPARQL query evaluation.
///
///
/// 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)]
pub struct QueryOptions { pub struct QueryOptions {
pub(crate) service_handler: Rc<dyn ServiceHandler<Error = EvaluationError>>, pub(crate) service_handler: Rc<dyn ServiceHandler<Error = EvaluationError>>,
@ -100,26 +104,27 @@ impl Default for QueryOptions {
#[inline] #[inline]
fn default() -> Self { fn default() -> Self {
Self { Self {
service_handler: Rc::new(EmptyServiceHandler), service_handler: if cfg!(feature = "http_client") {
Rc::new(service::SimpleServiceHandler::new())
} else {
Rc::new(EmptyServiceHandler)
},
} }
} }
} }
impl QueryOptions { impl QueryOptions {
/// Use a simple HTTP 1.1 client built into Oxigraph to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls. /// Use a given [`ServiceHandler`](trait.ServiceHandler.html) to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls.
///
/// Requires the `"http_client"` optional feature.
#[inline] #[inline]
#[cfg(feature = "http_client")] pub fn with_service_handler(mut self, service_handler: impl ServiceHandler + 'static) -> Self {
pub fn with_simple_service_handler(mut self) -> Self { self.service_handler = Rc::new(ErrorConversionServiceHandler::wrap(service_handler));
self.service_handler = Rc::new(service::SimpleServiceHandler::new());
self self
} }
/// Use a given [`ServiceHandler`](trait.ServiceHandler.html) to execute [SPARQL 1.1 Federated Query](https://www.w3.org/TR/sparql11-federated-query/) SERVICE calls. /// Disables the `SERVICE` calls
#[inline] #[inline]
pub fn with_service_handler(mut self, service_handler: impl ServiceHandler + 'static) -> Self { pub fn without_service_handler(mut self) -> Self {
self.service_handler = Rc::new(ErrorConversionServiceHandler::wrap(service_handler)); self.service_handler = Rc::new(EmptyServiceHandler);
self self
} }
} }

@ -47,14 +47,14 @@ impl QueryResults {
/// ``` /// ```
/// use oxigraph::MemoryStore; /// use oxigraph::MemoryStore;
/// use oxigraph::model::*; /// use oxigraph::model::*;
/// use oxigraph::sparql::{QueryOptions, QueryResultsFormat}; /// use oxigraph::sparql::QueryResultsFormat;
/// ///
/// let store = MemoryStore::new(); /// let store = MemoryStore::new();
/// let ex = NamedNode::new("http://example.com")?; /// let ex = NamedNode::new("http://example.com")?;
/// store.insert(Quad::new(ex.clone(), ex.clone(), ex.clone(), None)); /// store.insert(Quad::new(ex.clone(), ex.clone(), ex.clone(), None));
/// ///
/// let mut results = Vec::new(); /// let mut results = Vec::new();
/// store.query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())?.write(&mut results, QueryResultsFormat::Json)?; /// store.query("SELECT ?s WHERE { ?s ?p ?o }")?.write(&mut results, QueryResultsFormat::Json)?;
/// assert_eq!(results, "{\"head\":{\"vars\":[\"s\"]},\"results\":{\"bindings\":[{\"s\":{\"type\":\"uri\",\"value\":\"http://example.com\"}}]}}".as_bytes()); /// assert_eq!(results, "{\"head\":{\"vars\":[\"s\"]},\"results\":{\"bindings\":[{\"s\":{\"type\":\"uri\",\"value\":\"http://example.com\"}}]}}".as_bytes());
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
@ -78,7 +78,6 @@ impl QueryResults {
/// ``` /// ```
/// use oxigraph::MemoryStore; /// use oxigraph::MemoryStore;
/// use oxigraph::io::GraphFormat; /// use oxigraph::io::GraphFormat;
/// use oxigraph::sparql::QueryOptions;
/// use oxigraph::model::*; /// use oxigraph::model::*;
/// use std::io::Cursor; /// use std::io::Cursor;
/// ///
@ -88,7 +87,7 @@ impl QueryResults {
/// store.load_graph(Cursor::new(graph), GraphFormat::NTriples, &GraphName::DefaultGraph, None)?; /// store.load_graph(Cursor::new(graph), GraphFormat::NTriples, &GraphName::DefaultGraph, None)?;
/// ///
/// let mut results = Vec::new(); /// let mut results = Vec::new();
/// store.query("CONSTRUCT WHERE { ?s ?p ?o }", QueryOptions::default())?.write_graph(&mut results, GraphFormat::NTriples)?; /// store.query("CONSTRUCT WHERE { ?s ?p ?o }")?.write_graph(&mut results, GraphFormat::NTriples)?;
/// assert_eq!(results, graph); /// assert_eq!(results, graph);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ``` /// ```
@ -219,10 +218,10 @@ impl QueryResultsFormat {
/// ///
/// ``` /// ```
/// use oxigraph::MemoryStore; /// use oxigraph::MemoryStore;
/// use oxigraph::sparql::{QueryResults, QueryOptions}; /// use oxigraph::sparql::QueryResults;
/// ///
/// let store = MemoryStore::new(); /// let store = MemoryStore::new();
/// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())? { /// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
/// for solution in solutions { /// for solution in solutions {
/// println!("{:?}", solution?.get("s")); /// println!("{:?}", solution?.get("s"));
/// } /// }
@ -246,10 +245,10 @@ impl QuerySolutionIter {
/// ///
/// ``` /// ```
/// use oxigraph::MemoryStore; /// use oxigraph::MemoryStore;
/// use oxigraph::sparql::{QueryResults, QueryOptions, Variable}; /// use oxigraph::sparql::{QueryResults, Variable};
/// ///
/// let store = MemoryStore::new(); /// let store = MemoryStore::new();
/// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s ?o WHERE { ?s ?p ?o }", QueryOptions::default())? { /// if let QueryResults::Solutions(solutions) = store.query("SELECT ?s ?o WHERE { ?s ?p ?o }")? {
/// assert_eq!(solutions.variables(), &[Variable::new("s")?, Variable::new("o")?]); /// assert_eq!(solutions.variables(), &[Variable::new("s")?, Variable::new("o")?]);
/// } /// }
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
@ -368,10 +367,10 @@ impl VariableSolutionIndex for Variable {
/// ///
/// ``` /// ```
/// use oxigraph::MemoryStore; /// use oxigraph::MemoryStore;
/// use oxigraph::sparql::{QueryResults, QueryOptions}; /// use oxigraph::sparql::QueryResults;
/// ///
/// let store = MemoryStore::new(); /// let store = MemoryStore::new();
/// if let QueryResults::Graph(triples) = store.query("CONSTRUCT WHERE { ?s ?p ?o }", QueryOptions::default())? { /// if let QueryResults::Graph(triples) = store.query("CONSTRUCT WHERE { ?s ?p ?o }")? {
/// for triple in triples { /// for triple in triples {
/// println!("{}", triple?); /// println!("{}", triple?);
/// } /// }

@ -29,7 +29,7 @@ use std::error::Error;
/// ///
/// fn handle(&self,service_name: NamedNode, query: Query) -> Result<QueryResults,EvaluationError> { /// fn handle(&self,service_name: NamedNode, query: Query) -> Result<QueryResults,EvaluationError> {
/// if service_name == "http://example.com/service" { /// if service_name == "http://example.com/service" {
/// self.store.query(query, QueryOptions::default()) /// self.store.query(query)
/// } else { /// } else {
/// panic!() /// panic!()
/// } /// }
@ -41,7 +41,7 @@ use std::error::Error;
/// let ex = NamedNode::new("http://example.com")?; /// let ex = NamedNode::new("http://example.com")?;
/// service.store.insert(Quad::new(ex.clone(), ex.clone(), ex.clone(), None)); /// service.store.insert(Quad::new(ex.clone(), ex.clone(), ex.clone(), None));
/// ///
/// if let QueryResults::Solutions(mut solutions) = store.query( /// if let QueryResults::Solutions(mut solutions) = store.query_opt(
/// "SELECT ?s WHERE { SERVICE <http://example.com/service> { ?s ?p ?o } }", /// "SELECT ?s WHERE { SERVICE <http://example.com/service> { ?s ?p ?o } }",
/// QueryOptions::default().with_service_handler(service) /// QueryOptions::default().with_service_handler(service)
/// )? { /// )? {

@ -32,7 +32,7 @@ use std::{fmt, io};
/// ``` /// ```
/// use oxigraph::MemoryStore; /// use oxigraph::MemoryStore;
/// use oxigraph::model::*; /// use oxigraph::model::*;
/// use oxigraph::sparql::{QueryResults, QueryOptions}; /// use oxigraph::sparql::QueryResults;
/// ///
/// let store = MemoryStore::new(); /// let store = MemoryStore::new();
/// ///
@ -46,7 +46,7 @@ use std::{fmt, io};
/// assert_eq!(vec![quad], results); /// assert_eq!(vec![quad], results);
/// ///
/// // SPARQL query /// // SPARQL query
/// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())? { /// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into())); /// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// } /// }
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
@ -92,11 +92,13 @@ impl MemoryStore {
/// Executes a [SPARQL 1.1 query](https://www.w3.org/TR/sparql11-query/). /// Executes a [SPARQL 1.1 query](https://www.w3.org/TR/sparql11-query/).
/// ///
/// The default query options are used.
///
/// Usage example: /// Usage example:
/// ``` /// ```
/// use oxigraph::MemoryStore; /// use oxigraph::MemoryStore;
/// use oxigraph::model::*; /// use oxigraph::model::*;
/// use oxigraph::sparql::{QueryResults, QueryOptions}; /// use oxigraph::sparql::QueryResults;
/// ///
/// let store = MemoryStore::new(); /// let store = MemoryStore::new();
/// ///
@ -105,7 +107,7 @@ impl MemoryStore {
/// store.insert(Quad::new(ex.clone(), ex.clone(), ex.clone(), None)); /// store.insert(Quad::new(ex.clone(), ex.clone(), ex.clone(), None));
/// ///
/// // SPARQL query /// // SPARQL query
/// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())? { /// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into())); /// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// } /// }
/// # Result::<_,Box<dyn std::error::Error>>::Ok(()) /// # Result::<_,Box<dyn std::error::Error>>::Ok(())
@ -113,6 +115,14 @@ impl MemoryStore {
pub fn query( pub fn query(
&self, &self,
query: impl TryInto<Query, Error = impl Into<EvaluationError>>, query: impl TryInto<Query, Error = impl Into<EvaluationError>>,
) -> Result<QueryResults, EvaluationError> {
self.query_opt(query, QueryOptions::default())
}
/// Executes a [SPARQL 1.1 query](https://www.w3.org/TR/sparql11-query/) with some options.
pub fn query_opt(
&self,
query: impl TryInto<Query, Error = impl Into<EvaluationError>>,
options: QueryOptions, options: QueryOptions,
) -> Result<QueryResults, EvaluationError> { ) -> Result<QueryResults, EvaluationError> {
evaluate_query(self.clone(), query, options) evaluate_query(self.clone(), query, options)

@ -34,7 +34,7 @@ use std::{fmt, str};
/// ``` /// ```
/// use oxigraph::RocksDbStore; /// use oxigraph::RocksDbStore;
/// use oxigraph::model::*; /// use oxigraph::model::*;
/// use oxigraph::sparql::{QueryOptions, QueryResults}; /// use oxigraph::sparql::QueryResults;
/// # use std::fs::remove_dir_all; /// # use std::fs::remove_dir_all;
/// ///
/// # { /// # {
@ -50,7 +50,7 @@ use std::{fmt, str};
/// assert_eq!(vec![quad], results?); /// assert_eq!(vec![quad], results?);
/// ///
/// // SPARQL query /// // SPARQL query
/// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())? { /// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into())); /// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// } /// }
/// # /// #
@ -127,6 +127,14 @@ impl RocksDbStore {
pub fn query( pub fn query(
&self, &self,
query: impl TryInto<Query, Error = impl Into<EvaluationError>>, query: impl TryInto<Query, Error = impl Into<EvaluationError>>,
) -> Result<QueryResults, EvaluationError> {
self.query_opt(query, QueryOptions::default())
}
/// Executes a [SPARQL 1.1 query](https://www.w3.org/TR/sparql11-query/) with some options.
pub fn query_opt(
&self,
query: impl TryInto<Query, Error = impl Into<EvaluationError>>,
options: QueryOptions, options: QueryOptions,
) -> Result<QueryResults, EvaluationError> { ) -> Result<QueryResults, EvaluationError> {
evaluate_query(self.clone(), query, options) evaluate_query(self.clone(), query, options)

@ -36,7 +36,7 @@ use std::{fmt, io, str};
/// Usage example: /// Usage example:
/// ``` /// ```
/// use oxigraph::SledStore; /// use oxigraph::SledStore;
/// use oxigraph::sparql::{QueryOptions, QueryResults}; /// use oxigraph::sparql::QueryResults;
/// use oxigraph::model::*; /// use oxigraph::model::*;
/// # use std::fs::remove_dir_all; /// # use std::fs::remove_dir_all;
/// ///
@ -53,7 +53,7 @@ use std::{fmt, io, str};
/// assert_eq!(vec![quad], results?); /// assert_eq!(vec![quad], results?);
/// ///
/// // SPARQL query /// // SPARQL query
/// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }", QueryOptions::default())? { /// if let QueryResults::Solutions(mut solutions) = store.query("SELECT ?s WHERE { ?s ?p ?o }")? {
/// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into())); /// assert_eq!(solutions.next().unwrap()?.get("s"), Some(&ex.into()));
/// }; /// };
/// # /// #
@ -137,6 +137,14 @@ impl SledStore {
pub fn query( pub fn query(
&self, &self,
query: impl TryInto<Query, Error = impl Into<EvaluationError>>, query: impl TryInto<Query, Error = impl Into<EvaluationError>>,
) -> Result<QueryResults, EvaluationError> {
self.query_opt(query, QueryOptions::default())
}
/// Executes a [SPARQL 1.1 query](https://www.w3.org/TR/sparql11-query/) with some options.
pub fn query_opt(
&self,
query: impl TryInto<Query, Error = impl Into<EvaluationError>>,
options: QueryOptions, options: QueryOptions,
) -> Result<QueryResults, EvaluationError> { ) -> Result<QueryResults, EvaluationError> {
evaluate_query(self.clone(), query, options) evaluate_query(self.clone(), query, options)

@ -1,7 +1,7 @@
//! This crate provides implementation of [Sophia] traits for the `store` module. //! This crate provides implementation of [Sophia] traits for the `store` module.
//! [Sophia]: https://docs.rs/sophia/latest/sophia/ //! [Sophia]: https://docs.rs/sophia/latest/sophia/
use crate::model::*; use crate::model::*;
use crate::sparql::{EvaluationError, QueryOptions, QueryResults}; use crate::sparql::{EvaluationError, QueryResults};
use crate::store::*; use crate::store::*;
use sophia_api::dataset::*; use sophia_api::dataset::*;
use sophia_api::quad::stream::{QuadSource, StreamResult}; use sophia_api::quad::stream::{QuadSource, StreamResult};
@ -24,9 +24,7 @@ type StreamedSophiaQuad<'a> = StreamedQuad<'a, ByValue<SophiaQuad>>;
macro_rules! sparql_to_hashset { macro_rules! sparql_to_hashset {
($store: ident, $err_map: ident, $sparql: expr) => {{ ($store: ident, $err_map: ident, $sparql: expr) => {{
(|| -> Result<HashSet<Term>, EvaluationError> { (|| -> Result<HashSet<Term>, EvaluationError> {
if let QueryResults::Solutions(solutions) = if let QueryResults::Solutions(solutions) = $store.query($sparql)? {
$store.query($sparql, QueryOptions::default())?
{
solutions solutions
.map(|r| r.map(|v| v.get(0).unwrap().clone())) .map(|r| r.map(|v| v.get(0).unwrap().clone()))
.collect() .collect()

@ -3,7 +3,6 @@ use crate::model::*;
use crate::sparql::*; use crate::sparql::*;
use crate::store_utils::*; use crate::store_utils::*;
use oxigraph::io::{DatasetFormat, GraphFormat}; use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::sparql::QueryOptions;
use oxigraph::store::memory::*; use oxigraph::store::memory::*;
use pyo3::basic::CompareOp; use pyo3::basic::CompareOp;
use pyo3::exceptions::{PyNotImplementedError, PyValueError}; use pyo3::exceptions::{PyNotImplementedError, PyValueError};
@ -164,10 +163,7 @@ impl PyMemoryStore {
default_graph, default_graph,
named_graphs, named_graphs,
)?; )?;
let results = self let results = self.inner.query(query).map_err(map_evaluation_error)?;
.inner
.query(query, QueryOptions::default())
.map_err(map_evaluation_error)?;
query_results_to_python(py, results) query_results_to_python(py, results)
} }

@ -3,7 +3,6 @@ use crate::model::*;
use crate::sparql::*; use crate::sparql::*;
use crate::store_utils::*; use crate::store_utils::*;
use oxigraph::io::{DatasetFormat, GraphFormat}; use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::sparql::QueryOptions;
use oxigraph::store::sled::*; use oxigraph::store::sled::*;
use pyo3::exceptions::PyValueError; use pyo3::exceptions::PyValueError;
use pyo3::prelude::{ use pyo3::prelude::{
@ -178,10 +177,7 @@ impl PySledStore {
default_graph, default_graph,
named_graphs, named_graphs,
)?; )?;
let results = self let results = self.inner.query(query).map_err(map_evaluation_error)?;
.inner
.query(query, QueryOptions::default())
.map_err(map_evaluation_error)?;
query_results_to_python(py, results) query_results_to_python(py, results)
} }

@ -18,7 +18,7 @@ use async_std::task::{block_on, spawn, spawn_blocking};
use http_types::{headers, Body, Error, Method, Mime, Request, Response, Result, StatusCode}; use http_types::{headers, Body, Error, Method, Mime, Request, Response, Result, StatusCode};
use oxigraph::io::{DatasetFormat, GraphFormat}; use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::model::{GraphName, NamedNode, NamedOrBlankNode}; use oxigraph::model::{GraphName, NamedNode, NamedOrBlankNode};
use oxigraph::sparql::{Query, QueryOptions, QueryResults, QueryResultsFormat, Update}; use oxigraph::sparql::{Query, QueryResults, QueryResultsFormat, Update};
use std::io::BufReader; use std::io::BufReader;
use std::str::FromStr; use std::str::FromStr;
use url::form_urlencoded; use url::form_urlencoded;
@ -246,8 +246,7 @@ async fn evaluate_sparql_query(
.set_available_named_graphs(named_graph_uris); .set_available_named_graphs(named_graph_uris);
} }
let options = QueryOptions::default().with_simple_service_handler(); let results = store.query(query)?;
let results = store.query(query, options)?;
//TODO: stream //TODO: stream
if let QueryResults::Graph(_) = results { if let QueryResults::Graph(_) = results {
let format = content_negotiation( let format = content_negotiation(

@ -89,7 +89,7 @@ fn evaluate_sparql_test(test: &Test) -> Result<()> {
test, test,
error error
)), )),
Ok(query) => match store.query(query, options) { Ok(query) => match store.query_opt(query, options) {
Err(error) => Err(anyhow!( Err(error) => Err(anyhow!(
"Failure to execute query of {} with error: {}", "Failure to execute query of {} with error: {}",
test, test,
@ -272,7 +272,7 @@ impl ServiceHandler for StaticServiceHandler {
format!("Service {} not found", service_name), format!("Service {} not found", service_name),
) )
})? })?
.query( .query_opt(
query, query,
QueryOptions::default().with_service_handler(self.clone()), QueryOptions::default().with_service_handler(self.clone()),
) )

@ -17,7 +17,7 @@ use async_std::prelude::*;
use async_std::task::{spawn, spawn_blocking}; use async_std::task::{spawn, spawn_blocking};
use http_types::{headers, Body, Error, Method, Mime, Request, Response, Result, StatusCode}; use http_types::{headers, Body, Error, Method, Mime, Request, Response, Result, StatusCode};
use oxigraph::io::GraphFormat; use oxigraph::io::GraphFormat;
use oxigraph::sparql::{Query, QueryOptions, QueryResults, QueryResultsFormat}; use oxigraph::sparql::{Query, QueryResults, QueryResultsFormat};
use oxigraph::RocksDbStore; use oxigraph::RocksDbStore;
use std::str::FromStr; use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
@ -183,8 +183,7 @@ async fn evaluate_sparql_query(
if query.dataset().is_default_dataset() { if query.dataset().is_default_dataset() {
query.dataset_mut().set_default_graph_as_union(); query.dataset_mut().set_default_graph_as_union();
} }
let options = QueryOptions::default().with_simple_service_handler(); let results = store.query(query)?;
let results = store.query(query, options)?;
if let QueryResults::Graph(_) = results { if let QueryResults::Graph(_) = results {
let format = content_negotiation( let format = content_negotiation(
request, request,

Loading…
Cancel
Save