Struct QueryDatasetSpecification
pub struct QueryDatasetSpecification {
pub(crate) default: Option<Vec<GraphName>>,
pub(crate) named: Option<Vec<NamedOrBlankNode>>,
}rdf only.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.
Fieldsยง
ยงdefault: Option<Vec<GraphName>>ยงnamed: Option<Vec<NamedOrBlankNode>>Implementationsยง
ยงimpl QueryDatasetSpecification
impl QueryDatasetSpecification
pub fn new() -> QueryDatasetSpecification
pub 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)
pub 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.
pub 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())
);
}
pub 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())
);
}
pub 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
pub 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ยง
ยงimpl Clone for QueryDatasetSpecification
impl Clone for QueryDatasetSpecification
ยง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ยงimpl Debug for QueryDatasetSpecification
impl Debug for QueryDatasetSpecification
ยงimpl Default for QueryDatasetSpecification
impl Default for QueryDatasetSpecification
ยงfn default() -> QueryDatasetSpecification
fn default() -> QueryDatasetSpecification
ยงimpl From<QueryDataset> for QueryDatasetSpecification
impl From<QueryDataset> for QueryDatasetSpecification
ยงfn from(dataset: QueryDataset) -> QueryDatasetSpecification
fn from(dataset: QueryDataset) -> QueryDatasetSpecification
ยงimpl Hash for QueryDatasetSpecification
impl Hash for QueryDatasetSpecification
ยงimpl PartialEq for QueryDatasetSpecification
impl PartialEq for QueryDatasetSpecification
impl Eq for QueryDatasetSpecification
impl StructuralPartialEq for QueryDatasetSpecification
Auto Trait Implementationsยง
impl Freeze for QueryDatasetSpecification
impl RefUnwindSafe for QueryDatasetSpecification
impl Send for QueryDatasetSpecification
impl Sync for QueryDatasetSpecification
impl Unpin for QueryDatasetSpecification
impl UnwindSafe for QueryDatasetSpecification
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
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
ยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
ยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.ยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.ยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.ยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.ยงimpl<T> DowncastSend for T
impl<T> DowncastSend for T
ยงimpl<T> DowncastSync for T
impl<T> DowncastSync for T
ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
ยงimpl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for Twhere
Request: Req<E> + Send + 'static,
Encoding: Decodes<T>,
E: FromServerFnError,
impl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for Twhere
Request: Req<E> + Send + 'static,
Encoding: Decodes<T>,
E: FromServerFnError,
ยงimpl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for Twhere
Request: Req<E> + Send + 'static,
Encoding: Decodes<T>,
E: FromServerFnError,
impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for Twhere
Request: Req<E> + Send + 'static,
Encoding: Decodes<T>,
E: FromServerFnError,
ยงimpl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for Twhere
Request: Req<E> + Send + 'static,
Encoding: Decodes<T>,
E: FromServerFnError,
impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for Twhere
Request: Req<E> + Send + 'static,
Encoding: Decodes<T>,
E: FromServerFnError,
ยงimpl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for Twhere
Response: ClientRes<E> + Send,
Encoding: Decodes<T>,
E: FromServerFnError,
impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for Twhere
Response: ClientRes<E> + Send,
Encoding: Decodes<T>,
E: FromServerFnError,
ยงimpl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for Twhere
Response: ClientRes<E> + Send,
Encoding: Decodes<T>,
E: FromServerFnError,
impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for Twhere
Response: ClientRes<E> + Send,
Encoding: Decodes<T>,
E: FromServerFnError,
ยงimpl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for Twhere
Response: ClientRes<E> + Send,
Encoding: Decodes<T>,
E: FromServerFnError,
impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for Twhere
Response: ClientRes<E> + Send,
Encoding: Decodes<T>,
E: FromServerFnError,
ยงimpl<T> Instrument for T
impl<T> Instrument for T
ยงfn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more