pub struct PreparedDeleteInsertUpdate<'a> { /* private fields */ }Expand description
A prepared SPARQL query.
Allows customizing things like the evaluation dataset and substituting variables.
Usage example:
use oxrdf::{Dataset, GraphName, Literal, NamedNode, Quad};
use spareval::{DeleteInsertQuad, QueryEvaluator};
use spargebra::{GraphUpdateOperation, SparqlParser};
let ex = NamedNode::new("http://example.com")?;
let dataset = Dataset::from_iter([Quad::new(
ex.clone(),
ex.clone(),
Literal::from(0),
GraphName::DefaultGraph,
)]);
let update = SparqlParser::new().parse_update(
"DELETE { ?s ?p ?o } INSERT { ?s ?p ?o2 } WHERE { ?s ?p ?o BIND(?o +1 AS ?o2) }",
)?;
let GraphUpdateOperation::DeleteInsert {
delete,
insert,
using: _,
pattern,
} = &update.operations[0]
else {
unreachable!()
};
let results = QueryEvaluator::new()
.prepare_delete_insert(delete.clone(), insert.clone(), None, None, pattern)
.execute(&dataset)?
.collect::<Result<Vec<_>, _>>()?;
assert_eq!(
results,
vec![
DeleteInsertQuad::Delete(Quad::new(
ex.clone(),
ex.clone(),
Literal::from(0),
GraphName::DefaultGraph,
)),
DeleteInsertQuad::Insert(Quad::new(
ex.clone(),
ex.clone(),
Literal::from(1),
GraphName::DefaultGraph,
))
]
);Implementations§
Source§impl PreparedDeleteInsertUpdate<'_>
impl PreparedDeleteInsertUpdate<'_>
Sourcepub fn dataset(&self) -> &QueryDatasetSpecification
pub fn dataset(&self) -> &QueryDatasetSpecification
Returns the query dataset specification of this prepared update.
Sourcepub fn dataset_mut(&mut self) -> &mut QueryDatasetSpecification
pub fn dataset_mut(&mut self) -> &mut QueryDatasetSpecification
Returns the query dataset specification of this prepared update.
Sourcepub fn execute<'b>(
self,
dataset: impl QueryableDataset<'b>,
) -> Result<DeleteInsertIter<'b>, QueryEvaluationError>
pub fn execute<'b>( self, dataset: impl QueryableDataset<'b>, ) -> Result<DeleteInsertIter<'b>, QueryEvaluationError>
Execute the SPARQL query against the given QueryableDataset.
Trait Implementations§
Source§impl<'a> Clone for PreparedDeleteInsertUpdate<'a>
impl<'a> Clone for PreparedDeleteInsertUpdate<'a>
Source§fn clone(&self) -> PreparedDeleteInsertUpdate<'a>
fn clone(&self) -> PreparedDeleteInsertUpdate<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for PreparedDeleteInsertUpdate<'a>
impl<'a> !RefUnwindSafe for PreparedDeleteInsertUpdate<'a>
impl<'a> Send for PreparedDeleteInsertUpdate<'a>
impl<'a> Sync for PreparedDeleteInsertUpdate<'a>
impl<'a> Unpin for PreparedDeleteInsertUpdate<'a>
impl<'a> !UnwindSafe for PreparedDeleteInsertUpdate<'a>
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