pub struct Omnigraph { /* private fields */ }Expand description
Top-level handle to an Omnigraph database.
An Omnigraph is a Lance-native graph database with git-style branching. It stores typed property graphs as per-type Lance datasets coordinated through a Lance manifest table.
Implementations§
Source§impl Omnigraph
impl Omnigraph
Sourcepub async fn init(uri: &str, schema_source: &str) -> Result<Self>
pub async fn init(uri: &str, schema_source: &str) -> Result<Self>
Create a new repo at uri from schema source.
Creates _schema.pg, per-type Lance datasets, and __manifest.
Sourcepub async fn open(uri: &str) -> Result<Self>
pub async fn open(uri: &str) -> Result<Self>
Open an existing repo (read-write).
Reads _schema.pg, parses it, builds the catalog, and opens __manifest.
Runs the open-time recovery sweep before returning — see OpenMode.
Sourcepub async fn open_read_only(uri: &str) -> Result<Self>
pub async fn open_read_only(uri: &str) -> Result<Self>
Open an existing repo for read-only consumers (NDJSON export,
commit list, etc.). Skips the recovery sweep — see OpenMode.
Sourcepub fn catalog(&self) -> Arc<Catalog>
pub fn catalog(&self) -> Arc<Catalog>
Returns an Arc<Catalog> snapshot. Cheap clone of the current
catalog pointer; callers can hold the returned Arc across awaits
without blocking concurrent apply_schema.
Sourcepub fn schema_source(&self) -> Arc<String>
pub fn schema_source(&self) -> Arc<String>
Returns an Arc<String> snapshot of the schema source.
pub fn uri(&self) -> &str
pub async fn plan_schema( &self, desired_schema_source: &str, ) -> Result<SchemaMigrationPlan>
pub async fn apply_schema( &self, desired_schema_source: &str, ) -> Result<SchemaApplyResult>
pub async fn snapshot_of( &self, target: impl Into<ReadTarget>, ) -> Result<Snapshot>
pub async fn version_of(&self, target: impl Into<ReadTarget>) -> Result<u64>
pub async fn resolved_branch_of( &self, target: impl Into<ReadTarget>, ) -> Result<Option<String>>
Sourcepub async fn sync_branch(&self, branch: &str) -> Result<()>
pub async fn sync_branch(&self, branch: &str) -> Result<()>
Synchronize this handle’s write base to the latest head of the named branch.
Sourcepub async fn refresh(&self) -> Result<()>
pub async fn refresh(&self) -> Result<()>
Re-read the handle-local coordinator state from storage AND run
in-process recovery. Closes the Phase B → Phase C residual (e.g.
MutationStaging::finalize crash mid-publish in a long-running
server) without restart.
Composition mirrors Omnigraph::open_with_storage_and_mode’s
recovery sequence, in the same order, with one restriction: the
manifest-drift sweep runs in RollForwardOnly mode (rollback /
abort cases defer to the next ReadWrite open because
Dataset::restore is unsafe under concurrency). Each step:
coordinator.refresh()— re-read manifest.recover_schema_state_files— complete an in-flight schema_apply’s staging→final rename if a SchemaApply sidecar is on disk; idempotent + early-returns when no staging files exist. Required BEFORE manifest-drift recovery so a SchemaApply roll-forward doesn’t publish the manifest while the staging files remain unrenamed (which would corrupt the repo: data on new schema, catalog on old).recover_manifest_drift(... RollForwardOnly)— close the finalize→publisher residual via roll-forward; defer rollback work to next ReadWrite open.runtime_cache.invalidate_all— drop stale per-snapshot caches.
Steady state cost: one list_dir of __recovery/ (typically
returns empty → early return for both passes). No additional
Lance reads.
Engine-internal callers that already hold an in-flight sidecar
(e.g. schema_apply mid-write) MUST use
refresh_coordinator_only to
avoid the recovery sweep racing their own sidecar.
pub async fn resolve_snapshot(&self, branch: &str) -> Result<SnapshotId>
pub async fn diff_between( &self, from: impl Into<ReadTarget>, to: impl Into<ReadTarget>, filter: &ChangeFilter, ) -> Result<ChangeSet>
Sourcepub async fn diff_commits(
&self,
from_commit_id: &str,
to_commit_id: &str,
filter: &ChangeFilter,
) -> Result<ChangeSet>
pub async fn diff_commits( &self, from_commit_id: &str, to_commit_id: &str, filter: &ChangeFilter, ) -> Result<ChangeSet>
Diff two graph commits. Resolves each commit to (manifest_branch, manifest_version)
and creates branch-aware snapshots. Supports cross-branch comparison.
pub async fn entity_at_target( &self, target: impl Into<ReadTarget>, table_key: &str, id: &str, ) -> Result<Option<Value>>
Sourcepub async fn entity_at(
&self,
table_key: &str,
id: &str,
version: u64,
) -> Result<Option<Value>>
pub async fn entity_at( &self, table_key: &str, id: &str, version: u64, ) -> Result<Option<Value>>
Read one entity at a specific manifest version via time travel (on-demand enrichment).
Sourcepub async fn snapshot_at_version(&self, version: u64) -> Result<Snapshot>
pub async fn snapshot_at_version(&self, version: u64) -> Result<Snapshot>
Create a Snapshot at any historical manifest version.
pub async fn export_jsonl( &self, branch: &str, type_names: &[String], table_keys: &[String], ) -> Result<String>
pub async fn export_jsonl_to_writer<W: Write>( &self, branch: &str, type_names: &[String], table_keys: &[String], writer: &mut W, ) -> Result<()>
Sourcepub async fn graph_index(&self) -> Result<Arc<GraphIndex>>
pub async fn graph_index(&self) -> Result<Arc<GraphIndex>>
Get or build the graph index for the current snapshot.
Sourcepub async fn ensure_indices(&self) -> Result<()>
pub async fn ensure_indices(&self) -> Result<()>
Ensure BTree scalar indices exist on key columns. Idempotent — Lance skips if index already exists.
Opens sub-tables at their latest version (not snapshot-pinned) because indices must be created on the current head. Any version drift from the snapshot is expected and logged. The resulting versions are committed back to the manifest.
On named branches, indexing preserves lazy branching:
unbranched subtables keep inheriting main, while subtables inherited
from an ancestor branch are first forked into the active branch before
their index metadata is updated.
pub async fn ensure_indices_on(&self, branch: &str) -> Result<()>
Sourcepub async fn optimize(&self) -> Result<Vec<TableOptimizeStats>>
pub async fn optimize(&self) -> Result<Vec<TableOptimizeStats>>
Compact small Lance fragments into fewer larger ones across every
node + edge table on main. See [optimize] for details.
Sourcepub async fn cleanup(
&mut self,
options: CleanupPolicyOptions,
) -> Result<Vec<TableCleanupStats>>
pub async fn cleanup( &mut self, options: CleanupPolicyOptions, ) -> Result<Vec<TableCleanupStats>>
Remove Lance manifests (and the fragments they uniquely own) per the
given optimize::CleanupPolicyOptions. Destructive to version
history. See [optimize] for details.
Sourcepub async fn read_blob(
&self,
type_name: &str,
id: &str,
property: &str,
) -> Result<BlobFile>
pub async fn read_blob( &self, type_name: &str, id: &str, property: &str, ) -> Result<BlobFile>
Read a blob from a node by its string ID and property name.
Returns a BlobFile handle with async read(), seek(), tell(),
and metadata accessors (size(), kind(), uri()).
let blob = db.read_blob("Document", "readme", "content").await?;
let bytes = blob.read().await?;pub async fn branch_create(&self, name: &str) -> Result<()>
pub async fn branch_create_from( &self, from: impl Into<ReadTarget>, name: &str, ) -> Result<()>
pub async fn branch_list(&self) -> Result<Vec<String>>
pub async fn branch_delete(&self, name: &str) -> Result<()>
pub async fn get_commit(&self, commit_id: &str) -> Result<GraphCommit>
pub async fn list_commits( &self, branch: Option<&str>, ) -> Result<Vec<GraphCommit>>
Source§impl Omnigraph
impl Omnigraph
pub async fn branch_merge( &self, source: &str, target: &str, ) -> Result<MergeOutcome>
pub async fn branch_merge_as( &self, source: &str, target: &str, actor_id: Option<&str>, ) -> Result<MergeOutcome>
Source§impl Omnigraph
impl Omnigraph
Sourcepub async fn query(
&self,
target: impl Into<ReadTarget>,
query_source: &str,
query_name: &str,
params: &ParamMap,
) -> Result<QueryResult>
pub async fn query( &self, target: impl Into<ReadTarget>, query_source: &str, query_name: &str, params: &ParamMap, ) -> Result<QueryResult>
Run a named query against an explicit branch or snapshot target.
Sourcepub async fn run_query_at(
&self,
version: u64,
query_source: &str,
query_name: &str,
params: &ParamMap,
) -> Result<QueryResult>
pub async fn run_query_at( &self, version: u64, query_source: &str, query_name: &str, params: &ParamMap, ) -> Result<QueryResult>
Run a named query against the graph as it existed at a prior manifest version.
Compiles the query normally, builds a temporary (non-cached) graph index if traversal is needed, and executes against the historical snapshot.
Source§impl Omnigraph
impl Omnigraph
pub async fn ingest( &self, branch: &str, from: Option<&str>, data: &str, mode: LoadMode, ) -> Result<IngestResult>
pub async fn ingest_as( &self, branch: &str, from: Option<&str>, data: &str, mode: LoadMode, actor_id: Option<&str>, ) -> Result<IngestResult>
pub async fn ingest_file( &self, branch: &str, from: Option<&str>, path: &str, mode: LoadMode, ) -> Result<IngestResult>
pub async fn ingest_file_as( &self, branch: &str, from: Option<&str>, path: &str, mode: LoadMode, actor_id: Option<&str>, ) -> Result<IngestResult>
pub async fn load( &self, branch: &str, data: &str, mode: LoadMode, ) -> Result<LoadResult>
pub async fn load_as( &self, branch: &str, data: &str, mode: LoadMode, actor_id: Option<&str>, ) -> Result<LoadResult>
pub async fn load_file( &self, branch: &str, path: &str, mode: LoadMode, ) -> Result<LoadResult>
Auto Trait Implementations§
impl !Freeze for Omnigraph
impl !RefUnwindSafe for Omnigraph
impl Send for Omnigraph
impl Sync for Omnigraph
impl Unpin for Omnigraph
impl UnsafeUnpin for Omnigraph
impl !UnwindSafe for Omnigraph
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.