pub struct BoundPreparedSparqlQuery<'a, D: QueryableDataset<'a> = DatasetView<'a>> { /* private fields */ }Expand description
A prepared SPARQL query bound to a storage, ready to be executed.
Usage example:
use oxigraph::model::{Literal, Variable};
use oxigraph::sparql::{QueryResults, SparqlEvaluator};
use oxigraph::store::Store;
let prepared_query = SparqlEvaluator::new()
.parse_query("SELECT ?v WHERE {}")?
.substitute_variable(Variable::new("v")?, Literal::from(1));
if let QueryResults::Solutions(mut solutions) =
prepared_query.on_store(&Store::new()?).execute()?
{
assert_eq!(
solutions.next().unwrap()?.get("v"),
Some(&Literal::from(1).into())
);
}Implementations§
Source§impl<'a, D: QueryableDataset<'a>> BoundPreparedSparqlQuery<'a, D>
impl<'a, D: QueryableDataset<'a>> BoundPreparedSparqlQuery<'a, D>
Sourcepub fn substitute_variable(
self,
variable: impl Into<Variable>,
term: impl Into<Term>,
) -> Self
pub fn substitute_variable( self, variable: impl Into<Variable>, term: impl Into<Term>, ) -> Self
Substitute a variable with a given RDF term in the SPARQL query.
Usage example:
use oxigraph::model::{Literal, Variable};
use oxigraph::sparql::{QueryResults, SparqlEvaluator};
use oxigraph::store::Store;
let prepared_query = SparqlEvaluator::new()
.parse_query("SELECT ?v WHERE {}")?
.on_store(&Store::new()?)
.substitute_variable(Variable::new("v")?, Literal::from(1));
if let QueryResults::Solutions(mut solutions) = prepared_query.execute()? {
assert_eq!(
solutions.next().unwrap()?.get("v"),
Some(&Literal::from(1).into())
);
}Sourcepub fn execute(self) -> Result<QueryResults<'a>, QueryEvaluationError>
pub fn execute(self) -> Result<QueryResults<'a>, QueryEvaluationError>
Evaluate the query against the given store.
Sourcepub fn compute_statistics(self) -> Self
pub fn compute_statistics(self) -> Self
Compute statistics during evaluation and fills them in the explanation tree.
Sourcepub fn explain(
self,
) -> (Result<QueryResults<'a>, QueryEvaluationError>, QueryExplanation)
pub fn explain( self, ) -> (Result<QueryResults<'a>, QueryEvaluationError>, QueryExplanation)
Executes a SPARQL 1.1 query with some options and
returns a query explanation with some statistics (if enabled with the compute_statistics option).
If you want to compute statistics, you need to exhaust the results iterator before having a look at them.
Usage example serializing the explanation with statistics in JSON:
use oxigraph::sparql::{QueryResults, SparqlEvaluator};
use oxigraph::store::Store;
if let (Ok(QueryResults::Solutions(solutions)), explanation) = SparqlEvaluator::new()
.parse_query("SELECT ?s WHERE { VALUES ?s { 1 2 3 } }")?
.on_store(&Store::new()?)
.explain()
{
// We make sure to have read all the solutions
for _ in solutions {}
let mut buf = Vec::new();
explanation.write_in_json(&mut buf)?;
}Auto Trait Implementations§
impl<'a, D> Freeze for BoundPreparedSparqlQuery<'a, D>where
D: Freeze,
impl<'a, D = DatasetView<'a>> !RefUnwindSafe for BoundPreparedSparqlQuery<'a, D>
impl<'a, D> Send for BoundPreparedSparqlQuery<'a, D>where
D: Send,
impl<'a, D> Sync for BoundPreparedSparqlQuery<'a, D>where
D: Sync,
impl<'a, D> Unpin for BoundPreparedSparqlQuery<'a, D>where
D: Unpin,
impl<'a, D> UnsafeUnpin for BoundPreparedSparqlQuery<'a, D>where
D: UnsafeUnpin,
impl<'a, D = DatasetView<'a>> !UnwindSafe for BoundPreparedSparqlQuery<'a, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more