pub struct MemoryGraph {
pub term_index: Option<TermIndex>,
pub doc_lengths: Option<DocLengths>,
/* private fields */
}Expand description
The core in-memory graph structure holding cognitive events and their relationships.
Fields§
§term_index: Option<TermIndex>BM25 inverted index (optional, may not be present in old files).
doc_lengths: Option<DocLengths>Document lengths for BM25 normalization (optional).
Implementations§
Source§impl MemoryGraph
impl MemoryGraph
Sourcepub fn from_parts(
nodes: Vec<CognitiveEvent>,
edges: Vec<Edge>,
dimension: usize,
) -> AmemResult<Self>
pub fn from_parts( nodes: Vec<CognitiveEvent>, edges: Vec<Edge>, dimension: usize, ) -> AmemResult<Self>
Create from pre-existing data (used by reader).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges.
Sourcepub fn get_node(&self, id: u64) -> Option<&CognitiveEvent>
pub fn get_node(&self, id: u64) -> Option<&CognitiveEvent>
Get a node by ID (immutable).
Sourcepub fn get_node_mut(&mut self, id: u64) -> Option<&mut CognitiveEvent>
pub fn get_node_mut(&mut self, id: u64) -> Option<&mut CognitiveEvent>
Get a node by ID (mutable).
Sourcepub fn ensure_adjacency(&mut self)
pub fn ensure_adjacency(&mut self)
Ensure adjacency indexes are up to date. No-op in the current implementation (adjacency is always up to date).
Sourcepub fn edges_from(&self, source_id: u64) -> &[Edge]
pub fn edges_from(&self, source_id: u64) -> &[Edge]
Get all edges from a source node.
Sourcepub fn nodes(&self) -> &[CognitiveEvent]
pub fn nodes(&self) -> &[CognitiveEvent]
Get all nodes (immutable slice).
Sourcepub fn add_node(&mut self, event: CognitiveEvent) -> AmemResult<u64>
pub fn add_node(&mut self, event: CognitiveEvent) -> AmemResult<u64>
Add a node, returns the assigned ID.
Sourcepub fn add_edge(&mut self, edge: Edge) -> AmemResult<()>
pub fn add_edge(&mut self, edge: Edge) -> AmemResult<()>
Add an edge between two existing nodes.
Sourcepub fn remove_node(&mut self, id: u64) -> AmemResult<CognitiveEvent>
pub fn remove_node(&mut self, id: u64) -> AmemResult<CognitiveEvent>
Remove a node and all its edges.
Sourcepub fn remove_edge(
&mut self,
source_id: u64,
target_id: u64,
edge_type: EdgeType,
) -> AmemResult<()>
pub fn remove_edge( &mut self, source_id: u64, target_id: u64, edge_type: EdgeType, ) -> AmemResult<()>
Remove a specific edge.
Sourcepub fn type_index(&self) -> &TypeIndex
pub fn type_index(&self) -> &TypeIndex
Get the type index.
Sourcepub fn temporal_index(&self) -> &TemporalIndex
pub fn temporal_index(&self) -> &TemporalIndex
Get the temporal index.
Sourcepub fn session_index(&self) -> &SessionIndex
pub fn session_index(&self) -> &SessionIndex
Get the session index.
Sourcepub fn cluster_map(&self) -> &ClusterMap
pub fn cluster_map(&self) -> &ClusterMap
Get the cluster map.
Sourcepub fn cluster_map_mut(&mut self) -> &mut ClusterMap
pub fn cluster_map_mut(&mut self) -> &mut ClusterMap
Get a mutable reference to the cluster map.
Sourcepub fn term_index(&self) -> Option<&TermIndex>
pub fn term_index(&self) -> Option<&TermIndex>
Get the term index (for BM25 search). None if not built.
Sourcepub fn doc_lengths(&self) -> Option<&DocLengths>
pub fn doc_lengths(&self) -> Option<&DocLengths>
Get the doc lengths (for BM25 normalization). None if not built.
Sourcepub fn set_term_index(&mut self, index: TermIndex)
pub fn set_term_index(&mut self, index: TermIndex)
Set the term index.
Sourcepub fn set_doc_lengths(&mut self, lengths: DocLengths)
pub fn set_doc_lengths(&mut self, lengths: DocLengths)
Set the doc lengths.