View Source shards (shards v1.1.1)
Partitioned/Sharded ETS tables.
Features
shards
implements the ETS API to keep compatibility and make the usage straightforward; exactly the same if you were usingets
.- Sharded or partitioned tables under-the-hood. This feature is managed entirely by
shards
and it is 100% transparent for the client. Provides a logical view of a single ETS table, but internally, it is composed byN
number ofpartitions
and each partition has associated an ETS table. - High performance and scalability.
shards
keeps the lock contention under control enabling ETS tables to scale out and support higher levels of concurrency without lock issues; specially write-locks, which most of the cases might cause significant performance degradation.
Partitioned Table
When a table is created with shards:new/2
, a new supervision tree is created to represent the partitioned table. There is a main supervisor shards_partition_sup
that create an ETS table to store the metadata and also starts the children which are the partitions to create. Each partition is owned by shards_partition
(it is a gen_server
) and it creates an ETS table for storing data mapped to that partition. The supervision tree looks like:
[shards_partition]--><ETS-Table>
/
[shards_partition_sup]--<-[shards_partition]--><ETS-Table>
| \
<Metadata-ETS-Table> [shards_partition]--><ETS-Table>
The returned value by shards:new/2
may be an atom if it is a named table or a reference otherwise, and in the second case the returned reference is the one of the metadata table, which is the main entry point and it is owned by the main supervisor. See shards:new/2
for more information.
Usage
> Tab = shards:new(tab, []).
#Ref<0.1541908042.2337144842.31535>
> shards:insert(Tab, [{a, 1}, {b, 2}, {c, 3}]).
true
> shards:lookup(Tab, a).
[{a,1}]
> shards:lookup(Tab, b).
[{b,2}]
> shards:lookup(Tab, c).
[{c,3}]
> shards:lookup_element(Tab, c, 2).
3
> shards:lookup(Tab, d).
[]
> shards:delete(Tab, c).
true
> shards:lookup(Tab, c).
[]
As you can see, the usage is exactly the same if you were using ets
, you can try the rest of the ETS API but with shards
module.
Important
Despiteshards
aims to keep 100% compatibility with current ETS API, the semantic for some of the functions may be a bit different due to the nature of sharding; it is not the same having all the entries in a single table than distributed across multiple ones. For example, for query-based functions like select
, match
, etc., the returned entries are the same but not necessary the same order than ets
. For first
, next
, and last
they behave the similar in the sense by means of them a partitioned table is traversed, so the final result is the same, but the order in which the entries are traversed may be different. Therefore, it is highly recommended to read the documentation of the functions.
Summary
Functions
ets:delete/1
.See also: ets:delete/1.
Equivalent to delete(Tab, Key, shards_meta:get(Tab)).
ets:delete/2
.See also: ets:delete/2.
ets:delete_all_objects/1
.See also: ets:delete_all_objects/1.
ets:delete_object/2
.See also: ets:delete_object/2.
Equivalent to file2tab(Filename, []).
shards:file2tab/2
. Moreover, it restores the supervision tree for the shards
corresponding to the given file, such as if they had been created using shards:new/2
.See also: ets:file2tab/2.
Equivalent to first(Tab, shards_meta:get(Tab)).
Equivalent to ets:first/1
.
Equivalent to foldl(Fun, Acc, Tab, shards_meta:get(Tab)).
Equivalent to ets:foldl/3
.
Equivalent to foldr(Fun, Acc, Tab, shards_meta:get(Tab)).
Equivalent to ets:foldr/3
.
Equivalent to get_meta(Tab, Key, undefined).
shards_meta:get/3
.Similar to ets:info/1' but extra information about the partitioned table is added.
Equivalent to ets:info/2
.
Equivalent to ets:insert/2
.
Equivalent to ets:insert_new/2
.
Equivalent to ets:is_compiled_ms(Term).
Equivalent to ets:last/1
.
Equivalent to lookup(Tab, Key, shards_meta:get(Tab)).
ets:lookup/2
.See also: ets:lookup/2.
ets:lookup_element/3
.See also: ets:lookup_element/3.
Equivalent to ets:match/1
.
Equivalent to match(Tab, Pattern, shards_meta:get(Tab)).
If 3rd argument is pos_integer()
this function behaves like ets:match/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:match/2
.
Equivalent to ets:match/3
.
ets:match_delete/2
.See also: ets:match_delete/2.
Equivalent to ets:match_object/1
.
If 3rd argument is pos_integer()
this function behaves like ets:match_object/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:match_object/2
.
Equivalent to ets:match_object/3
.
Equivalent to ets:match_spec_compile(MatchSpec).
Equivalent to member(Tab, Key, shards_meta:get(Tab)).
ets:member/2
.See also: ets:member/2.
This operation is equivalent to ets:new/2
, but when is called, instead of create a single ETS table, it creates a new supervision tree for the partitioned table.
Equivalent to ets:next/2
.
TabOrPid
.Equivalent to ets:next/2
.
shards_meta:put/3
.Equivalent to rename(Tab, Name, shards_meta:get(Tab)).
Equivalent to ets:rename/2
.
Equivalent to ets:select/1
.
If 3rd argument is pos_integer()
this function behaves like ets:select/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:select/2
.
Equivalent to ets:select/3
.
ets:select_count/2
.See also: ets:select_count/2.
ets:select_delete/2
.See also: ets:select_delete/2.
ets:select_replace/2
.See also: ets:select_replace/2.
Equivalent to ets:select_reverse/1
.
If 3rd argument is pos_integer()
this function behaves like ets:select_reverse/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:select_reverse/2
.
Equivalent to ets:select_reverse/3
.
Equivalent to setopts(Tab, Opts, shards_meta:get(Tab)).
Equivalent to ets:setopts/2
.
Equivalent to tab2file(Tab, Filename, []).
Equivalent to ets:tab2file/3
.
Equivalent to tab2list(Tab, shards_meta:get(Tab)).
ets:tab2list/1
.See also: ets:tab2list/1.
Equivalent to ets:tabfile_info/1
.
Equivalent to table(Tab, []).
Equivalent to table(Tab, Options, shards_meta:get(Tab)).
ets:table/2
, but it returns a list of qlc:query_handle()
; one per partition.See also: ets:table/2.
Tab
.Equivalent to take(Tab, Key, shards_meta:get(Tab)).
ets:take/2
.See also: ets:take/2.
Equivalent to ets:test_ms(Tuple, MatchSpec).
Equivalent to update_counter(Tab, Key, UpdateOp, shards_meta:get(Tab)).
ets:update_counter/4
.See also: ets:update_counter/4.
Equivalent to update_element(Tab, Key, ElementSpec, shards_meta:get(Tab)).
ets:update_element/3
.See also: ets:update_element/3.
Types
-type access() :: public | protected | private.
-type continuation() :: {Tab :: tab(), MatchSpec :: ets:match_spec(), Limit :: pos_integer(), Partition :: non_neg_integer(), Continuation :: ets_continuation()}.
-type info_item() ::
compressed | fixed | heir | keypos | memory | name | named_table | node | owner | protection |
safe_fixed | size | stats | type | write_concurrency | read_concurrency | shards.
-type info_tuple() :: {compressed, boolean()} | {heir, pid() | none} | {keypos, pos_integer()} | {memory, non_neg_integer()} | {name, atom()} | {named_table, boolean()} | {node, node()} | {owner, pid()} | {protection, access()} | {size, non_neg_integer()} | {type, type()} | {write_concurrency, boolean()} | {read_concurrency, boolean()} | {shards, [atom()]}.
-type option() :: type() | access() | named_table | {keypos, pos_integer()} | {heir, pid(), HeirData :: term()} | {heir, none} | tweaks() | shards_opt().
-type shards_opt() :: {partitions, pos_integer()} | {keyslot_fun, shards_meta:keyslot_fun()} | {restore, term(), term()}.
-type tabinfo_item() :: {name, atom()} | {type, type()} | {protection, access()} | {named_table, boolean()} | {keypos, non_neg_integer()} | {size, non_neg_integer()} | {extended_info, [md5sum | object_count]} | {version, {Major :: non_neg_integer(), Minor :: non_neg_integer()}} | {shards, [atom()]}.
-type type() :: set | ordered_set | bag | duplicate_bag.
Functions
Equivalent to ets:all().
-spec delete(Tab :: tab()) -> true.
ets:delete/1
.See also: ets:delete/1.
Equivalent to delete(Tab, Key, shards_meta:get(Tab)).
-spec delete(Tab, Key, Meta) -> true when Tab :: tab(), Key :: term(), Meta :: shards_meta:t().
ets:delete/2
.See also: ets:delete/2.
Equivalent to delete_all_objects(Tab, shards_meta:get(Tab)).
-spec delete_all_objects(Tab, Meta) -> true when Tab :: tab(), Meta :: shards_meta:t().
ets:delete_all_objects/1
.See also: ets:delete_all_objects/1.
Equivalent to delete_object(Tab, Object, shards_meta:get(Tab)).
-spec delete_object(Tab, Object, Meta) -> true when Tab :: tab(), Object :: tuple(), Meta :: shards_meta:t().
ets:delete_object/2
.See also: ets:delete_object/2.
Equivalent to file2tab(Filename, []).
-spec file2tab(Filename, Options) -> {ok, Tab} | {error, Reason} when Filename :: filename(), Tab :: tab(), Options :: [Option], Option :: {verify, boolean()}, Reason :: term().
shards:file2tab/2
. Moreover, it restores the supervision tree for the shards
corresponding to the given file, such as if they had been created using shards:new/2
.See also: ets:file2tab/2.
Equivalent to first(Tab, shards_meta:get(Tab)).
-spec first(Tab, Meta) -> Key | '$end_of_table' when Tab :: tab(), Key :: term(), Meta :: shards_meta:t().
Equivalent to ets:first/1
.
See also: ets:first/1.
Equivalent to foldl(Fun, Acc, Tab, shards_meta:get(Tab)).
-spec foldl(Fun, Acc0, Tab, Meta) -> Acc1 when Fun :: fun((Element :: term(), AccIn) -> AccOut), Tab :: tab(), Meta :: shards_meta:t(), Acc0 :: term(), Acc1 :: term(), AccIn :: term(), AccOut :: term().
Equivalent to ets:foldl/3
.
See also: ets:foldl/3.
Equivalent to foldr(Fun, Acc, Tab, shards_meta:get(Tab)).
-spec foldr(Fun, Acc0, Tab, Meta) -> Acc1 when Fun :: fun((Element :: term(), AccIn) -> AccOut), Tab :: tab(), Meta :: shards_meta:t(), Acc0 :: term(), Acc1 :: term(), AccIn :: term(), AccOut :: term().
Equivalent to ets:foldr/3
.
See also: ets:foldr/3.
Equivalent to get_meta(Tab, Key, undefined).
-spec get_meta(Tab, Key, Def) -> Val when Tab :: tab(), Key :: term(), Def :: term(), Val :: term().
shards_meta:get/3
.
Equivalent to ets:i().
-spec info(Tab) -> InfoList | undefined when Tab :: tab(), InfoList :: [InfoTuple], InfoTuple :: info_tuple().
Similar to ets:info/1' but extra information about the partitioned table is added.
Extra Info:
{partitions, post_integer()}
- Number of partitions.{keyslot_fun, shards_meta:keyslot_fun()}
- Functions used for compute the keyslot.{parallel, boolean()}
- Whether the parallel mode is enabled or not.
See also: ets:info/1.
Equivalent to ets:info/2
.
shards:info/1
.See also: ets:info/2.
Equivalent to insert(Tab, ObjOrObjs, shards_meta:get(Tab)).
-spec insert(Tab, ObjOrObjs, Meta) -> true | no_return() when Tab :: tab(), ObjOrObjs :: tuple() | [tuple()], Meta :: shards_meta:t().
Equivalent to ets:insert/2
.
ets:insert/2
and produces the same result, there is a big difference due to the nature of the sharding distribution model, IT IS NOT ATOMIC. Therefore, if it fails by inserting an object at some partition, previous inserts execution on other partitions are not rolled back, but an error is raised instead.See also: ets:insert/2.
Equivalent to insert_new(Tab, ObjOrObjs, shards_meta:get(Tab)).
-spec insert_new(Tab, ObjOrObjs, Meta) -> boolean() when Tab :: tab(), ObjOrObjs :: tuple() | [tuple()], Meta :: shards_meta:t().
Equivalent to ets:insert_new/2
.
Despite this functions behaves exactly the same as ets:insert_new/2
and produces the same result, there is a big difference due to the nature of the sharding distribution model, IT IS NOT ATOMIC. Opposite to shards:insert/2
, this function tries to roll-back previous inserts execution on other partitions if it fails by inserting an object at some partition, but there might be race conditions during roll-back execution.
Example:
> shards:insert_new(mytab, {k1, 1}).
true
> shards:insert_new(mytab, {k1, 1}).
false
> shards:insert_new(mytab, [{k1, 1}, {k2, 2}]).
false
See also: ets:insert_new/2.
Equivalent to ets:is_compiled_ms(Term).
Equivalent to ets:last/1
.
See also: ets:last/1.
Equivalent to lookup(Tab, Key, shards_meta:get(Tab)).
-spec lookup(Tab, Key, Meta) -> [Object] when Tab :: tab(), Key :: term(), Meta :: shards_meta:t(), Object :: tuple().
ets:lookup/2
.See also: ets:lookup/2.
Equivalent to lookup_element(Tab, Key, Pos, shards_meta:get(Tab)).
-spec lookup_element(Tab, Key, Pos, Meta) -> Elem when Tab :: tab(), Key :: term(), Pos :: pos_integer(), Meta :: shards_meta:t(), Elem :: term() | [term()].
ets:lookup_element/3
.See also: ets:lookup_element/3.
-spec match(Continuation) -> {[Match], continuation()} | '$end_of_table' when Match :: [term()], Continuation :: continuation().
Equivalent to ets:match/1
.
See also: ets:match/1.
Equivalent to match(Tab, Pattern, shards_meta:get(Tab)).
-spec match(Tab, Pattern, LimitOrMeta) -> {[Match], Cont} | '$end_of_table' | [Match] when Tab :: tab(), Pattern :: ets:match_pattern(), LimitOrMeta :: pos_integer() | shards_meta:t(), Match :: [term()], Cont :: continuation().
If 3rd argument is pos_integer()
this function behaves like ets:match/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:match/2
.
See also: ets:match/2, ets:match/3.
-spec match(Tab, Pattern, Limit, Meta) -> {[Match], Cont} | '$end_of_table' when Tab :: tab(), Pattern :: ets:match_pattern(), Limit :: pos_integer(), Meta :: shards_meta:t(), Match :: [term()], Cont :: continuation().
Equivalent to ets:match/3
.
See also: ets:match/3.
Equivalent to match_delete(Tab, Pattern, shards_meta:get(Tab)).
-spec match_delete(Tab, Pattern, Meta) -> true when Tab :: tab(), Pattern :: ets:match_pattern(), Meta :: shards_meta:t().
ets:match_delete/2
.See also: ets:match_delete/2.
-spec match_object(Cont) -> {[Object], Cont} | '$end_of_table' when Object :: tuple(), Cont :: continuation().
Equivalent to ets:match_object/1
.
See also: ets:match_object/1.
Equivalent to match_object(Tab, Pattern, shards_meta:get(Tab)).
-spec match_object(Tab, Pattern, LimitOrMeta) -> {[Object], Cont} | '$end_of_table' | [Object] when Tab :: tab(), Pattern :: ets:match_pattern(), LimitOrMeta :: pos_integer() | shards_meta:t(), Object :: tuple(), Cont :: continuation().
If 3rd argument is pos_integer()
this function behaves like ets:match_object/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:match_object/2
.
See also: ets:match_object/3.
-spec match_object(Tab, Pattern, Limit, Meta) -> {[Object], Cont} | '$end_of_table' when Tab :: tab(), Pattern :: ets:match_pattern(), Limit :: pos_integer(), Meta :: shards_meta:t(), Object :: tuple(), Cont :: continuation().
Equivalent to ets:match_object/3
.
See also: ets:match_object/3.
Equivalent to ets:match_spec_compile(MatchSpec).
Equivalent to ets:match_spec_run(List, CompiledMatchSpec).
Equivalent to member(Tab, Key, shards_meta:get(Tab)).
-spec member(Tab, Key, Meta) -> boolean() when Tab :: tab(), Key :: term(), Meta :: shards_meta:t().
ets:member/2
.See also: ets:member/2.
This operation is equivalent to ets:new/2
, but when is called, instead of create a single ETS table, it creates a new supervision tree for the partitioned table.
The supervision tree is composed by a main supervisor shards_partition_sup
and N
number of workers or partitions handled by shards_partition
(partition owner). Each worker creates an ETS table to handle the partition. Also, the main supervisor shards_partition_sup
creates an ETS table to keep the metadata for the partitioned table.
Returns an atom if the created table is a named table, otherwise, a reference is returned. In the last case, the returned reference is the one of the metadata table, which is the main entry-point and it is owned by the main supervisor shards_partition_sup
.
Options:
In addition to the options given byets:new/2
, this functions provides the next options:{partitions, N}
- Specifies the number of partitions for the sharded table. By default,N = erlang:system_info(schedulers_online)
.{keyslot_fun, F}
- Specifies the function used to compute the partition where the action will be evaluated. Defaults toerlang:phash2/2
.{parallel, P}
- Specifies whethershards
should work in parallel mode or not, for the applicable functions, e.g.:select
,match
, etc. By default is set tofalse
.{parallel_timeout, T}
- Whenparallel
is set totrue
, it specifies the max timeout for a parallel execution. Defaults toinfinity
.
Access:
Currently, only public
access is supported by shards:new/2
. Since a partitioned table is started with its own supervision tree when created, it is very tricky to provide private
or protected
access since there are multiple partitions (or ETS tables) and they are owned by the supervisor's children, and the supervisor along with their children (or partitions) are managed by shards
under-the-hood; it is completely transparent for the client.
Examples:
> Tab = shards:new(tab1, []).
#Ref<0.1541908042.2337144842.31535>
> shards:new(tab2, [named_table]).
tab2
See also the "Partitioned Table" section at the module documentation for more information.See also: ets:new/2.
-spec next(Tab, Key1, Meta) -> Key2 | '$end_of_table' when Tab :: tab(), Key1 :: term(), Key2 :: term(), Meta :: shards_meta:t().
Equivalent to ets:next/2
.
See also: ets:next/2.
TabOrPid
.
Equivalent to ets:next/2
.
See also: ets:prev/2.
-spec put_meta(Tab, Key, Val) -> ok when Tab :: shards:tab(), Key :: term(), Val :: term().
shards_meta:put/3
.
Equivalent to rename(Tab, Name, shards_meta:get(Tab)).
-spec rename(Tab, Name, Meta) -> Name when Tab :: tab(), Name :: atom(), Meta :: shards_meta:t().
Equivalent to ets:rename/2
.
See also: ets:rename/2.
Equivalent to safe_fixtable(Tab, Fix, shards_meta:get(Tab)).
-spec select(Cont) -> {[Match], Cont} | '$end_of_table' when Match :: term(), Cont :: continuation().
Equivalent to ets:select/1
.
See also: ets:select/1.
Equivalent to select(Tab, MatchSpec, shards_meta:get(Tab)).
-spec select(Tab, MatchSpec, LimitOrMeta) -> {[Match], Cont} | '$end_of_table' | [Match] when Tab :: tab(), MatchSpec :: ets:match_spec(), LimitOrMeta :: pos_integer() | shards_meta:t(), Match :: term(), Cont :: continuation().
If 3rd argument is pos_integer()
this function behaves like ets:select/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:select/2
.
See also: ets:select/3.
-spec select(Tab, MatchSpec, Limit, Meta) -> {[Match], Cont} | '$end_of_table' when Tab :: tab(), MatchSpec :: ets:match_spec(), Limit :: pos_integer(), Meta :: shards_meta:t(), Match :: term(), Cont :: continuation().
Equivalent to ets:select/3
.
See also: ets:select/3.
Equivalent to select_count(Tab, MatchSpec, shards_meta:get(Tab)).
-spec select_count(Tab, MatchSpec, Meta) -> NumMatched when Tab :: tab(), MatchSpec :: ets:match_spec(), Meta :: shards_meta:t(), NumMatched :: non_neg_integer().
ets:select_count/2
.See also: ets:select_count/2.
Equivalent to select_delete(Tab, MatchSpec, shards_meta:get(Tab)).
-spec select_delete(Tab, MatchSpec, Meta) -> NumDeleted when Tab :: tab(), MatchSpec :: ets:match_spec(), Meta :: shards_meta:t(), NumDeleted :: non_neg_integer().
ets:select_delete/2
.See also: ets:select_delete/2.
Equivalent to select_replace(Tab, MatchSpec, shards_meta:get(Tab)).
-spec select_replace(Tab, MatchSpec, Meta) -> NumReplaced when Tab :: tab(), MatchSpec :: ets:match_spec(), Meta :: shards_meta:t(), NumReplaced :: non_neg_integer().
ets:select_replace/2
.See also: ets:select_replace/2.
-spec select_reverse(Cont) -> {[Match], Cont} | '$end_of_table' when Cont :: continuation(), Match :: term().
Equivalent to ets:select_reverse/1
.
See also: ets:select_reverse/1.
Equivalent to select_reverse(Tab, MatchSpec, shards_meta:get(Tab)).
-spec select_reverse(Tab, MatchSpec, LimitOrMeta) -> {[Match], Cont} | '$end_of_table' | [Match] when Tab :: tab(), MatchSpec :: ets:match_spec(), LimitOrMeta :: pos_integer() | shards_meta:t(), Match :: term(), Cont :: continuation().
If 3rd argument is pos_integer()
this function behaves like ets:select_reverse/3
, otherwise, the 3rd argument is assumed as shards_meta:t()` and it behaves like `ets:select_reverse/2
.
See also: ets:select_reverse/3.
-spec select_reverse(Tab, MatchSpec, Limit, Meta) -> {[Match], Cont} | '$end_of_table' when Tab :: tab(), MatchSpec :: ets:match_spec(), Limit :: pos_integer(), Meta :: shards_meta:t(), Match :: term(), Cont :: continuation().
Equivalent to ets:select_reverse/3
.
See also: ets:select_reverse/3.
Equivalent to setopts(Tab, Opts, shards_meta:get(Tab)).
-spec setopts(Tab, Opts, Meta) -> true when Tab :: tab(), Opts :: Opt | [Opt], Opt :: {heir, pid(), HeirData} | {heir, none}, Meta :: shards_meta:t(), HeirData :: term().
Equivalent to ets:setopts/2
.
true
if the function was applied successfully on each partition, otherwise, false
is returned.See also: ets:setopts/2.
Equivalent to tab2file(Tab, Filename, []).
-spec tab2file(Tab, Filename, Options) -> ok | {error, Reason} when Tab :: tab(), Filename :: filename(), Options :: [Option], Option :: {extended_info, [md5sum | object_count]} | {sync, boolean()}, Reason :: term().
Equivalent to ets:tab2file/3
.
ets:tab2file/3
, and also generates a master file with the given Filename
that holds the information of the created partition files so that they can be recovered by calling ets:file2tab/1,2
.See also: ets:tab2file/3.
Equivalent to tab2list(Tab, shards_meta:get(Tab)).
-spec tab2list(Tab, Meta) -> [Object] when Tab :: tab(), Meta :: shards_meta:t(), Object :: tuple().
ets:tab2list/1
.See also: ets:tab2list/1.
-spec tabfile_info(Filename) -> {ok, TableInfo} | {error, Reason} when Filename :: filename(), TableInfo :: [tabinfo_item()], Reason :: term().
Equivalent to ets:tabfile_info/1
.
See also: ets:tabfile_info/1.
Equivalent to table(Tab, []).
Equivalent to table(Tab, Options, shards_meta:get(Tab)).
-spec table(Tab, Options, Meta) -> QueryHandle when Tab :: tab(), QueryHandle :: qlc:query_handle(), Options :: [Option] | Option, Meta :: shards_meta:t(), Option :: {n_objects, NObjects} | {traverse, TraverseMethod}, NObjects :: default | pos_integer(), MatchSpec :: ets:match_spec(), TraverseMethod :: first_next | last_prev | select | {select, MatchSpec}.
ets:table/2
, but it returns a list of qlc:query_handle()
; one per partition.See also: ets:table/2.
-spec table_meta(Tab :: tab()) -> shards_meta:t().
Tab
.
Equivalent to take(Tab, Key, shards_meta:get(Tab)).
-spec take(Tab, Key, Meta) -> [Object] when Tab :: tab(), Key :: term(), Meta :: shards_meta:t(), Object :: tuple().
ets:take/2
.See also: ets:take/2.
Equivalent to ets:test_ms(Tuple, MatchSpec).
Equivalent to update_counter(Tab, Key, UpdateOp, shards_meta:get(Tab)).
-spec update_counter(Tab, Key, UpdateOp, DefaultOrMeta) -> Result | [Result] when Tab :: tab(), Key :: term(), UpdateOp :: term(), DefaultOrMeta :: tuple() | shards_meta:t(), Result :: integer().
Equivalent to ets:update_counter/4
.
shards_meta:t()
, it behaves like ets:update_counter/3
.See also: ets:update_counter/4.
-spec update_counter(Tab, Key, UpdateOp, Default, Meta) -> Result | [Result] when Tab :: tab(), Key :: term(), UpdateOp :: term(), Default :: tuple(), Meta :: shards_meta:t(), Result :: integer().
ets:update_counter/4
.See also: ets:update_counter/4.
Equivalent to update_element(Tab, Key, ElementSpec, shards_meta:get(Tab)).
-spec update_element(Tab, Key, ElementSpec, Meta) -> boolean() when Tab :: tab(), Key :: term(), ElementSpec :: {Pos, Value} | [{Pos, Value}], Pos :: pos_integer(), Value :: term(), Meta :: shards_meta:t().
ets:update_element/3
.See also: ets:update_element/3.