Skip to main content

TripleRepository

Struct TripleRepository 

Source
pub struct TripleRepository { /* private fields */ }

Implementations§

Source§

impl TripleRepository

Source

pub fn new(pool: PgPool) -> Self

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn triples_for_subject( &self, subject_iri: &str, ) -> Result<Vec<Triple>, DomainError>

Source

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).

Source

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.

Source

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.

Source

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§

Source§

impl Clone for TripleRepository

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more