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>
impl<B: SyncBackend + Send + Sync + 'static> Store<B>
Sourcepub fn register_schema_graph<'a>(
&self,
graph: impl Into<GraphNameRef<'a>>,
role: SchemaRole,
registration: &Registration,
) -> Result<()>
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.
Sourcepub fn schema_graphs(&self) -> Result<Vec<RegisteredGraph>>
pub fn schema_graphs(&self) -> Result<Vec<RegisteredGraph>>
The registry, ordered by role and graph.
Sourcepub fn schema_graphs_for<'a>(
&self,
target: impl Into<GraphNameRef<'a>>,
role: SchemaRole,
) -> Result<Vec<GraphName>>
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.
Sourcepub fn set_schema_graph_targets<'a>(
&self,
graph: impl Into<GraphNameRef<'a>>,
applies_to: &[GraphName],
) -> Result<bool>
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.
Sourcepub fn registry_problems(&self) -> Result<Vec<String>>
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.
Sourcepub fn set_schema_graph_active<'a>(
&self,
graph: impl Into<GraphNameRef<'a>>,
active: bool,
) -> Result<bool>
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.
Sourcepub fn unregister_schema_graph<'a>(
&self,
graph: impl Into<GraphNameRef<'a>>,
) -> Result<bool>
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.
Sourcepub fn drop_schema_graph<'a>(
&self,
graph: impl Into<GraphNameRef<'a>>,
) -> Result<u64>
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.
Sourcepub fn system_graphs_installed(&self) -> Result<bool>
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?
Sourcepub fn install_system_graphs(&self) -> Result<bool>
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.
Sourcepub fn shape_index(&self) -> Result<ShapeIndex>
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
impl Store
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Opens (or creates) a store in a SQLite database file.
Sourcepub fn open_with_options(
path: impl AsRef<Path>,
options: StoreOptions,
) -> Result<Self>
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).
Sourcepub fn open_read_only(path: impl AsRef<Path>) -> Result<Self>
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>
impl<B: SyncBackend + Send + Sync + 'static> Store<B>
Sourcepub fn with_backend(backend: B) -> Result<Self>
pub fn with_backend(backend: B) -> Result<Self>
Opens a store over any backend (creating the schema if needed).
pub fn with_backend_and_options( backend: B, options: &StoreOptions, ) -> Result<Self>
Sourcepub fn query(&self, query: impl IntoQuery) -> Result<QueryResults<'static>>
pub fn query(&self, query: impl IntoQuery) -> Result<QueryResults<'static>>
Executes a SPARQL query.
Sourcepub fn query_opt(
&self,
query: impl IntoQuery,
options: QueryOptions,
) -> Result<QueryResults<'static>>
pub fn query_opt( &self, query: impl IntoQuery, options: QueryOptions, ) -> Result<QueryResults<'static>>
Executes a SPARQL query with options.
Sourcepub fn query_output(
&self,
query: impl IntoQuery,
options: &QueryOptions,
) -> Result<QueryOutput>
pub fn query_output( &self, query: impl IntoQuery, options: &QueryOptions, ) -> Result<QueryOutput>
Executes a SPARQL query, returning decoded output.
Sourcepub fn explain(&self, query: impl IntoQuery) -> Result<String>
pub fn explain(&self, query: impl IntoQuery) -> Result<String>
Returns the SQL a query compiles to (or why it is evaluated by the fallback).
pub fn explain_opt( &self, query: impl IntoQuery, options: &QueryOptions, ) -> Result<String>
Sourcepub fn quads_for_pattern(
&self,
subject: Option<NamedOrBlankNodeRef<'_>>,
predicate: Option<NamedNodeRef<'_>>,
object: Option<TermRef<'_>>,
graph_name: Option<GraphNameRef<'_>>,
) -> QuadIter ⓘ
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).
pub fn contains<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>
pub fn len(&self) -> Result<usize>
pub fn is_empty(&self) -> Result<bool>
Sourcepub fn explain_update(&self, update: impl IntoUpdate) -> Result<String>
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.
Sourcepub fn update(&self, update: impl IntoUpdate) -> Result<()>
pub fn update(&self, update: impl IntoUpdate) -> Result<()>
Executes a SPARQL update atomically.
Sourcepub fn load_from_reader(
&self,
parser: impl Into<RdfParser>,
reader: impl Read,
) -> Result<()>
pub fn load_from_reader( &self, parser: impl Into<RdfParser>, reader: impl Read, ) -> Result<()>
Loads a document atomically (blank nodes are renamed, like Oxigraph).
pub fn load_from_slice( &self, parser: impl Into<RdfParser>, slice: &(impl AsRef<[u8]> + ?Sized), ) -> Result<()>
Sourcepub fn insert<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>
pub fn insert<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>
Inserts a quad; returns true if it was not already present.
Sourcepub fn extend(
&self,
quads: impl IntoIterator<Item = impl Into<Quad>>,
) -> Result<()>
pub fn extend( &self, quads: impl IntoIterator<Item = impl Into<Quad>>, ) -> Result<()>
Inserts quads atomically.
Sourcepub fn remove<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>
pub fn remove<'a>(&self, quad: impl Into<QuadRef<'a>>) -> Result<bool>
Removes a quad; returns true if it was present.
Sourcepub fn materialize(&self) -> Result<u64>
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.
Sourcepub fn clear_inferences(&self) -> Result<()>
pub fn clear_inferences(&self) -> Result<()>
Removes every materialized inference.
Sourcepub fn clear_inferences_of(&self, producer: &str) -> Result<()>
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.
Sourcepub fn inference_producers<'a>(
&self,
quad: impl Into<QuadRef<'a>>,
) -> Result<Vec<String>>
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.
Sourcepub fn dump_to_writer<W: Write>(
&self,
serializer: impl Into<RdfSerializer>,
writer: W,
) -> Result<W>
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).
Sourcepub fn dump_graph_to_writer<'a, W: Write>(
&self,
from_graph_name: impl Into<GraphNameRef<'a>>,
serializer: impl Into<RdfSerializer>,
writer: W,
) -> Result<W>
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…).
pub fn named_graphs(&self) -> GraphNameIter ⓘ
pub fn contains_named_graph<'a>( &self, graph_name: impl Into<NamedOrBlankNodeRef<'a>>, ) -> Result<bool>
Sourcepub fn insert_named_graph<'a>(
&self,
graph_name: impl Into<NamedOrBlankNodeRef<'a>>,
) -> Result<bool>
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.
pub fn clear_graph<'a>( &self, graph_name: impl Into<GraphNameRef<'a>>, ) -> Result<()>
Sourcepub fn remove_named_graph<'a>(
&self,
graph_name: impl Into<NamedOrBlankNodeRef<'a>>,
) -> Result<bool>
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.
pub fn clear(&self) -> Result<()>
Sourcepub fn flush(&self) -> Result<()>
pub fn flush(&self) -> Result<()>
No-op: SQLite commits are durable (kept for Oxigraph API compatibility).
Sourcepub fn optimize(&self) -> Result<()>
pub fn optimize(&self) -> Result<()>
Refreshes the planner statistics (replaces RocksDB compaction).
Sourcepub fn backup(&self, target: impl AsRef<Path>) -> Result<()>
pub fn backup(&self, target: impl AsRef<Path>) -> Result<()>
Writes a consistent copy of the database to target (VACUUM INTO).
Sourcepub fn bulk_loader(&self) -> BulkLoader<'_, B>
pub fn bulk_loader(&self) -> BulkLoader<'_, B>
A loader for large imports, committing in chunks (not atomic, like Oxigraph’s).
Source§impl<B: SyncBackend + Send + Sync + 'static> Store<B>
impl<B: SyncBackend + Send + Sync + 'static> Store<B>
Sourcepub fn register_function(&self, function: HostFunction) -> Result<()>
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.
Sourcepub fn unregister_function(&self, iri: &str) -> bool
pub fn unregister_function(&self, iri: &str) -> bool
Removes a host function; false when none has this IRI.
Sourcepub fn functions(&self) -> Vec<HostFunction>
pub fn functions(&self) -> Vec<HostFunction>
The registered host functions.
Sourcepub fn host_functions(&self) -> Functions
pub fn host_functions(&self) -> Functions
The registry, as the frontends’ options carry it.
Sourcepub fn create_vector_index(&self, index: &VectorIndex) -> Result<()>
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.
Sourcepub fn drop_vector_index(&self, name: &str) -> Result<bool>
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.
Sourcepub fn vector_indexes(&self) -> Result<Vec<VectorIndexInfo>>
pub fn vector_indexes(&self) -> Result<Vec<VectorIndexInfo>>
The vector indexes, with whether each is built and how many embeddings it holds.
Sourcepub fn vector_index_problems(&self) -> Vec<String>
pub fn vector_index_problems(&self) -> Vec<String>
Why descriptions in <oxilite:vectors> are not valid index definitions.
Sourcepub fn sync_vector_indexes(&self) -> Result<bool>
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.
Sourcepub fn vector_search(
&self,
name: &str,
query: &QueryVector,
k: u64,
) -> Result<Vec<VectorHit>>
pub fn vector_search( &self, name: &str, query: &QueryVector, k: u64, ) -> Result<Vec<VectorHit>>
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>
impl<B: SyncBackend + Send + Sync + 'static> Store<B>
Sourcepub fn versioning(&self) -> Result<VersionStatus>
pub fn versioning(&self) -> Result<VersionStatus>
The versioning level and where the clock and history stand.
Sourcepub fn set_versioning(
&self,
level: Versioning,
change: LevelChange,
) -> Result<VersionStatus>
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.
Sourcepub fn set_commit_info(&self, info: CommitInfo)
pub fn set_commit_info(&self, info: CommitInfo)
Author and message recorded on the ticks of the following writes (until changed).
Sourcepub fn commit_info(&self) -> CommitInfo
pub fn commit_info(&self) -> CommitInfo
Author and message recorded on the ticks of writes.
Sourcepub fn with_commit<T>(
&self,
info: CommitInfo,
f: impl FnOnce(&Self) -> Result<T>,
) -> Result<T>
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.
Sourcepub fn resolve_version(&self, version: &str) -> Result<i64>
pub fn resolve_version(&self, version: &str) -> Result<i64>
The tick a version reference (HEAD~2, #42, @2026-09-01T00:00:00Z) designates.
Sourcepub fn history(&self, limit: usize) -> Result<Vec<CommitRecord>>
pub fn history(&self, limit: usize) -> Result<Vec<CommitRecord>>
The latest limit commits and level changes, newest first.
Sourcepub fn changes(&self, after: i64, until: Option<i64>) -> Result<Vec<Change>>
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.
Sourcepub fn diff(&self, from: &str, to: &str) -> Result<Vec<Change>>
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.
Sourcepub fn purge(
&self,
subject: Option<NamedOrBlankNodeRef<'_>>,
predicate: Option<NamedNodeRef<'_>>,
object: Option<TermRef<'_>>,
graph_name: Option<GraphNameRef<'_>>,
reason: Option<&str>,
) -> Result<()>
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.