Skip to main content

GraphStore

Struct GraphStore 

Source
pub struct GraphStore(/* private fields */);

Implementations§

Source§

impl GraphStore

Source

pub fn apply_batch( &self, batch: &GraphBatch, ) -> Result<WriteReceipt<GraphBatchResult>>

Source

pub fn get( &self, kind: RecordKind, id: i64, filter: &ReadFilter, ) -> Result<Value>

Source

pub fn list(&self, kind: RecordKind, page: &PageRequest) -> Result<Page<Value>>

Source

pub fn set_predicate_equivalents( &self, namespace: &str, groups: &[Vec<String>], ) -> Result<WriteReceipt<usize>>

登记一批谓词等价组到某个知识领域:groups 是一组组互等同义词, 组内第一个词当规范词(组内代表),同组词据此归并。重复登记同一个词会改写它的归属。 表由上游提供、库不内置领域数据;只影响查询期扩散,不改谓词的落盘写法。

Source

pub fn predicate_equivalents(&self, namespace: &str) -> Result<Vec<Vec<String>>>

列出某个知识领域已登记的等价组;每个组是一组互等同义词。没登记过就返回空。

Source

pub fn expand_query( &self, namespace: &str, text_value: &str, ) -> Result<Vec<String>>

扩散:找出 text 里出现了哪些已登记谓词,返回这些谓词所在等价组的全部同义词。 命中判定是「登记词作为子串出现在查询里」。 返回的是可直接追加进检索的补充词元;没有命中返回空。

Source

pub fn resolve( &self, name: &str, filter: &ReadFilter, limit: usize, ) -> Result<Vec<Entity>>

Source

pub fn neighbors( &self, id: i64, filter: &ReadFilter, limit: usize, ) -> Result<Neighborhood>

Source

pub fn events_for_entity( &self, id: i64, filter: &ReadFilter, limit: usize, ) -> Result<Vec<Event>>

Source

pub fn delete( &self, kind: RecordKind, id: i64, filter: &ReadFilter, ) -> Result<WriteReceipt<bool>>

Source

pub fn delete_by_filter( &self, filter: &ReadFilter, ) -> Result<WriteReceipt<usize>>

删除过滤条件命中的全部图记录(实体、关系、事件),返回删除条数。

顺序固定为关系 → 事件 → 实体:关系与事件的参与行都以 RESTRICT 引用实体, 先删边再删点,级联顺序由这里保证,调用方不必知道外键怎么连。 若某个待删实体仍被过滤条件之外的关系或事件引用,删除会被外键拦下并返回 Conflict, 整个事务回滚,不做部分删除。

Source§

impl GraphStore

Source

pub fn build_graph(&self, filter: &ReadFilter) -> Result<GraphView>

filter 范围(namespace/scope/tag)内的实体铺成节点、关系连成边,建一张有向图。

节点来自 entity 记录(含没有关系的孤立实体,「谁没连进主图」才看得出来), 边来自 relation 记录。范围外的记录不进图——多命名空间不会串。

Source

pub fn strongly_connected(&self, filter: &ReadFilter) -> Result<Vec<Vec<i64>>>

强连通分量(有向,tarjan_scc):互相可达的实体环,如「互为对手/同伙」的闭环。 只返回大小 > 1 的分量,孤点自环被滤掉。

Source

pub fn ego( &self, root: i64, depth: usize, filter: &ReadFilter, limit: usize, ) -> Result<Vec<Entity>>

root 出发 depth 跳内的实体(带 name / aliases / attributes)。

Source

pub fn path( &self, from: i64, to: i64, filter: &ReadFilter, ) -> Result<Option<Vec<Entity>>>

fromto 桥接路径上的实体(含两端)。不连通返回 None。

Source

pub fn set_predicate_rule( &self, predicate: &str, inverse: Option<&str>, symmetric: bool, ) -> Result<WriteReceipt<()>>

登记谓词元规则:symmetric 声明对称谓词(反向即自身),inverse 声明逆谓词 (反向补一条对偶边,如 父亲 的逆是 子女)。二者互斥,规则只影响建图时的内存补边。

Trait Implementations§

Source§

impl Clone for GraphStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

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

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Fruit for T
where T: Send + Downcast,

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

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.