Anoma.Tables (Anoma v0.34.0)

Summary

Types

A table is typed by a tuple where the first element is the table name, and the second one is a list of keys (i.e., columns).

a list of table specs

Functions

I clear out the given table.

I duplicate a given table's content to a new table. If the new table does not exist, it is created.

I initialize the mnesia storage for this entire vm.

I initialize the tables for the client. There is only one client in the virtual machine. I do this by creating all tables in the mnesia storage.

I initialize the tables for a given node id. I do this by creating all tables in the mnesia storage.

Given an atom as table name, I create a node-specific name based on that.

I reset the tables for the client. Resetting means creating them if they dont exist, and clearing them if they do.

I return the table name for the given node its blocks.

I return the name of the client's id table.

I return the name of the client's update table.

I return the name of the client's values table.

I return the table name for the given node its event table.

Check if the given table name exists.

I return the table name for the intents table.

I return the table name for the given node its updates.

I return the table name for the given node its values.

Check if a given list of tables exists.

Types

table_spec()

@type table_spec() :: {atom(), [atom()]}

A table is typed by a tuple where the first element is the table name, and the second one is a list of keys (i.e., columns).

table_specs()

@type table_specs() :: [table_spec()]

a list of table specs

Functions

clear_table(table_name)

@spec clear_table(atom()) :: :ok | {:error, :failed_to_clear_table}

I clear out the given table.

copy_table_rows(source_table, target_table, cont \\ nil)

@spec copy_table_rows(any(), any(), any()) :: :ok

create_local_schema()

@spec create_local_schema() :: :ok | {:error, :failed_to_create_schema, any()}

create_table(name, fields)

@spec create_table(atom(), [atom()]) ::
  {:ok, :exists | :created} | {:error, :failed_to_create_table, any()}

create_tables(table_list)

@spec create_tables([{atom(), [atom()]}]) ::
  {:ok, {[atom()], [atom()]}}
  | {:error, :failed_to_create_table, atom(), [atom()], any()}

duplicate_table(source_table, target_table)

@spec duplicate_table(atom(), atom()) ::
  {:ok, :table_copied} | {:error, :copy_failed, any()}

I duplicate a given table's content to a new table. If the new table does not exist, it is created.

has_data?(node_id)

@spec has_data?(String.t()) ::
  {:ok, :exists}
  | {:error, :partial_exist | :none_exist | :failed_to_check_tables}

initialize_storage()

@spec initialize_storage() ::
  :ok
  | {:error, :failed_to_initialize_storage}
  | {:error, :failed_to_create_tables}

I initialize the mnesia storage for this entire vm.

initialize_tables_for_client()

@spec initialize_tables_for_client() ::
  {:ok, :existing | :created} | {:error, :failed_to_initialize_tables}

I initialize the tables for the client. There is only one client in the virtual machine. I do this by creating all tables in the mnesia storage.

I return information whether these tables did not exist, were created, or when I failed to create them.

initialize_tables_for_node(node_id)

@spec initialize_tables_for_node(String.t()) ::
  {:ok, :existing | :created} | {:error, :failed_to_initialize_tables}

I initialize the tables for a given node id. I do this by creating all tables in the mnesia storage.

I return information whether these tables did not exist, were created, or when I failed to create them.

node_table_name(node_id, name)

@spec node_table_name(String.t(), atom()) :: atom()

Given an atom as table name, I create a node-specific name based on that.

reset_tables_for_client()

@spec reset_tables_for_client() :: :ok

I reset the tables for the client. Resetting means creating them if they dont exist, and clearing them if they do.

table_blocks(node_id)

@spec table_blocks(String.t()) :: atom()

I return the table name for the given node its blocks.

table_client_ids()

@spec table_client_ids() :: atom()

I return the name of the client's id table.

table_client_updates()

@spec table_client_updates() :: atom()

I return the name of the client's update table.

table_client_values()

@spec table_client_values() :: atom()

I return the name of the client's values table.

table_events(node_id)

@spec table_events(String.t()) :: atom()

I return the table name for the given node its event table.

table_exists?(table)

@spec table_exists?(atom()) :: boolean()

Check if the given table name exists.

Run inside transaction.

table_intents(node_id)

@spec table_intents(String.t()) :: atom()

I return the table name for the intents table.

table_updates(node_id)

@spec table_updates(String.t()) :: atom()

I return the table name for the given node its updates.

table_values(node_id)

@spec table_values(String.t()) :: atom()

I return the table name for the given node its values.

tables_exist?(table_names)

@spec tables_exist?([atom()]) ::
  {:ok, :exists}
  | {:error, :partial_exist | :none_exist | :failed_to_check_tables}

Check if a given list of tables exists.

This function takes a list of tables to avoid waiting for tables multiple times.