MnemosyneZvex.Sidecar (mnemosyne_zvex v0.1.0)

Copy Markdown

DETS-backed store for mutable per-node metadata and typed links between nodes. Lookups by node_type go straight to Zvex via a filtered query — no type-index is maintained here.

Records:

{{:links, node_id}, %{edge_type => MapSet.t(node_id)}}
{{:meta,  node_id}, %Mnemosyne.NodeMetadata{}}

Summary

Functions

Closes the underlying DETS table.

Deletes metadata for the given ids.

Fetches the link map for a node id, defaulting to empty when absent.

Looks up metadata for many node ids; missing ids are absent from the map.

Opens a DETS table at the given path, creating it if needed.

Adds a bidirectional link between two nodes.

Adds many bidirectional links in one pass (no sync).

Upserts a batch of metadata entries.

Removes the given ids from all sidecar tables and scrubs back-references from every surviving node's link set. Mirrors Mnemosyne.GraphBackends.Persistence.DETS.strip_dead_refs/2.

Flushes pending writes to disk.

Types

t()

@type t() :: %MnemosyneZvex.Sidecar{path: charlist(), ref: :dets.tab_name()}

Functions

close(sidecar)

@spec close(t()) :: :ok | {:error, {:dets_error, term()}}

Closes the underlying DETS table.

delete_metadata(sidecar, ids)

@spec delete_metadata(t(), [String.t()]) :: :ok | {:error, {:dets_error, term()}}

Deletes metadata for the given ids.

get_links(sidecar, id)

@spec get_links(t(), String.t()) :: %{
  required(Mnemosyne.Graph.Edge.edge_type()) => MapSet.t()
}

Fetches the link map for a node id, defaulting to empty when absent.

get_metadata_many(sidecar, ids)

@spec get_metadata_many(t(), [String.t()]) :: %{required(String.t()) => struct()}

Looks up metadata for many node ids; missing ids are absent from the map.

open(path)

@spec open(Path.t()) :: {:ok, t()} | {:error, {:dets_error, term()}}

Opens a DETS table at the given path, creating it if needed.

put_link(side, id_a, id_b, type)

@spec put_link(t(), String.t(), String.t(), Mnemosyne.Graph.Edge.edge_type()) ::
  :ok | {:error, {:dets_error, term()}}

Adds a bidirectional link between two nodes.

put_metadata_many(sidecar, entries)

@spec put_metadata_many(t(), %{required(String.t()) => struct()}) ::
  :ok | {:error, {:dets_error, term()}}

Upserts a batch of metadata entries.

remove_ids(sidecar, ids)

@spec remove_ids(t(), [String.t()]) :: :ok | {:error, {:dets_error, term()}}

Removes the given ids from all sidecar tables and scrubs back-references from every surviving node's link set. Mirrors Mnemosyne.GraphBackends.Persistence.DETS.strip_dead_refs/2.

sync(sidecar)

@spec sync(t()) :: :ok | {:error, {:dets_error, term()}}

Flushes pending writes to disk.