pub struct ConcurrentGraph { /* private fields */ }Expand description
Thread-safe concurrent graph for multi-threaded access
This struct wraps the Graph in an Arc<RwLock<_>> to provide safe concurrent access across multiple threads. It implements reader-writer semantics where multiple readers can access the graph simultaneously, but only one writer can modify it at a time.
Implementations§
Source§impl ConcurrentGraph
impl ConcurrentGraph
Sourcepub fn from_graph(graph: Graph) -> Self
pub fn from_graph(graph: Graph) -> Self
Create a concurrent graph from an existing graph
Sourcepub fn add_triple(&self, triple: Triple) -> bool
pub fn add_triple(&self, triple: Triple) -> bool
Add a triple to the graph (thread-safe)
Sourcepub fn add_triples(&self, triples: Vec<Triple>) -> usize
pub fn add_triples(&self, triples: Vec<Triple>) -> usize
Add multiple triples atomically
Sourcepub fn remove_triple(&self, triple: &Triple) -> bool
pub fn remove_triple(&self, triple: &Triple) -> bool
Remove a triple from the graph (thread-safe)
Sourcepub fn contains_triple(&self, triple: &Triple) -> bool
pub fn contains_triple(&self, triple: &Triple) -> bool
Check if a triple exists in the graph (thread-safe read)
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 (thread-safe read)
Sourcepub fn merge_concurrent(&self, other: &ConcurrentGraph)
pub fn merge_concurrent(&self, other: &ConcurrentGraph)
Merge another concurrent graph into this one (thread-safe)
Sourcepub fn union(&self, other: &Graph) -> Graph
pub fn union(&self, other: &Graph) -> Graph
Create a union with another graph (thread-safe read)
Sourcepub fn intersection(&self, other: &Graph) -> Graph
pub fn intersection(&self, other: &Graph) -> Graph
Create an intersection with another graph (thread-safe read)
Sourcepub fn with_read<F, R>(&self, f: F) -> R
pub fn with_read<F, R>(&self, f: F) -> R
Execute a read operation with access to the underlying graph
Sourcepub fn with_write<F, R>(&self, f: F) -> R
pub fn with_write<F, R>(&self, f: F) -> R
Execute a write operation with access to the underlying graph
Sourcepub fn par_insert_batch(&self, triples: Vec<Triple>) -> Result<usize>
pub fn par_insert_batch(&self, triples: Vec<Triple>) -> Result<usize>
Parallel batch insert (thread-safe)
Sourcepub fn par_remove_batch(&self, triples: Vec<Triple>) -> Result<usize>
pub fn par_remove_batch(&self, triples: Vec<Triple>) -> Result<usize>
Parallel batch remove (thread-safe)
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>>>
Parallel batch query (thread-safe read)
Sourcepub fn predicates(&self) -> BTreeSet<Predicate>
pub fn predicates(&self) -> BTreeSet<Predicate>
Get predicates concurrently
Trait Implementations§
Source§impl Clone for ConcurrentGraph
impl Clone for ConcurrentGraph
Source§fn clone(&self) -> ConcurrentGraph
fn clone(&self) -> ConcurrentGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConcurrentGraph
impl Debug for ConcurrentGraph
Auto Trait Implementations§
impl Freeze for ConcurrentGraph
impl !RefUnwindSafe for ConcurrentGraph
impl Send for ConcurrentGraph
impl Sync for ConcurrentGraph
impl Unpin for ConcurrentGraph
impl UnsafeUnpin for ConcurrentGraph
impl !UnwindSafe for ConcurrentGraph
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<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