pub struct QueryDatasetSpecification { /* private fields */ }Expand description
An extended SPARQL query dataset specification.
Allows setting blank node graph names and that the default graph is the union of all named graphs.
Implementations§
Source§impl QueryDatasetSpecification
impl QueryDatasetSpecification
pub fn new() -> Self
Sourcepub fn is_default_dataset(&self) -> bool
pub fn is_default_dataset(&self) -> bool
Checks if this dataset specification is the default one (i.e., the default graph is the store default graph, and all named graphs included in the queried store are available)
Sourcepub fn default_graph_graphs(&self) -> Option<&[GraphName]>
pub fn default_graph_graphs(&self) -> Option<&[GraphName]>
Returns the list of the store graphs that are available to the query as the default graph or None if the union of all graphs is used as the default graph.
This list is by default only the store default graph.
Sourcepub fn set_default_graph_as_union(&mut self)
pub fn set_default_graph_as_union(&mut self)
Sets the default graph of the query to be the union of all the graphs in the queried store.
use oxrdf::{Dataset, NamedNode, Quad};
use spareval::{QueryEvaluator, QueryResults};
use spargebra::SparqlParser;
let dataset = Dataset::from_iter([Quad::new(
NamedNode::new("http://example.com/s")?,
NamedNode::new("http://example.com/p")?,
NamedNode::new("http://example.com/o")?,
NamedNode::new("http://example.com/g")?,
)]);
let query = SparqlParser::new().parse_query("SELECT * WHERE { ?s ?p ?o }")?;
let evaluator = QueryEvaluator::new();
let mut prepared = evaluator.prepare(&query);
prepared
.dataset_mut()
.set_default_graph(vec![NamedNode::new("http://example.com/g")?.into()]);
if let QueryResults::Solutions(mut solutions) = prepared.execute(&dataset)? {
assert_eq!(
solutions.next().unwrap()?.get("s"),
Some(&NamedNode::new("http://example.com/s")?.into())
);
}
Sourcepub fn set_default_graph(&mut self, graphs: Vec<GraphName>)
pub fn set_default_graph(&mut self, graphs: Vec<GraphName>)
Sets the list of graphs the query should consider as being part of the default graph.
By default, only the store default graph is considered.
use oxrdf::{Dataset, NamedNode, Quad};
use spareval::{QueryEvaluator, QueryResults};
use spargebra::SparqlParser;
let dataset = Dataset::from_iter([Quad::new(
NamedNode::new("http://example.com/s")?,
NamedNode::new("http://example.com/p")?,
NamedNode::new("http://example.com/o")?,
NamedNode::new("http://example.com/g")?,
)]);
let query = SparqlParser::new().parse_query("SELECT * WHERE { ?s ?p ?o }")?;
let evaluator = QueryEvaluator::new();
let mut prepared = evaluator.prepare(&query);
prepared
.dataset_mut()
.set_default_graph(vec![NamedNode::new("http://example.com/g")?.into()]);
if let QueryResults::Solutions(mut solutions) = prepared.execute(&dataset)? {
assert_eq!(
solutions.next().unwrap()?.get("s"),
Some(&NamedNode::new("http://example.com/s")?.into())
);
}
Sourcepub fn available_named_graphs(&self) -> Option<&[NamedOrBlankNode]>
pub fn available_named_graphs(&self) -> Option<&[NamedOrBlankNode]>
Returns the list of the available named graphs for the query or None if all graphs are available
Sourcepub fn set_available_named_graphs(
&mut self,
named_graphs: Vec<NamedOrBlankNode>,
)
pub fn set_available_named_graphs( &mut self, named_graphs: Vec<NamedOrBlankNode>, )
Sets the list of allowed named graphs in the query.
use oxrdf::{Dataset, NamedNode, Quad};
use spareval::{QueryEvaluator, QueryResults};
use spargebra::SparqlParser;
let dataset = Dataset::from_iter([Quad::new(
NamedNode::new("http://example.com/s")?,
NamedNode::new("http://example.com/p")?,
NamedNode::new("http://example.com/o")?,
NamedNode::new("http://example.com/g")?,
)]);
let query = SparqlParser::new().parse_query("SELECT * WHERE { ?s ?p ?o }")?;
let evaluator = QueryEvaluator::new();
let mut prepared = evaluator.prepare(&query);
prepared
.dataset_mut()
.set_available_named_graphs(Vec::new());
if let QueryResults::Solutions(mut solutions) = prepared.execute(&dataset)? {
assert!(solutions.next().is_none(),);
}
Trait Implementations§
Source§impl Clone for QueryDatasetSpecification
impl Clone for QueryDatasetSpecification
Source§fn clone(&self) -> QueryDatasetSpecification
fn clone(&self) -> QueryDatasetSpecification
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more