Skip to main content

Store

Struct Store 

Source
pub struct Store<B: SyncBackend = RusqliteBackend> { /* private fields */ }
Expand description

An RDF dataset stored in SQLite, queryable with SPARQL.

Mirrors oxigraph::store::Store. It is cheap to clone (shared handle).

Implementations§

Source§

impl<B: SyncBackend + Send + Sync + 'static> Store<B>

Source

pub fn register_schema_graph<'a>( &self, graph: impl Into<GraphNameRef<'a>>, role: SchemaRole, registration: &Registration, ) -> Result<()>

Declares a graph to hold an ontology, SHACL shapes or a ShEx schema, and which graphs it applies to.

The graph’s triples are untouched and stay queryable. Registering the first ontology graph narrows reasoning to the registered ones; the same holds for shapes and the compiled shape index. Registering a graph again replaces its description.

Source

pub fn schema_graphs(&self) -> Result<Vec<RegisteredGraph>>

The registry, ordered by role and graph.

Source

pub fn schema_graphs_for<'a>( &self, target: impl Into<GraphNameRef<'a>>, role: SchemaRole, ) -> Result<Vec<GraphName>>

The active schema graphs of role that apply to target.

Source

pub fn set_schema_graph_targets<'a>( &self, graph: impl Into<GraphNameRef<'a>>, applies_to: &[GraphName], ) -> Result<bool>

Sets the graphs a registration applies to (empty: every graph), keeping the rest of its description; returns whether one was found.

Source

pub fn registry_problems(&self) -> Result<Vec<String>>

What is wrong with the registry: the violations of its SHACL shapes (oxl:RegistrationShape), one message each. Empty means valid.

Source

pub fn set_schema_graph_active<'a>( &self, graph: impl Into<GraphNameRef<'a>>, active: bool, ) -> Result<bool>

Activates or deactivates a registration; returns whether one was found.

Source

pub fn unregister_schema_graph<'a>( &self, graph: impl Into<GraphNameRef<'a>>, ) -> Result<bool>

Removes a registration, leaving the graph’s triples in place; returns whether one was found.

Source

pub fn drop_schema_graph<'a>( &self, graph: impl Into<GraphNameRef<'a>>, ) -> Result<u64>

Removes a registration together with every quad of its graph, in one atomic update; returns how many quads the graph held.

Source

pub fn system_graphs_installed(&self) -> Result<bool>

Are the system graphs (<oxilite:vocabulary> and the registry’s own description) installed at the current vocabulary version?

Source

pub fn install_system_graphs(&self) -> Result<bool>

Installs or refreshes the system graphs (what StoreOptions::system_graphs does for a blank store); registrations are untouched. Returns false when they were already current.

Source

pub fn shape_index(&self) -> Result<ShapeIndex>

The compiled SHACL property shapes of the registered shapes graphs (of every graph while none is registered). One request, no SPARQL evaluation.

Source§

impl Store

Source

pub fn new() -> Result<Self>

A new in-memory store.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Opens (or creates) a store in a SQLite database file.

Source

pub fn open_with_options( path: impl AsRef<Path>, options: StoreOptions, ) -> Result<Self>

Opens a store with explicit options (used when the database is created).

Source

pub fn open_read_only(path: impl AsRef<Path>) -> Result<Self>

Opens an existing store read-only.

Source§

impl<B: SyncBackend + Send + Sync + 'static> Store<B>

Source

pub fn with_backend(backend: B) -> Result<Self>

Opens a store over any backend (creating the schema if needed).

Source

pub fn with_backend_and_options( backend: B, options: &StoreOptions, ) -> Result<Self>

Source

pub fn backend(&self) -> &B

The backend.

Source

pub fn query(&self, query: impl IntoQuery) -> Result<QueryResults<'static>>

Executes a SPARQL query.

Source

pub fn query_opt( &self, query: impl IntoQuery, options: QueryOptions, ) -> Result<QueryResults<'static>>

Executes a SPARQL query with options.

Source

pub fn query_output( &self, query: impl IntoQuery, options: &QueryOptions, ) -> Result<QueryOutput>

Executes a SPARQL query, returning decoded output.

Source

pub fn explain(&self, query: impl IntoQuery) -> Result<String>

Returns the SQL a query compiles to (or why it is evaluated by the fallback).

Source

pub fn explain_opt( &self, query: impl IntoQuery, options: &QueryOptions, ) -> Result<String>

Source

pub fn quads_for_pattern( &self, subject: Option<NamedOrBlankNodeRef<'_>>, predicate: Option<NamedNodeRef<'_>>, object: Option<TermRef<'_>>, graph_name: Option<GraphNameRef<'_>>, ) -> QuadIter ⓘ

