Spex.InstanceManager.InstanceStore (spex v0.1.0)

Copy Markdown View Source

Abstraction layer for instance storage using DETS.

Summary

Functions

Gets all instances.

Gets all instances for a specific specification.

Closes the DETS table.

Deletes an instance by hash.

Deletes instances matching the given filter function.

Checks if an instance exists for the given hash.

Gets an instance by hash.

Initializes the DETS table for storing instances.

Stores an instance with the given hash.

Traverses all instances with the given function.

Deletes all instances from the DETS table.

Types

instance_hash()

@type instance_hash() :: non_neg_integer()

Functions

all(dets_table)

@spec all(:dets.tab_name()) :: {:ok, list()} | {:error, Spex.Errors.DetsError.t()}

Gets all instances.

all(dets_table, specification)

@spec all(:dets.tab_name(), module()) ::
  {:ok, list()} | {:error, Spex.Errors.DetsError.t()}

Gets all instances for a specific specification.

close(dets_table)

@spec close(:dets.tab_name()) :: :ok | {:error, Spex.Errors.DetsError.t()}

Closes the DETS table.

delete(dets_table, instance_identifier)

Deletes an instance by hash.

delete_matching(dets_table, filter_fun)

@spec delete_matching(:dets.tab_name(), (Spex.InstanceManager.Instance.t() ->
                                     as_boolean(term()))) ::
  :ok | {:error, Spex.Errors.DetsError.t()}

Deletes instances matching the given filter function.

exists?(dets_table, instance_identifier)

Checks if an instance exists for the given hash.

get(dets_table, instance_identifier)

Gets an instance by hash.

init(dets_table, dets_dir)

@spec init(:dets.tab_name(), Path.t()) ::
  :ok | {:error, Spex.Errors.DetsError.t() | Spex.Errors.FileError.t()}

Initializes the DETS table for storing instances.

put(dets_table, instance)

Stores an instance with the given hash.

traverse(dets_table, fun)

@spec traverse(:dets.tab_name(), (Spex.InstanceManager.Instance.t() -> term())) ::
  :ok | {:error, Spex.Errors.DetsError.t()}

Traverses all instances with the given function.

truncate(dets_table)

@spec truncate(:dets.tab_name()) :: :ok | {:error, Spex.Errors.DetsError.t()}

Deletes all instances from the DETS table.