View Source erlfdb_directory (erlfdb v1.2.0)
Summary
Types
A directory is a named subdirectory within a root or partition. Its keys are
allocated by the root's HCA allocator and stored under a content prefix derived
from that allocated node name. The layer field is an arbitrary binary that
applications use to tag what kind of data lives in the directory (e.g.
<<"tenant">>). get_subspace/1 returns a usable subspace for reading and
writing key-value data.
A partition is a directory that acts as its own independent root, with its own node-prefix space and HCA allocator. Key allocation for everything underneath a partition is managed by the partition itself rather than by any ancestor root, giving it a completely separate key namespace.
A directory layer node — either a partition() (root) or a directory() (leaf).
Functions
Lists the immediate subdirectories of Node.
Equivalent to list(TxObj, Node, {}).
Lists the immediate subdirectories of the directory at Path under Node.
Types
-type directory() :: #{id := binary(), name := binary(), root := t(), path := [path_item()], layer := binary(), get_id := fun((t()) -> binary()), get_name := fun((t()) -> binary()), get_root := fun((t()) -> t()), get_root_for_path := fun((t(), path()) -> t()), get_partition := fun((t()) -> t()), get_node_prefix := fun((t()) -> binary()), get_path := fun((t()) -> [path_item()]), get_layer := fun((t()) -> binary()), get_subspace := fun((t()) -> term())}.
A directory is a named subdirectory within a root or partition. Its keys are
allocated by the root's HCA allocator and stored under a content prefix derived
from that allocated node name. The layer field is an arbitrary binary that
applications use to tag what kind of data lives in the directory (e.g.
<<"tenant">>). get_subspace/1 returns a usable subspace for reading and
writing key-value data.
-type open_option() :: {layer, binary()}.
-type partition() :: #{id := binary(), node_prefix := binary(), content_prefix := binary(), allocator := term(), allow_manual_names := boolean(), name => binary(), root => t(), path => [path_item()], is_partition => true, is_absolute_root => true, get_id := fun((t()) -> binary()), get_name => fun((t()) -> binary()), get_root := fun((t()) -> t()), get_root_for_path := fun((t(), path()) -> t()), get_partition := fun((t()) -> t()), get_node_prefix := fun((t()) -> binary()), get_path := fun((t()) -> [path_item()]), get_layer := fun((t()) -> binary()), get_subspace := fun((t()) -> term())}.
A partition is a directory that acts as its own independent root, with its own node-prefix space and HCA allocator. Key allocation for everything underneath a partition is managed by the partition itself rather than by any ancestor root, giving it a completely separate key namespace.
Because a partition is a root and not a leaf, get_subspace/1 raises an error
on a partition — data is stored in ordinary directories beneath it.
The absolute root (returned by root/0) is also represented as a partition.
A directory layer node — either a partition() (root) or a directory() (leaf).
Functions
-spec create(erlfdb:tx_object(), t(), path()) -> t().
-spec create(erlfdb:tx_object(), t(), path(), [create_option()]) -> t().
-spec create_or_open(erlfdb:tx_object(), t(), path()) -> t().
-spec create_or_open(erlfdb:tx_object(), t(), path(), binary()) -> t().
-spec debug_nodes(erlfdb:tx_object(), t()) -> ok | nil.
-spec exists(erlfdb:tx_object(), t()) -> boolean().
-spec exists(erlfdb:tx_object(), t(), path()) -> boolean().
-spec list(erlfdb:tx_object(), t()) -> [{path_item(), t()}].
Lists the immediate subdirectories of Node.
Equivalent to list(TxObj, Node, {}).
-spec list(erlfdb:tx_object(), t(), path()) -> [{path_item(), t()}].
Lists the immediate subdirectories of the directory at Path under Node.
Returns [{Name, ChildNode}] where each Name is a path_item(). In
practice the directory layer always stores names as {utf8, Binary} tuples,
so pattern matching on the first element should use that form:
Listed = erlfdb_directory:list(Db, Root),
Names = [N || {{utf8, N}, _Node} <- Listed].Raises {erlfdb_directory, {list_error, missing_path, Path}} if Path does
not exist under Node.
-spec move(erlfdb:tx_object(), t(), path(), path()) -> t().
-spec move_to(erlfdb:tx_object(), t(), path()) -> t().
-spec open(erlfdb:tx_object(), t(), path()) -> t().
-spec open(erlfdb:tx_object(), t(), path(), [open_option()]) -> t().
-spec remove(erlfdb:tx_object(), t()) -> ok.
-spec remove(erlfdb:tx_object(), t(), path()) -> ok.
-spec remove_if_exists(erlfdb:tx_object(), t()) -> ok.
-spec remove_if_exists(erlfdb:tx_object(), t(), path()) -> ok.
-spec root() -> partition().
-spec root([root_option()]) -> partition().