pub struct KnowledgeGraph { /* private fields */ }Implementations§
Source§impl KnowledgeGraph
impl KnowledgeGraph
pub fn new(path: &Path) -> Result<Self>
pub const fn interner(&self) -> &StringInterner
Sourcepub fn get_entity(&self, name: &str) -> Option<Entity>
pub fn get_entity(&self, name: &str) -> Option<Entity>
Return a single entity by exact name match.
Sourcepub fn graph_stats(&self) -> Value
pub fn graph_stats(&self) -> Value
Return aggregate statistics about the graph.
Sourcepub fn search_relations(
&self,
from: Option<&str>,
to: Option<&str>,
rtype: Option<&str>,
) -> Vec<Relation>
pub fn search_relations( &self, from: Option<&str>, to: Option<&str>, rtype: Option<&str>, ) -> Vec<Relation>
Search relations by optional filters: from, to, relationType.
Any filter that is absent matches everything. A filter value that does
not exist in the graph returns empty results.
Sourcepub fn find_path(&self, from: &str, to: &str) -> Result<Vec<String>>
pub fn find_path(&self, from: &str, to: &str) -> Result<Vec<String>>
BFS shortest-path between two entity names. Returns the sequence of entity names along the path (inclusive of both endpoints).
Sourcepub fn compact(&mut self) -> Result<()>
pub fn compact(&mut self) -> Result<()>
Rewrite the binary log from the current in-memory state. After compaction the log contains only the minimal set of records needed to reconstruct the graph (all creates, no deletes). Crash-safe: writes to a temp file, then atomically renames (C3).
pub fn create_entities(&mut self, entities: &[Entity]) -> Result<Vec<Entity>>
pub fn create_relations( &mut self, relations: &[Relation], ) -> Result<Vec<Relation>>
pub fn add_observations( &mut self, entity_name: &str, contents: &[String], ) -> Result<Vec<String>>
pub fn delete_entities(&mut self, entity_names: &[String]) -> Result<()>
pub fn delete_observations( &mut self, entity_name: &str, observations: &[String], ) -> Result<()>
pub fn delete_relations(&mut self, relations: &[Relation]) -> Result<()>
pub fn read_graph(&self) -> KnowledgeGraphOut
pub fn search_nodes(&self, query: &str) -> KnowledgeGraphOut
pub fn open_nodes(&self, names: &[String]) -> KnowledgeGraphOut
Sourcepub fn flush_and_sync(&mut self) -> Result<()>
pub fn flush_and_sync(&mut self) -> Result<()>
Flush and fsync the log to stable storage.
Auto Trait Implementations§
impl Freeze for KnowledgeGraph
impl RefUnwindSafe for KnowledgeGraph
impl Send for KnowledgeGraph
impl Sync for KnowledgeGraph
impl Unpin for KnowledgeGraph
impl UnsafeUnpin for KnowledgeGraph
impl UnwindSafe for KnowledgeGraph
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