Skip to main content

BoundPreparedSparqlQuery

Struct BoundPreparedSparqlQuery 

Source
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>

Source

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())
    );
}
Source

pub fn execute(self) -> Result<QueryResults<'a>, QueryEvaluationError>

Evaluate the query against the given store.

Source

pub fn compute_statistics(self) -> Self

Compute statistics during evaluation and fills them in the explanation tree.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V