Skip to main content

MemoryGraph

Struct MemoryGraph 

Source
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

Source

pub fn new(dimension: usize) -> Self

Create a new empty graph.

Source

pub fn from_parts( nodes: Vec<CognitiveEvent>, edges: Vec<Edge>, dimension: usize, ) -> AmemResult<Self>

Create from pre-existing data (used by reader).

Source

pub fn node_count(&self) -> usize

Number of nodes.

Source

pub fn edge_count(&self) -> usize

Number of edges.

Source

pub fn get_node(&self, id: u64) -> Option<&CognitiveEvent>

Get a node by ID (immutable).

Source

pub fn get_node_mut(&mut self, id: u64) -> Option<&mut CognitiveEvent>

Get a node by ID (mutable).

Source

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

Source

pub fn edges_from(&self, source_id: u64) -> &[Edge]

Get all edges from a source node.

Source

pub fn edges_to(&self, target_id: u64) -> Vec<&Edge>

Get all edges that point TO this node.

Source

pub fn nodes(&self) -> &[CognitiveEvent]

Get all nodes (immutable slice).

Source

pub fn edges(&self) -> &[Edge]

Get all edges (immutable slice).

Source

pub fn dimension(&self) -> usize

The feature vector dimension for this graph.

Source

pub fn add_node(&mut self, event: CognitiveEvent) -> AmemResult<u64>

Add a node, returns the assigned ID.

Source

pub fn add_edge(&mut self, edge: Edge) -> AmemResult<()>

Add an edge between two existing nodes.

Source

pub fn remove_node(&mut self, id: u64) -> AmemResult<CognitiveEvent>

Remove a node and all its edges.

Source

pub fn remove_edge( &mut self, source_id: u64, target_id: u64, edge_type: EdgeType, ) -> AmemResult<()>

Remove a specific edge.

Source

pub fn next_id(&self) -> u64

Get the next available node ID (for builder use).

Source

pub fn type_index(&self) -> &TypeIndex

Get the type index.

Source

pub fn temporal_index(&self) -> &TemporalIndex

Get the temporal index.

Source

pub fn session_index(&self) -> &SessionIndex

Get the session index.

Source

pub fn cluster_map(&self) -> &ClusterMap

Get the cluster map.

Source

pub fn cluster_map_mut(&mut self) -> &mut ClusterMap

Get a mutable reference to the cluster map.

Source

pub fn term_index(&self) -> Option<&TermIndex>

Get the term index (for BM25 search). None if not built.

Source

pub fn doc_lengths(&self) -> Option<&DocLengths>

Get the doc lengths (for BM25 normalization). None if not built.

Source

pub fn set_term_index(&mut self, index: TermIndex)

Set the term index.

Source

pub fn set_doc_lengths(&mut self, lengths: DocLengths)

Set the doc lengths.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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