pub struct SqliteGraphBackend { /* private fields */ }Expand description
SQLite-backed implementation of the GraphBackend trait.
This struct wraps a SqliteGraph instance and implements all GraphBackend methods by delegating to the underlying SQLite-based graph operations.
Implementations§
Source§impl SqliteGraphBackend
impl SqliteGraphBackend
Sourcepub fn in_memory() -> Result<Self, SqliteGraphError>
pub fn in_memory() -> Result<Self, SqliteGraphError>
Create a new SQLite backend with an in-memory database.
Sourcepub fn from_graph(graph: SqliteGraph) -> Self
pub fn from_graph(graph: SqliteGraph) -> Self
Create a new SQLite backend from an existing SqliteGraph instance.
Sourcepub fn graph(&self) -> &SqliteGraph
pub fn graph(&self) -> &SqliteGraph
Get a reference to the underlying SqliteGraph instance.
Sourcepub fn create_hnsw_storage(
&self,
_index_name: impl Into<String>,
) -> Option<Box<dyn VectorStorage>>
pub fn create_hnsw_storage( &self, _index_name: impl Into<String>, ) -> Option<Box<dyn VectorStorage>>
Create a new HNSW vector storage using this SQLite backend
§Arguments
index_name- Name for the HNSW index (used for table naming)
§Returns
Some(Box<dyn VectorStorage>) containing a storage backed by SQLite
§Example
ⓘ
let backend = SqliteGraphBackend::in_memory().unwrap();
let storage = backend.create_hnsw_storage("my_index").unwrap();Sourcepub fn entity_ids(&self) -> Result<Vec<i64>, SqliteGraphError>
pub fn entity_ids(&self) -> Result<Vec<i64>, SqliteGraphError>
Get all entity IDs from the graph.
Trait Implementations§
Source§impl GraphBackend for SqliteGraphBackend
impl GraphBackend for SqliteGraphBackend
fn insert_node(&self, node: NodeSpec) -> Result<i64, SqliteGraphError>
fn get_node( &self, snapshot_id: SnapshotId, id: i64, ) -> Result<GraphEntity, SqliteGraphError>
fn insert_edge(&self, edge: EdgeSpec) -> Result<i64, SqliteGraphError>
Source§fn delete_entity(&self, id: i64) -> Result<(), SqliteGraphError>
fn delete_entity(&self, id: i64) -> Result<(), SqliteGraphError>
Delete an entity (node) from the graph by ID Read more
Source§fn update_node(
&self,
node_id: i64,
node: NodeSpec,
) -> Result<i64, SqliteGraphError>
fn update_node( &self, node_id: i64, node: NodeSpec, ) -> Result<i64, SqliteGraphError>
Update an existing node in place without allocating a new node ID Read more
Source§fn entity_ids(&self) -> Result<Vec<i64>, SqliteGraphError>
fn entity_ids(&self) -> Result<Vec<i64>, SqliteGraphError>
Get all entity IDs from the graph Read more
fn neighbors( &self, snapshot_id: SnapshotId, node: i64, query: NeighborQuery, ) -> Result<Vec<i64>, SqliteGraphError>
fn bfs( &self, snapshot_id: SnapshotId, start: i64, depth: u32, ) -> Result<Vec<i64>, SqliteGraphError>
fn shortest_path( &self, snapshot_id: SnapshotId, start: i64, end: i64, ) -> Result<Option<Vec<i64>>, SqliteGraphError>
fn node_degree( &self, snapshot_id: SnapshotId, node: i64, ) -> Result<(usize, usize), SqliteGraphError>
fn k_hop( &self, snapshot_id: SnapshotId, start: i64, depth: u32, direction: BackendDirection, ) -> Result<Vec<i64>, SqliteGraphError>
fn k_hop_filtered( &self, snapshot_id: SnapshotId, start: i64, depth: u32, direction: BackendDirection, allowed_edge_types: &[&str], ) -> Result<Vec<i64>, SqliteGraphError>
fn chain_query( &self, snapshot_id: SnapshotId, start: i64, chain: &[ChainStep], ) -> Result<Vec<i64>, SqliteGraphError>
fn pattern_search( &self, snapshot_id: SnapshotId, start: i64, pattern: &PatternQuery, ) -> Result<Vec<PatternMatch>, SqliteGraphError>
Source§fn checkpoint(&self) -> Result<(), SqliteGraphError>
fn checkpoint(&self) -> Result<(), SqliteGraphError>
Trigger WAL checkpoint for backends that support write-ahead logging Read more
Source§fn flush(&self) -> Result<(), SqliteGraphError>
fn flush(&self) -> Result<(), SqliteGraphError>
Force immediate flush of WAL buffer to disk Read more
Source§fn backup(&self, backup_dir: &Path) -> Result<BackupResult, SqliteGraphError>
fn backup(&self, backup_dir: &Path) -> Result<BackupResult, SqliteGraphError>
Create a backup of the database Read more
Source§fn snapshot_export(
&self,
export_dir: &Path,
) -> Result<SnapshotMetadata, SqliteGraphError>
fn snapshot_export( &self, export_dir: &Path, ) -> Result<SnapshotMetadata, SqliteGraphError>
Export database snapshot to the specified directory Read more
Source§fn snapshot_import(
&self,
import_dir: &Path,
) -> Result<ImportMetadata, SqliteGraphError>
fn snapshot_import( &self, import_dir: &Path, ) -> Result<ImportMetadata, SqliteGraphError>
Import database snapshot from the specified directory Read more
Source§fn subscribe(
&self,
filter: SubscriptionFilter,
) -> Result<(u64, Receiver<PubSubEvent>), SqliteGraphError>
fn subscribe( &self, filter: SubscriptionFilter, ) -> Result<(u64, Receiver<PubSubEvent>), SqliteGraphError>
Subscribe to graph change events Read more
Source§fn unsubscribe(&self, subscriber_id: u64) -> Result<bool, SqliteGraphError>
fn unsubscribe(&self, subscriber_id: u64) -> Result<bool, SqliteGraphError>
Unsubscribe from events Read more
Source§fn query_nodes_by_kind(
&self,
_snapshot_id: SnapshotId,
kind: &str,
) -> Result<Vec<i64>, SqliteGraphError>
fn query_nodes_by_kind( &self, _snapshot_id: SnapshotId, kind: &str, ) -> Result<Vec<i64>, SqliteGraphError>
Query all nodes with a given kind Read more
Source§fn query_nodes_by_name_pattern(
&self,
_snapshot_id: SnapshotId,
pattern: &str,
) -> Result<Vec<i64>, SqliteGraphError>
fn query_nodes_by_name_pattern( &self, _snapshot_id: SnapshotId, pattern: &str, ) -> Result<Vec<i64>, SqliteGraphError>
Query nodes by name pattern using glob matching Read more
Source§fn all_entity_ids(&self) -> Result<Vec<i64>, SqliteGraphError>
fn all_entity_ids(&self) -> Result<Vec<i64>, SqliteGraphError>
Alias for
entity_ids() for backward compatibility with algorithms Read moreSource§fn fetch_outgoing(&self, node: i64) -> Result<Vec<i64>, SqliteGraphError>
fn fetch_outgoing(&self, node: i64) -> Result<Vec<i64>, SqliteGraphError>
Get outgoing neighbors for a node (convenience method) Read more
Source§fn fetch_incoming(&self, node: i64) -> Result<Vec<i64>, SqliteGraphError>
fn fetch_incoming(&self, node: i64) -> Result<Vec<i64>, SqliteGraphError>
Get incoming neighbors for a node (convenience method) Read more
Auto Trait Implementations§
impl !Freeze for SqliteGraphBackend
impl !RefUnwindSafe for SqliteGraphBackend
impl !Send for SqliteGraphBackend
impl !Sync for SqliteGraphBackend
impl Unpin for SqliteGraphBackend
impl UnsafeUnpin for SqliteGraphBackend
impl !UnwindSafe for SqliteGraphBackend
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
Mutably borrows from an owned value. Read more
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>
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 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>
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