pub struct Graph { /* private fields */ }Expand description
RDF graph representation
A graph is a collection of RDF triples. This implementation uses a BTreeSet for efficient storage and retrieval.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn from_triples<I>(triples: I) -> Selfwhere
I: IntoIterator<Item = Triple>,
pub fn from_triples<I>(triples: I) -> Selfwhere
I: IntoIterator<Item = Triple>,
Create a graph from an iterator of triples
Sourcepub fn add_triple(&mut self, triple: Triple) -> bool
pub fn add_triple(&mut self, triple: Triple) -> bool
Add a triple to the graph
Sourcepub fn add_triple_str(
&mut self,
subject: &str,
predicate: &str,
object: &str,
) -> Result<bool>
pub fn add_triple_str( &mut self, subject: &str, predicate: &str, object: &str, ) -> Result<bool>
Add a triple to the graph using string components
Sourcepub fn remove_triple(&mut self, triple: &Triple) -> bool
pub fn remove_triple(&mut self, triple: &Triple) -> bool
Remove a triple from the graph
Sourcepub fn contains_triple(&self, triple: &Triple) -> bool
pub fn contains_triple(&self, triple: &Triple) -> bool
Check if a triple exists in the graph
Sourcepub fn query_triples(
&self,
subject: Option<&Subject>,
predicate: Option<&Predicate>,
object: Option<&Object>,
) -> Vec<Triple>
pub fn query_triples( &self, subject: Option<&Subject>, predicate: Option<&Predicate>, object: Option<&Object>, ) -> Vec<Triple>
Query triples matching the given pattern
None values act as wildcards matching any term.
Sourcepub fn iter_triples(&self) -> impl Iterator<Item = &Triple>
pub fn iter_triples(&self) -> impl Iterator<Item = &Triple>
Iterate over all triples
Sourcepub fn iter(&self) -> impl Iterator<Item = &Triple>
pub fn iter(&self) -> impl Iterator<Item = &Triple>
Iterate over all triples (alias for iter_triples)
Sourcepub fn contains(&self, triple: &Triple) -> bool
pub fn contains(&self, triple: &Triple) -> bool
Check if a triple exists in the graph (alias for contains_triple)
Sourcepub fn predicates(&self) -> BTreeSet<Predicate>
pub fn predicates(&self) -> BTreeSet<Predicate>
Get all predicates in the graph
Sourcepub fn union(&self, other: &Graph) -> Graph
pub fn union(&self, other: &Graph) -> Graph
Create a new graph containing the union of this graph and another
Sourcepub fn intersection(&self, other: &Graph) -> Graph
pub fn intersection(&self, other: &Graph) -> Graph
Create a new graph containing the intersection of this graph and another
Sourcepub fn difference(&self, other: &Graph) -> Graph
pub fn difference(&self, other: &Graph) -> Graph
Create a new graph containing triples in this graph but not in the other
Sourcepub fn is_isomorphic_to(&self, other: &Graph) -> bool
pub fn is_isomorphic_to(&self, other: &Graph) -> bool
Check if the graph is isomorphic to another graph
This is a simplified check that doesn’t handle blank node isomorphism properly. For proper blank node isomorphism, a more sophisticated algorithm would be needed.
Sourcepub fn par_insert_batch(&mut self, triples: Vec<Triple>) -> Result<usize>
pub fn par_insert_batch(&mut self, triples: Vec<Triple>) -> Result<usize>
Insert triples in parallel batches
This method uses parallel processing to insert a large collection of triples efficiently. It automatically batches the triples and processes them across multiple CPU cores.
Sourcepub fn par_remove_batch(&mut self, triples: Vec<Triple>) -> Result<usize>
pub fn par_remove_batch(&mut self, triples: Vec<Triple>) -> Result<usize>
Remove triples in parallel batches
This method uses parallel processing to remove a large collection of triples efficiently. It automatically batches the triples and processes them across multiple CPU cores.
Sourcepub fn par_query_batch(
&self,
queries: Vec<(Option<Subject>, Option<Predicate>, Option<Object>)>,
) -> Result<Vec<Vec<Triple>>>
pub fn par_query_batch( &self, queries: Vec<(Option<Subject>, Option<Predicate>, Option<Object>)>, ) -> Result<Vec<Vec<Triple>>>
Query triples in parallel batches
This method performs multiple queries in parallel, returning all matching triples. Each query pattern is processed concurrently for improved performance.
Sourcepub fn par_transform<F>(&mut self, transform_fn: F) -> Result<(usize, usize)>
pub fn par_transform<F>(&mut self, transform_fn: F) -> Result<(usize, usize)>
Apply a transformation function to all triples in parallel
This method applies a transformation function to each triple in the graph in parallel. The function can return None to remove a triple or Some(triple) to replace it.
Sourcepub fn par_iter(&self) -> impl ParallelIterator<Item = &Triple>
pub fn par_iter(&self) -> impl ParallelIterator<Item = &Triple>
Create a parallel iterator over the graph’s triples
This allows for parallel processing of triples using rayon’s parallel iterator traits.
Trait Implementations§
Source§impl Extend<Triple> for Graph
impl Extend<Triple> for Graph
Source§fn extend<I: IntoIterator<Item = Triple>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Triple>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<Triple> for Graph
impl FromIterator<Triple> for Graph
Source§impl<'a> IntoIterator for &'a Graph
impl<'a> IntoIterator for &'a Graph
Source§impl IntoIterator for Graph
impl IntoIterator for Graph
impl Eq for Graph
impl StructuralPartialEq for Graph
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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>
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