pub struct TripleRepository { /* private fields */ }Implementations§
Source§impl TripleRepository
impl TripleRepository
pub fn new(pool: PgPool) -> Self
Sourcepub async fn scan_all_page(
&self,
after_id: i64,
limit: i64,
) -> Result<Vec<(i64, Triple)>, DomainError>
pub async fn scan_all_page( &self, after_id: i64, limit: i64, ) -> Result<Vec<(i64, Triple)>, DomainError>
Stable keyset page over the complete quad table for maintenance jobs. Ordering by the immutable surrogate id avoids OFFSET’s growing scan cost and permits bounded-memory rebuilds on production corpora.
Sourcepub async fn scan_graph_page(
&self,
graph: &str,
after_id: i64,
limit: i64,
) -> Result<Vec<(i64, Triple)>, DomainError>
pub async fn scan_graph_page( &self, graph: &str, after_id: i64, limit: i64, ) -> Result<Vec<(i64, Triple)>, DomainError>
Stable keyset page over one named graph for bounded Graph Store reads.
Sourcepub async fn insert_triples(
&self,
conn: &mut PgConnection,
triples: &[Triple],
source: &str,
) -> Result<usize, DomainError>
pub async fn insert_triples( &self, conn: &mut PgConnection, triples: &[Triple], source: &str, ) -> Result<usize, DomainError>
Write a batch of triples in one UNNEST-backed round-trip. This is the
RDF write primitive (Graph Store CRUD POST, SPARQL INSERT, and SBOL
document import), tagged with source (e.g. "graph-store",
"sparql-update", "sbol"). Each triple’s graph_iri is its owner (the
graph row must already exist; see Self::ensure_graph).
A graph is a set of triples, so a triple already present in its graph is
not stored again: the sbol_triples identity index makes the write a
no-op via ON CONFLICT DO NOTHING, including duplicates within this same
batch. Returns the count of triples actually inserted (new to the graph).
Sourcepub async fn delete_triples(
&self,
conn: &mut PgConnection,
triples: &[Triple],
) -> Result<usize, DomainError>
pub async fn delete_triples( &self, conn: &mut PgConnection, triples: &[Triple], ) -> Result<usize, DomainError>
Delete every row that exactly matches one of triples on all RDF
positions (graph, subject, predicate, object, datatype, language) in one
DELETE ... USING UNNEST round-trip. IS NOT DISTINCT FROM makes NULL
positions (default graph, blank vs IRI) match by value, not collapse.
This is the delete half of SPARQL DELETE/DELETE DATA and Graph Store
CRUD edits. Ignores graph_id/source: a triple is matched by its RDF
content regardless of which writer produced it. Returns the deleted count.
Sourcepub async fn clear_graph(
&self,
conn: &mut PgConnection,
graph: Option<&str>,
) -> Result<usize, DomainError>
pub async fn clear_graph( &self, conn: &mut PgConnection, graph: Option<&str>, ) -> Result<usize, DomainError>
Delete every triple in a named graph. Backs SPARQL CLEAR/DROP GRAPH
and Graph Store CRUD DELETE. graph of None clears the default
(graphless) partition. Returns the deleted count.
Sourcepub async fn ensure_graph(
&self,
conn: &mut PgConnection,
iri: &str,
kind: &str,
) -> Result<(), DomainError>
pub async fn ensure_graph( &self, conn: &mut PgConnection, iri: &str, kind: &str, ) -> Result<(), DomainError>
Register a named graph if it is not already present. Every triple with a
named graph_iri is owned by its sbol_graphs row (FK, ON DELETE CASCADE), so writers must ensure the graph exists before inserting.
kind is "document" for a graph dedicated to one imported SBOL
document, or "rdf" for a standalone/shared graph (the triplestore
case). A pre-existing graph keeps its original kind.
Sourcepub async fn delete_graph(
&self,
conn: &mut PgConnection,
iri: &str,
) -> Result<bool, DomainError>
pub async fn delete_graph( &self, conn: &mut PgConnection, iri: &str, ) -> Result<bool, DomainError>
Delete a graph entirely: remove its sbol_graphs row, which cascades to
its triples (derived-view objects and validation runs have ON DELETE SET NULL and survive). Backs Graph Store CRUD DELETE, SPARQL DROP GRAPH,
and document deletion (an sbol3-kind graph is a document). Returns
whether a row was removed.
pub async fn triples_for_subject( &self, subject_iri: &str, ) -> Result<Vec<Triple>, DomainError>
Sourcepub async fn scan_pattern(
&self,
subject: Option<&PatternSubject>,
predicate: Option<&str>,
object: Option<&PatternObject>,
graph: Option<&GraphFilter>,
limit: i64,
) -> Result<Vec<Triple>, DomainError>
pub async fn scan_pattern( &self, subject: Option<&PatternSubject>, predicate: Option<&str>, object: Option<&PatternObject>, graph: Option<&GraphFilter>, limit: i64, ) -> Result<Vec<Triple>, DomainError>
Triple-pattern scan over sbol_triples.
Any combination of subject / predicate / object / graph positions may be
bound (Some(...)) or wildcarded (None). The SQL WHERE clause is
built dynamically so Postgres’ planner sees only the bound predicates
and picks the right SPOG/POSG/OSPG/GSPO index for the access shape.
limit caps the rows returned per call (per-pattern scan cap, not a
total-result cap — that’s enforced higher up).
Sourcepub async fn scan_graph_in_conn(
&self,
conn: &mut PgConnection,
graph: &str,
) -> Result<Vec<Triple>, DomainError>
pub async fn scan_graph_in_conn( &self, conn: &mut PgConnection, graph: &str, ) -> Result<Vec<Triple>, DomainError>
Fetch every triple in one named graph through the caller’s connection, so it sees triples the same transaction has written but not yet committed. The accelerator uses this to rebuild a graph’s indexes inside the write transaction.
Sourcepub async fn distinct_named_graphs(&self) -> Result<Vec<String>, DomainError>
pub async fn distinct_named_graphs(&self) -> Result<Vec<String>, DomainError>
Enumerate distinct named graphs present in sbol_triples. Used by SPARQL
evaluation to discover the named-graph universe.
Sourcepub async fn triples_for_graph(
&self,
graph: Option<&str>,
limit: i64,
) -> Result<Vec<Triple>, DomainError>
pub async fn triples_for_graph( &self, graph: Option<&str>, limit: i64, ) -> Result<Vec<Triple>, DomainError>
Fetch every triple in one named graph (Some) or the default/graphless
partition (None). Backs the Graph Store CRUD GET. limit caps the
rows returned.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TripleRepository
impl !UnwindSafe for TripleRepository
impl Freeze for TripleRepository
impl Send for TripleRepository
impl Sync for TripleRepository
impl Unpin for TripleRepository
impl UnsafeUnpin for TripleRepository
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