Quads matching a pattern (graph_name = None means any graph, default included).

Source

pub fn iter(&self) -> QuadIter ⓘ

All quads.

Source

pub fn contains<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>

Source

pub fn len(&self) -> Result<usize>

Source

pub fn is_empty(&self) -> Result<bool>

Source

pub fn explain_update(&self, update: impl IntoUpdate) -> Result<String>

Describes how an update runs: the SQL of each compiled operation, or why it needs the fallback.

Source

pub fn update(&self, update: impl IntoUpdate) -> Result<()>

Executes a SPARQL update atomically.

Source

pub fn load_from_reader( &self, parser: impl Into<RdfParser>, reader: impl Read, ) -> Result<()>

Loads a document atomically (blank nodes are renamed, like Oxigraph).

Source

pub fn load_from_slice( &self, parser: impl Into<RdfParser>, slice: &(impl AsRef<[u8]> + ?Sized), ) -> Result<()>

Source

pub fn insert<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>

Inserts a quad; returns true if it was not already present.

Source

pub fn extend( &self, quads: impl IntoIterator<Item = impl Into<Quad>>, ) -> Result<()>

Inserts quads atomically.

Source

pub fn remove<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>

Removes a quad; returns true if it was present.

Source

pub fn materialize(&self) -> Result<u64>

Computes the OWL 2 RL closure of the whole dataset into a separate inference table, replacing previous inferences; returns the number of inferred triples. Queries see them with QueryOptions::include_inferred. Runs SQL rules on every backend.

Source

pub fn clear_inferences(&self) -> Result<()>

Removes every materialized inference.

Source

pub fn clear_inferences_of(&self, producer: &str) -> Result<()>

Removes the inferences of one producer ("owl2rl", or a Datalog Options::producer), keeping those another producer also derived.

Source

pub fn inference_producers<'a>( &self, quad: impl Into<QuadRef<'a>>, ) -> Result<Vec<String>>

The producers that derived a materialized quad: empty when it is not an inference.

Source

pub fn dump_to_writer<W: Write>( &self, serializer: impl Into<RdfSerializer>, writer: W, ) -> Result<W>

Dumps the whole dataset (dataset formats: N-Quads, TriG).

Source

pub fn dump_graph_to_writer<'a, W: Write>( &self, from_graph_name: impl Into<GraphNameRef<'a>>, serializer: impl Into<RdfSerializer>, writer: W, ) -> Result<W>

Dumps one graph (graph formats: N-Triples, Turtle, RDF/XML…).

Source

pub fn named_graphs(&self) -> GraphNameIter ⓘ

Source

pub fn contains_named_graph<'a>( &self, graph_name: impl Into<NamedOrBlankNodeRef<'a>>, ) -> Result<bool>

Source

pub fn insert_named_graph<'a>( &self, graph_name: impl Into<NamedOrBlankNodeRef<'a>>, ) -> Result<bool>

Adds a named graph; returns true if it was new.

Source

pub fn clear_graph<'a>( &self, graph_name: impl Into<GraphNameRef<'a>>, ) -> Result<()>

Source

pub fn remove_named_graph<'a>( &self, graph_name: impl Into<NamedOrBlankNodeRef<'a>>, ) -> Result<bool>

Removes a named graph and its quads; returns true if it existed.

Source

pub fn clear(&self) -> Result<()>

Source

pub fn flush(&self) -> Result<()>

No-op: SQLite commits are durable (kept for Oxigraph API compatibility).

Source

pub fn optimize(&self) -> Result<()>

Refreshes the planner statistics (replaces RocksDB compaction).

Source

pub fn stats(&self) -> Stats

Current planner statistics.

Source

pub fn backup(&self, target: impl AsRef<Path>) -> Result<()>

Writes a consistent copy of the database to target (VACUUM INTO).

Source

pub fn bulk_loader(&self) -> BulkLoader<'_, B>

A loader for large imports, committing in chunks (not atomic, like Oxigraph’s).

Source

pub fn validate(&self) -> Result<()>

Checks internal consistency: SQLite integrity and that every stored id is decodable.

Source§

impl<B: SyncBackend + Send + Sync + 'static> Store<B>

Source

pub fn register_function(&self, function: HostFunction) -> Result<()>

Registers a host function, callable from SPARQL by its IRI, from Cypher by its Cypher name and from Datalog by its IRI (see oxilite_core::functions). It applies to this handle and its clones, and is not stored in the database.

Source

pub fn unregister_function(&self, iri: &str) -> bool

Removes a host function; false when none has this IRI.

Source

