Mnemosyne.GraphBackends.Persistence.DETS (mnemosyne v0.1.5)

Copy Markdown View Source

DETS-backed persistence for the InMemory graph backend.

Stores nodes as {node_id, node_struct} records. Secondary indexes are rebuilt on load via Graph.put_node/2.

Summary

Functions

Removes nodes by ID from DETS and strips any back-references to those IDs from every surviving node's link sets. Without the strip pass, surviving rows retain dangling references that re-materialize on reload.

Removes metadata entries by node ID from DETS.

Opens the DETS file at the configured path, returning a handle map.

Reads all records from DETS and rebuilds a Graph struct plus metadata map.

Persists changeset additions and links to DETS.

Persists metadata entries as {{:meta, id}, metadata} records.

Functions

delete(node_ids, arg2)

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

Removes nodes by ID from DETS and strips any back-references to those IDs from every surviving node's link sets. Without the strip pass, surviving rows retain dangling references that re-materialize on reload.

delete_metadata(node_ids, map)

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

Removes metadata entries by node ID from DETS.

init(opts)

@spec init(keyword()) :: {:ok, map()} | {:error, term()}

Opens the DETS file at the configured path, returning a handle map.

load(map)

@spec load(map()) :: {:ok, Mnemosyne.Graph.t(), map()} | {:error, term()}

Reads all records from DETS and rebuilds a Graph struct plus metadata map.

Node records are stored as {id, node} tuples, metadata records as {{:meta, id}, metadata} tuples. Both are separated during the fold.

save(changeset, map)

@spec save(Mnemosyne.Graph.Changeset.t(), map()) :: :ok | {:error, term()}

Persists changeset additions and links to DETS.

save_metadata(entries, map)

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

Persists metadata entries as {{:meta, id}, metadata} records.