This module encapsulates the partitioned table metadata.
Different properties must be stored somewhere soshards
can work properly. Shards perform logic on top of ETS tables,
for example, compute the partition based on the Key
where
the action will be applied. To do so, it needs the number of
partitions, the function to select the partition, and also the
partition identifier to perform the ETS action.
keyslot_fun() = fun((Key::term(), Range::pos_integer()) -> non_neg_integer())
Defines spec function to pick or compute the partition and/or node.
The function returns a value for Key
within the range 0..Range-1
.
meta_map() = #{tab_pid => pid(), keypos => pos_integer(), partitions => pos_integer(), keyslot_fun => keyslot_fun(), parallel => boolean(), parallel_timeout => timeout(), ets_opts => [term()]}
Defines the map representation for the metadata data type.
partition_pids() = [{non_neg_integer(), pid()}]
Defines a tuple-list with the partition number and the partition owner PID.
partition_tids() = [{non_neg_integer(), ets:tid()}]
Defines a tuple-list with the partition number and the ETS TID.
t() = #meta{}
Defines shards
metadata.
ets_opts/1 | |
from_map/1 |
Builds a new meta from the given Map . |
get/1 | Returns the metadata. |
get_partition_pids/1 | Returns a list with the partition PIDs. |
get_partition_tids/1 | Returns a list with the partition TIDs. |
init/2 | Initializes the metadata ETS table. |
is_metadata/1 |
Returns true if Meta is a metadata data type, otherwise,
false is returned. |
keypos/1 | |
keyslot_fun/1 | |
lookup/2 |
Returns the value associated to the key Key in the metadata table Tab . |
new/0 | Returns a metadata data type with the default values. |
parallel/1 | |
parallel_timeout/1 | |
partitions/1 | |
put/3 |
Stores the value Val under the given key Key into the metadata table
Tab . |
rename/2 | Renames the metadata ETS table. |
tab_pid/1 | |
to_map/1 |
Converts the given Meta into a map . |
ets_opts(Meta::t() | shards:tab()) -> [term()]
from_map(Map::#{atom() => term()}) -> t()
Builds a new meta
from the given Map
.
get(Tab::shards:tab()) -> t() | no_return()
Returns the metadata.
get_partition_pids(Tab::shards:tab()) -> partition_pids()
Returns a list with the partition PIDs.
get_partition_tids(Tab::shards:tab()) -> partition_tids()
Returns a list with the partition TIDs.
Initializes the metadata ETS table.
is_metadata(Meta::term()) -> boolean()
Returns true
if Meta
is a metadata data type, otherwise,
false
is returned.
keypos(Meta::t() | shards:tab()) -> pos_integer()
keyslot_fun(Meta::t() | shards:tab()) -> keyslot_fun()
Returns the value associated to the key Key
in the metadata table Tab
.
If Key
is not found, the error {unknown_table, Tab}
is raised.
new() -> t()
Returns a metadata data type with the default values.
parallel(Meta::t() | shards:tab()) -> boolean()
parallel_timeout(Meta::t() | shards:tab()) -> timeout()
partitions(Meta::t() | shards:tab()) -> pos_integer()
Stores the value Val
under the given key Key
into the metadata table
Tab
.
Renames the metadata ETS table.
tab_pid(Meta::t() | shards:tab()) -> pid()
to_map(Meta::t()) -> meta_map()
Converts the given Meta
into a map
.
Generated by EDoc