pub fn functions(&self) -> Vec<HostFunction>

The registered host functions.

Source

pub fn host_functions(&self) -> Functions

The registry, as the frontends’ options carry it.

Source

pub fn create_vector_index(&self, index: &VectorIndex) -> Result<()>

Creates a vector index: its definition in <oxilite:vectors>, its table and triggers, back-filled from the existing embeddings, in one atomic request. A malformed existing value fails the creation and changes nothing.

Source

pub fn drop_vector_index(&self, name: &str) -> Result<bool>

Drops a vector index (its definition and its table); false when none has this name.

Source

pub fn vector_indexes(&self) -> Result<Vec<VectorIndexInfo>>

The vector indexes, with whether each is built and how many embeddings it holds.

Source

pub fn vector_index_problems(&self) -> Vec<String>

Why descriptions in <oxilite:vectors> are not valid index definitions.

Source

pub fn sync_vector_indexes(&self) -> Result<bool>

Makes the built indexes match the definitions in <oxilite:vectors> (after a load that brought definitions, or a SPARQL update of them — updates call this themselves). Returns whether anything changed.

The k nodes nearest to query in an index, nearest first.

use oxilite::store::Store;
use oxilite::vector::{QueryVector, VectorIndex};
use oxilite::model::NamedNode;

let store = Store::new_turso()?;
store.update(r#"PREFIX ex: <http://example.com/>
    INSERT DATA { ex:a ex:e "[1, 0]" . ex:b ex:e "[0, 1]" }"#)?;
store.create_vector_index(&VectorIndex::new("docs", NamedNode::new("http://example.com/e")?, 2))?;
let hits = store.vector_search("docs", &QueryVector::vector(&[0.9, 0.1]), 1)?;
assert_eq!(hits[0].node.to_string(), "<http://example.com/a>");
Source§

impl<B: SyncBackend + Send + Sync + 'static> Store<B>

Source

pub fn versioning(&self) -> Result<VersionStatus>

The versioning level and where the clock and history stand.

Source

pub fn set_versioning( &self, level: Versioning, change: LevelChange, ) -> Result<VersionStatus>

Changes the versioning level (and its index options). Upgrades never lose data; a downgrade keeps the recorded history (frozen) and the ticks unless change.allow_loss. One atomic request; returns the new status.

Source

pub fn set_commit_info(&self, info: CommitInfo)

Author and message recorded on the ticks of the following writes (until changed).

Source

pub fn commit_info(&self) -> CommitInfo

Author and message recorded on the ticks of writes.

Source

pub fn with_commit<T>( &self, info: CommitInfo, f: impl FnOnce(&Self) -> Result<T>, ) -> Result<T>

Runs f with info recorded on its writes, then restores the previous commit info.

Source

pub fn resolve_version(&self, version: &str) -> Result<i64>

The tick a version reference (HEAD~2, #42, @2026-09-01T00:00:00Z) designates.

Source

pub fn history(&self, limit: usize) -> Result<Vec<CommitRecord>>

The latest limit commits and level changes, newest first.

Source

pub fn changes(&self, after: i64, until: Option<i64>) -> Result<Vec<Change>>

The changes after tick after, up to tick until (inclusive). With a change log, every addition and removal; with only the clock, the current quads added in that range.

Source

pub fn diff(&self, from: &str, to: &str) -> Result<Vec<Change>>

The net difference between two versions: quads added and removed from from to to.

Source

pub fn purge( &self, subject: Option<NamedOrBlankNodeRef<'_>>, predicate: Option<NamedNodeRef<'_>>, object: Option<TermRef<'_>>, graph_name: Option<GraphNameRef<'_>>, reason: Option<&str>, ) -> Result<()>

Removes the quads matching the pattern from the store and from the whole history, recording a purge tick that names no removed content — for erasure requests. None matches anything; with every part None the whole store and history are purged.

Trait Implementations§

Source§

impl<B: SyncBackend> Clone for Store<B>

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§

§

impl<B> Freeze for Store<B>
where Arc<Inner<B>>: Freeze,

§

impl<B> RefUnwindSafe for Store<B>
where Arc<Inner<B>>: RefUnwindSafe,

§

impl<B> Send for Store<B>
where Arc<Inner<B>>: Send,

§

impl<B> Sync for Store<B>
where Arc<Inner<B>>: Sync,

§

impl<B> Unpin for Store<B>
where Arc<Inner<B>>: Unpin,

§

impl<B> UnsafeUnpin for Store<B>
where Arc<Inner<B>>: UnsafeUnpin,

§

impl<B> UnwindSafe for Store<B>
where Arc<Inner<B>>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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