Class InMemoryGraphStore

java.lang.Object
com.tnsai.intelligence.rag.graph.InMemoryGraphStore
All Implemented Interfaces:
GraphStore

public final class InMemoryGraphStore extends Object implements GraphStore
Zero-config in-process GraphStore for development and FILE ingest.

Nodes are keyed by a normalized identity so Auth Service and auth service collapse to one entity. Callers add nodes and edges explicitly; FileGraphIngestor is the FILE-corpus construction path.

Since:
0.14.0
  • Constructor Details

    • InMemoryGraphStore

      public InMemoryGraphStore()
  • Method Details

    • putNode

      public void putNode(GraphStore.Node node)
      Inserts or replaces a node under its identity key.
      Parameters:
      node - node to retain
    • putEdge

      public void putEdge(GraphStore.Edge edge, GraphStore.Node destination)
      Inserts a directed edge. The destination must already be stored.
      Parameters:
      edge - directed edge
      destination - destination node (used if not already stored)
    • nodeCount

      public int nodeCount()
      Number of stored nodes.
    • nodes

      public List<GraphStore.Node> nodes()
      Snapshot of stored nodes.
    • edges

      public List<GraphStore.Edge> edges()
      Snapshot of stored edges.
    • findSeeds

      public List<GraphStore.Seed> findSeeds(String query, int limit)
      Description copied from interface: GraphStore
      Finds graph nodes that can seed traversal for a query.
      Specified by:
      findSeeds in interface GraphStore
      Parameters:
      query - query text, never null
      limit - maximum number of seeds requested
      Returns:
      seeds, never null
    • neighbors

      public List<GraphStore.Neighbor> neighbors(String nodeId)
      Description copied from interface: GraphStore
      Returns the outgoing edges and destination nodes for a node.
      Specified by:
      neighbors in interface GraphStore
      Parameters:
      nodeId - expanded node identifier
      Returns:
      neighbors, never null
    • identityKey

      public static String identityKey(String value)
      Collapses surface forms so identity is not exact-string-only.
      Parameters:
      value - raw entity label
      Returns:
      lowercase alphanumerics with single spaces