Skip to main content

KnowledgeGraph

Struct KnowledgeGraph 

Source
pub struct KnowledgeGraph { /* private fields */ }

Implementations§

Source§

impl KnowledgeGraph

Source

pub fn new(path: &Path) -> Result<Self>

Source

pub const fn interner(&self) -> &StringInterner

Source

pub fn get_entity(&self, name: &str) -> Option<Entity>

Return a single entity by exact name match.

Source

pub fn graph_stats(&self) -> Value

Return aggregate statistics about the graph.

Source

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.

Source

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).

Source

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).

Source

pub fn create_entities(&mut self, entities: &[Entity]) -> Result<Vec<Entity>>

Source

pub fn create_relations( &mut self, relations: &[Relation], ) -> Result<Vec<Relation>>

Source

pub fn add_observations( &mut self, entity_name: &str, contents: &[String], ) -> Result<Vec<String>>

Source

pub fn delete_entities(&mut self, entity_names: &[String]) -> Result<()>

Source

pub fn delete_observations( &mut self, entity_name: &str, observations: &[String], ) -> Result<()>

Source

pub fn delete_relations(&mut self, relations: &[Relation]) -> Result<()>

Source

pub fn read_graph(&self) -> KnowledgeGraphOut

Source

pub fn search_nodes(&self, query: &str) -> KnowledgeGraphOut

Source

pub fn open_nodes(&self, names: &[String]) -> KnowledgeGraphOut

Source

pub fn flush_and_sync(&mut self) -> Result<()>

Flush and fsync the log to stable storage.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more