pub struct GraphQuery<'a> { /* private fields */ }Expand description
GraphQuery provides advanced query building and execution.
This type provides a fluent interface for building and executing SPARQL queries with additional convenience methods.
§Examples
§Query with prefixes
use ggen_core::graph::{Graph, GraphQuery};
use std::collections::BTreeMap;
let graph = Graph::new()?;
let query = GraphQuery::new(&graph);
let mut prefixes = BTreeMap::new();
prefixes.insert("ex".to_string(), "http://example.org/".to_string());
let results = query.execute_with_prefixes(
"SELECT ?name WHERE { ?s ex:name ?name }",
&prefixes,
None
)?;Implementations§
Source§impl<'a> GraphQuery<'a>
impl<'a> GraphQuery<'a>
Sourcepub fn execute_with_prefixes(
&self,
sparql: &str,
prefixes: &BTreeMap<String, String>,
base: Option<&str>,
) -> Result<QueryResults<'a>>
pub fn execute_with_prefixes( &self, sparql: &str, prefixes: &BTreeMap<String, String>, base: Option<&str>, ) -> Result<QueryResults<'a>>
Execute a SPARQL query with PREFIX and BASE declarations.
§Arguments
sparql- SPARQL query string (without PREFIX/BASE)prefixes- Map of prefix names to namespace URIsbase- Optional base IRI
Sourcepub fn execute_cached(&self, sparql: &str) -> Result<CachedResult>
pub fn execute_cached(&self, sparql: &str) -> Result<CachedResult>
Execute a SPARQL query and return cached results.
This is a convenience method that calls graph.query_cached().
Sourcepub fn execute(&self, sparql: &str) -> Result<QueryResults<'a>>
pub fn execute(&self, sparql: &str) -> Result<QueryResults<'a>>
Execute a SPARQL query and return raw QueryResults.
This is a convenience method that calls graph.query().
Sourcepub fn execute_prepared(&self, q: &str) -> Result<QueryResults<'a>>
pub fn execute_prepared(&self, q: &str) -> Result<QueryResults<'a>>
Execute a prepared SPARQL query.
This is a convenience method that calls graph.query_prepared().
Sourcepub fn builder(&self) -> SparqlEvaluator
pub fn builder(&self) -> SparqlEvaluator
Create a query builder for constructing queries programmatically.
Returns a SparqlEvaluator that can be used to build and execute queries.
The evaluator provides a fluent API for constructing SPARQL queries.
§Example
use ggen_core::graph::{Graph, GraphQuery};
let graph = Graph::new()?;
let query = GraphQuery::new(&graph);
// Use the builder to construct and execute a query
let results = query.builder()
.parse_query("SELECT ?s WHERE { ?s ?p ?o }")?
.on_store(graph.inner())
.execute()?;Auto Trait Implementations§
impl<'a> !RefUnwindSafe for GraphQuery<'a>
impl<'a> !UnwindSafe for GraphQuery<'a>
impl<'a> Freeze for GraphQuery<'a>
impl<'a> Send for GraphQuery<'a>
impl<'a> Sync for GraphQuery<'a>
impl<'a> Unpin for GraphQuery<'a>
impl<'a> UnsafeUnpin for GraphQuery<'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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> EvidenceKind for T
impl<T> EvidenceKind for T
default fn kind_label(&self) -> &'static str
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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> ⓘ
Converts
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> ⓘ
Converts
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