pub struct SemanticGraph { /* private fields */ }Expand description
The unified knowledge graph: every entity and relationship produced by
any kopitiam_ontology-speaking provider, merged into one structure.
This type is storage-agnostic on purpose. It holds no file handles and
makes no assumptions about where it is persisted — it derives
Serialize/Deserialize so kopitiam-index (or anything else) can snapshot
it without kopitiam-knowledge depending on a storage engine.
Implementations§
Source§impl SemanticGraph
impl SemanticGraph
pub fn new() -> Self
Sourcepub fn insert_entity(&mut self, entity: Entity) -> EntityId
pub fn insert_entity(&mut self, entity: Entity) -> EntityId
Inserts one entity, keyed by its own EntityId. Re-inserting an
id already present overwrites the previous entity.
Sourcepub fn insert_relationship(
&mut self,
relationship: Relationship,
) -> RelationshipId
pub fn insert_relationship( &mut self, relationship: Relationship, ) -> RelationshipId
Inserts one relationship and indexes it for traversal in both directions.
Sourcepub fn extend(
&mut self,
entities: impl IntoIterator<Item = Entity>,
relationships: impl IntoIterator<Item = Relationship>,
)
pub fn extend( &mut self, entities: impl IntoIterator<Item = Entity>, relationships: impl IntoIterator<Item = Relationship>, )
Merges a batch of facts from a provider run in one call — the usual
entry point after calling a kopitiam_semantic::KnowledgeProvider.
pub fn entity(&self, id: EntityId) -> Option<&Entity>
pub fn relationship(&self, id: RelationshipId) -> Option<&Relationship>
pub fn entity_count(&self) -> usize
pub fn relationship_count(&self) -> usize
pub fn entities(&self) -> impl Iterator<Item = &Entity>
pub fn entities_of_kind( &self, kind: EntityKind, ) -> impl Iterator<Item = &Entity>
Sourcepub fn relationships_from(
&self,
id: EntityId,
) -> impl Iterator<Item = &Relationship>
pub fn relationships_from( &self, id: EntityId, ) -> impl Iterator<Item = &Relationship>
Relationships whose from is id.
Sourcepub fn relationships_to(
&self,
id: EntityId,
) -> impl Iterator<Item = &Relationship>
pub fn relationships_to( &self, id: EntityId, ) -> impl Iterator<Item = &Relationship>
Relationships whose to is id.
Trait Implementations§
Source§impl Clone for SemanticGraph
impl Clone for SemanticGraph
Source§fn clone(&self) -> SemanticGraph
fn clone(&self) -> SemanticGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more