XEts (x_ets v0.2.0)
A partitioned ETS implementation.
This is an Elixir wrapper around the shards
library.
The Access protocol is implemented. To support the Access protocol, XEts.new/2
returns a struct with the tab
field set to the table name.
Many of the functions support a struct or a shards tab() as the first argument. Those that take a struct (and the Access protocol callbacks) are chainable as illustrated in the example below.
:shard functions that return a value are not chainable, like lookup, select, etc.
Examples
iex> XEts.new(:test) |>
...> XEts.insert(x: %{}) |>
...> put_in([:x, :y], 1) |>
...> update_in([:x, :y], & &1 + 1) |>
...> XEts.to_list()
[{:x, %{y: 2}}]
Link to this section Summary
Functions
Returns a list of all tables at the node.
Deletes the entire table.
Delete an item from the table.
Delete a key given metadata.
Delete all objects from the table.
Delete all objects from the table given metadata.
Delete an object from the table.
Delete an object from the table given metadata.
Fetch a value from the table.
Equivalent to first(tab, :shards_meta.get(tab)).
Equivalent to :ets.first/1
.
Fold left over the table.
Fold left over the table given metadata.
Fold right over the table.
Fold right over the table given metadata.
Get a value from the table.
Get and update an item in the table.
Get the metadata of the table.
Similar to :ets.info/1
but extra information about the partitioned table is added.
Equivalent to :ets.info/2
.
Insert an item into the table.
Insert an item into the table given metadata.
Insert a new item into the table.
Insert a new item into the table given metadata.
Check if an item is a compiled match spec.
Get the last item in the table.
Lookup an item in the table.
Lookup an item in the table given metadata.
Lookup an element in the table.
Lookup an element in the table given metadata.
Match an item in the table.
Match an item in the table.
Match an item in the table given metadata and limit.
Match an item in the table and delete it.
Match an item in the table and delete it given metadata.
Match an item in the table.
Match an item in the table given limit or metadata.
Match an item in the table given limit and metadata.
Check if an item is a member of the table.
Check if an item is a member of the table given metadata.
Create a new table.
Get the next item in the table.
Returns the partition PIDs associated with the given table TabOrPid
.
Pop an item from the table.
Returns the previous item in the table.
Put an item or items into the table.
Put an item into the table.
Put metadata into the table.
Equivalent to rename(tab, name, :shards_meta.get(tab))
Equivalent to :ets.rename/2
.
Equivalent to :ets.safe_fixtable/2
.
Equivalent to :ets.select/1
.
Equivalent to :ets.select/2
.
Select items from the table given a match spec and limit or metadata.
Select items from the table given a match spec and limit or metadata.
Equivalent to select_count(tab, match_spec, :shards_meta.get(tab)).
Equivalent to :ets.select_count/2
.
Equivalent to select_delete(tab, match_spec, :shards_meta.get(tab)).
Equivalent to :ets.select_delete/2
.
Equivalent to select_replace(tab, match_spec, :shards_meta.get(tab)).
Equivalent to :ets.select_replace/2
.
Equivalent to :ets.select_reverse/1
.
Equivalent to select_reverse(tab, match_spec, :shards_meta.get(tab)).
Select items in reverse order given a match spec and limit or metadata.
Equivalent to :ets.select_reverse/3.
Equivalent to setopts(tab, opts, :shards_meta.get(tab)).
Equivalent to :ets.setopts/2
.
Get the size of the table.
Equivalent to tab2file(tab, filename, []).
Equivalent to :ets.tab2file/3
.
Equivalent to tab2list(tab, :shards_meta.get(tab)).
Equivalent to :ets.tab2list/1
.
Equivalent to :ets.tabfile_info/1
.
Equivalent to table(tab, []).
Equivalent to table(tab, options, :shards_meta.get(tab)).
Similar to :ets.table/2
, but it returns a list of :qlc.query_handle(); one
per partition.
Returns the metadata associated with the given table.
Equivalent to take(tab, key, :shards_meta.get(tab)).
Equivalent to :ets.take/2
.
Equivalent to :ets.test_ms/2
.
Convert a table to a list of tuples.
Equivalent to update_counter(tab, key, update_op, :shards_meta.get(tab)).
Equivalent to update_counter(tab, key, update_op, default_or_meta).
Equivalent to update_counter(tab, key, update_op, default, meta).
Equivalent to update_element(tab, key, element_spec, :shards_meta.get(tab)).
Equivalent to :ets.whereis/1
.
Link to this section Types
continuation()
Specs
continuation() :: :shards.continuation()
element_spec()
Specs
element_spec() :: {pos_integer(), term()} | [{pos_integer(), term()}]
filename()
Specs
info_item()
Specs
info_item() :: :shards.info_item()
info_tuple()
Specs
info_tuple() :: :shards.info_tuple()
limit()
Specs
limit() :: pos_integer()
limit_or_meta()
Specs
match_spec()
Specs
match_spec() :: :ets.match_spec()
meta()
Specs
meta() :: :shards_meta.t()
n_objects()
Specs
n_objects() :: :default | pos_integer()
opt()
Specs
option()
Specs
option() :: {:n_objects, n_objects()} | {:traverse, traversal_method()}
options()
Specs
opts()
Specs
Specs
tab()
Specs
tabinfo_item()
Specs
tabinfo_item() :: :shards.tabinfo_item()
traversal_method()
Specs
traversal_method() :: :first_next | :last_prev | :select | {:select, match_spec()}
Link to this section Functions
all()
Specs
all() :: [tab()]
Returns a list of all tables at the node.
Equivalent to :ets.all/0.
delete(tab)
Specs
delete(t()) :: true
Deletes the entire table.
Equivalent to :ets.delete/1.
delete(tab, key)
Specs
Delete an item from the table.
Examples
iex> XEts.new(:table) |> XEts.insert(x: 1, y: 2) |> XEts.delete(:x) |> XEts.to_list()
[{:y, 2}]
iex> %{tab: tab} = XEts.new(:table1) |> XEts.insert(x: 1, y: 2)
iex> XEts.delete(tab, :y)
iex> XEts.to_list(tab)
[{:x, 1}]
delete(tab, key, meta)
Specs
Delete a key given metadata.
delete_all_objects(tab)
Specs
Delete all objects from the table.
Examples
iex> XEts.new(:table) |> XEts.insert(x: 1, y: 2) |> XEts.delete_all_objects() |> XEts.to_list()
[]
iex> %{tab: tab} = XEts.new(:table1) |> XEts.insert(x: 1, y: 2)
iex> XEts.delete_all_objects(tab)
iex> XEts.to_list(tab)
[]
delete_all_objects(tab, meta)
Specs
Delete all objects from the table given metadata.
delete_object(tab, key)
Specs
Delete an object from the table.
Examples
iex> XEts.new(:table) |> XEts.insert(x: 1, y: 2) |> XEts.delete_object({:x, 1}) |> XEts.to_list()
[{:y, 2}]
iex> %{tab: tab} = XEts.new(:table1) |> XEts.insert(x: 1, y: 2)
iex> XEts.delete_object(tab, {:y, 2})
iex> XEts.to_list(tab)
[{:x, 1}]
delete_object(tab, key, meta)
Specs
Delete an object from the table given metadata.
Examples
iex> tab = XEts.new(:table)
iex> XEts.insert(tab, x: 1, y: 2)
iex> meta = :shards_meta.get(tab.tab)
iex> tab |> XEts.delete_object({:x, 1}, meta) |> XEts.to_list()
[{:y, 2}]
fetch(tab, key)
Specs
Fetch a value from the table.
iex> XEts.new(:foo) |> XEts.put(:k, :v) |> XEts.fetch(:k)
{:ok, :v}
iex> XEts.new(:foo, []) |> XEts.fetch(:k)
:error
file2tab(filename)
Specs
file2tab(filename, options)
Specs
first(tab)
Specs
Equivalent to first(tab, :shards_meta.get(tab)).
first(tab, meta)
Specs
Equivalent to :ets.first/1
.
However, the order in which results are returned might be not the same as the original ETS function, since it is a sharded table.
See also: :ets.first/1.
foldl(tab, acc, fun)
Specs
Fold left over the table.
Examples
iex> %{tab: tab} = XEts.new(:table) |> XEts.insert(y: 1, x: 2)
iex> XEts.foldl(tab, [], fn {k, v}, acc -> [{k, v * 2} | acc] end)
[x: 4, y: 2]
foldl(tab, acc, meta, fun)
Specs
Fold left over the table given metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(y: 1, x: 2)
iex> XEts.foldl(tab, [], XEts.get_meta(tab), fn {k, v}, acc -> [{k, v * 2} | acc] end)
[x: 4, y: 2]
iex> %{tab: tab} = XEts.new(:table) |> XEts.insert(y: 1, x: 2)
iex> XEts.foldl(tab, [], XEts.get_meta(tab), fn {k, v}, acc -> [{k, v * 2} | acc] end)
[x: 4, y: 2]
foldr(tab, acc, fun)
Specs
Fold right over the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.foldr(tab, [], fn {k, v}, acc -> [{k, v * 2} | acc] end)
[x: 2, y: 4]
foldr(tab, acc, meta, fun)
Specs
Fold right over the table given metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.foldr(tab, [], XEts.get_meta(tab), fn {k, v}, acc -> [{k, v * 2} | acc] end)
[x: 2, y: 4]
iex> %{tab: tab} = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.foldr(tab, [], XEts.get_meta(tab), fn {k, v}, acc -> [{k, v * 2} | acc] end)
[x: 2, y: 4]
get(tab, value, default \\ nil)
Specs
Get a value from the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.get(tab, :x)
1
iex> XEts.get(tab, :foo)
nil
iex> XEts.get(tab, :foo, :bar)
:bar
get_and_update(tab, key, fun)
Specs
Get and update an item in the table.
iex> tab = XEts.new(:foo)|> XEts.put(:k, 2)
iex> XEts.get_and_update(tab, :k, & { &1, &1 + 1 })
{2, tab}
get_meta(tab)
Specs
Get the metadata of the table.
Examples
iex> tab = XEts.new(:table)
iex> {:meta, pid, _, _, fun, false, :infinity, []} = XEts.get_meta(tab)
iex> is_pid(pid) && is_function(fun, 2)
true
iex> %{tab: tab} = XEts.new(:table)
iex> {:meta, pid, _, _, fun, false, :infinity, []} = XEts.get_meta(tab)
iex> is_pid(pid) && is_function(fun, 2)
true
Specs
i() :: any()
info(tab)
Specs
info(t() | tab()) :: [info_tuple()] | :undefined
Similar to :ets.info/1
but extra information about the partitioned table is added.
Extra Info:
{:partitions, pos_integer()}
- The number of partitions in the table.{:keyslot_fun, :shards_meta.keyslot_fun()}
- Functions used to compute the keyslot.{:parallel, boolean()}
- Whether the parallel mode is enabled or not.
See also :ets.info/1.
info(tab, key)
Specs
Equivalent to :ets.info/2
.
See the added items by XEts.info/1
.
See also: :ets.info/2.
insert(tab, item)
Specs
Insert an item into the table.
Examples
iex> XEts.new(:table) |> XEts.insert({:x, 5}) |> XEts.to_list()
[{:x, 5}]
iex> tab = XEts.new(:table) |> Map.get(:tab)
iex> XEts.insert(tab, {:x, 5})
iex> XEts.to_list(tab)
[{:x, 5}]
insert(tab, key, meta)
Specs
Insert an item into the table given metadata.
Examples
iex> tab = XEts.new(:table)
iex> tab |> XEts.insert({:x, 5}, XEts.get_meta(tab)) |> XEts.to_list()
[{:x, 5}]
insert_new(tab, item)
Specs
Insert a new item into the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.insert_new(tab, {:x, 3}) |> XEts.to_list()
[{:y, 2}, {:x, 1}]
insert_new(tab, item, meta)
Specs
Insert a new item into the table given metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.insert_new(tab, {:x, 3}, XEts.get_meta(tab)) |> XEts.to_list()
[{:y, 2}, {:x, 1}]
is_compiled_ms(item)
Specs
Check if an item is a compiled match spec.
Examples
iex> XEts.is_compiled_ms({:x, 1})
false
last(tab)
Specs
Get the last item in the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.last(tab)
:y
lookup(tab, key)
Specs
Lookup an item in the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.lookup(tab, :x)
[x: 1]
iex> %{tab: tab} = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.lookup(tab, :y)
[y: 2]
lookup(tab, key, meta)
Specs
Lookup an item in the table given metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.lookup(tab, :x, XEts.get_meta(tab))
[x: 1]
lookup_element(tab, key, pos)
Specs
Lookup an element in the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.lookup_element(tab, :x, 1)
:x
iex> XEts.lookup_element(tab, :x, 2)
1
iex> %{tab: tab} = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.lookup_element(tab, :y, 2)
2
lookup_element(tab, key, pos, meta)
Specs
lookup_element(t(), any(), integer(), meta()) :: any()
lookup_element(tab(), any(), integer(), meta()) :: any()
Lookup an element in the table given metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.lookup_element(tab, :x, 1, XEts.get_meta(tab))
:x
iex> XEts.lookup_element(tab, :x, 2, XEts.get_meta(tab))
1
match(continuation)
Specs
match(tab, pattern)
Specs
Match an item in the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.match(tab, :"$1")
[[y: 2], [x: 1]]
iex> %{tab: tab} = XEts.new(:table) |> XEts.insert({{:item, 1}, 2})
iex> XEts.match(tab, {{:item, :"$1"}, :"$2"})
[[1, 2]]
match(tab, pattern, limit_or_meta)
Specs
Match an item in the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.match(tab, :"$1", XEts.get_meta(tab))
[[y: 2], [x: 1]]
iex> %{tab: tab} = XEts.new(:table1) |> XEts.insert(x: 1, y: 2, z: 3)
iex> XEts.match(tab, {:"$1", :"$2"}, 2) |> elem(0)
[[:y, 2], [:z, 3]]
match(tab, pattern, limit, meta)
Specs
Match an item in the table given metadata and limit.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.match(tab, :"$1", 2, XEts.get_meta(tab)) |> elem(0)
[[x: 1], [y: 2]]
iex> %{tab: tab} = XEts.new(:table1) |> XEts.insert(x: 1, y: 2, z: 3)
iex> XEts.match(tab, {:"$1", :"$2"}, 2, XEts.get_meta(tab)) |> elem(0)
[[:y, 2], [:z, 3]]
match_delete(tab, pattern)
Specs
Match an item in the table and delete it.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> tab |> XEts.match_delete({:x, :_}) |> XEts.to_list()
[{:y, 2}]
iex> tab |> XEts.match_delete({:_, 2}) |> XEts.to_list()
[]
match_delete(tab, pattern, meta)
Specs
Match an item in the table and delete it given metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> tab |> XEts.match_delete({:x, :_}, XEts.get_meta(tab)) |> XEts.to_list()
[{:y, 2}]
match_object(tab, pattern)
Specs
Match an item in the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> tab |> XEts.match_object({:x, :_})
[{:x, 1}]
iex> tab |> XEts.match_object({:_, 2})
[{:y, 2}]
match_object(tab, pattern, limit_or_meta)
Specs
Match an item in the table given limit or metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2, z: 3)
iex> tab |> XEts.match_object({:x, :_}, XEts.get_meta(tab))
[{:x, 1}]
iex> tab |> XEts.match_object(:_, 2) |> elem(0)
[{:y, 2}, {:z, 3}]
match_object(tab, pattern, limit, meta)
Specs
Match an item in the table given limit and metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 1, z: 1)
iex> tab |> XEts.match_object({:_, 1}, 2, XEts.get_meta(tab)) |> elem(0)
[{:y, 1}, {:z, 1}]
match_spec_compile(match_spec)
Specs
match_spec_run(list, compiled_match_spec)
Specs
member?(tab, key)
Specs
Check if an item is a member of the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.member?(tab, :x)
true
iex> XEts.member?(tab, :z)
false
member?(tab, key, meta)
Specs
Check if an item is a member of the table given metadata.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.member?(tab, :x, XEts.get_meta(tab))
true
iex> XEts.member?(tab, :z, XEts.get_meta(tab))
false
new(tab, opts \\ [])
Specs
Create a new table.
Examples
iex> %{tab: tab, keypos: 1} = XEts.new(:table)
iex> is_reference(tab)
true
next(tab, key1, meta)
Specs
Get the next item in the table.
Examples
iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> tab |> XEts.next(:x, XEts.get_meta(tab))
:"$end_of_table"
partition_owners(tab_or_pid)
Specs
Returns the partition PIDs associated with the given table TabOrPid
.
pop(tab, key, default \\ nil)
Specs
Pop an item from the table.
iex> tab = XEts.KV.new(:foo, [])
iex> tab |> XEts.KV.put(:k, :v) |> XEts.KV.pop(:k)
{:v, tab}
prev(tab, key1)
Specs
Returns the previous item in the table.
Equivalent to :ets.next/2
However, the order in which results are returned might not be the same as the original ETS function, since it's a sharded table.
See also: :ets.pray/2.
put(tab, item)
Specs
Put an item or items into the table.
Examples
iex> XEts.new(:table) |> XEts.put(x: 1, y: 2) |> XEts.to_list()
[y: 2, x: 1]
put(tab, key, value)
Specs
Put an item into the table.
Examples
iex> XEts.new(:table) |> XEts.put(:x, 1) |> XEts.to_list()
[x: 1]
put_meta(tab, key, value)
Specs
Put metadata into the table.
Wrapper for :shards_meta.put/3
.
rename(tab, name)
Specs
Equivalent to rename(tab, name, :shards_meta.get(tab))
rename(tab, name, meta)
Specs
Equivalent to :ets.rename/2
.
Renames the table name and all its associated shard tables. If something unexpected occurs during the process, an exception will be raised.
See also: :ets.rename/2.
safe_fixtable(tab, fix)
Specs
Equivalent to :ets.safe_fixtable/2
.
select(continuation)
Specs
select(continuation()) :: {[term()], continuation()} | :"$end_of_table"
Equivalent to :ets.select/1
.
The order in which results are returned might be not the same as the original ETS function.
See also: ets:select/1.
select(tab, match_spec)
Equivalent to :ets.select/2
.
See also: ets:select/2.
select(tab, match_spec, limit_or_meta)
Specs
select(t() | tab(), match_spec(), limit_or_meta()) :: t() | {[term()], continuation()} | :"$end_of_table"
select(t() | tab(), match_spec(), limit() | meta()) :: t() | {[term()], continuation()} | :"$end_of_table"
Select items from the table given a match spec and limit or metadata.
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.
The order in which results are returned might be not the same as the original ETS function.
See also: :ets.select/3.
select(tab, match_spec, limit, meta)
Select items from the table given a match spec and limit or metadata.
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.
The order in which results are returned might be not the same as the original ETS function.
See also: :ets.select/3.
select_count(tab, match_spec)
Specs
select_count(t() | tab(), match_spec()) :: non_neg_integer()
Equivalent to select_count(tab, match_spec, :shards_meta.get(tab)).
select_count(tab, match_spec, meta)
Specs
select_count(t() | tab(), match_spec(), meta()) :: non_neg_integer()
Equivalent to :ets.select_count/2
.
See also: :ets.select_count/2.
select_delete(tab, match_spec)
Specs
select_delete(t() | tab(), match_spec()) :: num_deleted :: non_neg_integer()
Equivalent to select_delete(tab, match_spec, :shards_meta.get(tab)).
select_delete(tab, match_spec, meta)
Specs
select_delete(t() | tab(), match_spec(), meta()) :: num_deleted :: non_neg_integer()
Equivalent to :ets.select_delete/2
.
See also: :ets.select_delete/2.
select_replace(tab, match_spec)
Specs
select_replace(t() | tab(), match_spec()) :: num_replaced :: non_neg_integer()
Equivalent to select_replace(tab, match_spec, :shards_meta.get(tab)).
select_replace(tab, match_spec, meta)
Specs
select_replace(t() | tab(), match_spec(), meta()) :: num_replaced :: non_neg_integer()
Equivalent to :ets.select_replace/2
.
See also: :ets.select_replace/2.
select_reverse(continuation)
Specs
select_reverse(continuation()) :: {[term()], continuation()} | :"$end_of_table"
Equivalent to :ets.select_reverse/1
.
The order in which results are returned might be not the same as the original ETS function.
See also: :ets.select_reverse/1.
select_reverse(tab, match_spec)
Specs
select_reverse(t() | tab(), match_spec()) :: {[term()], continuation()} | :"$end_of_table" | [term()]
Equivalent to select_reverse(tab, match_spec, :shards_meta.get(tab)).
select_reverse(tab, match_spec, limit_or_meta)
Specs
select_reverse(t() | tab(), match_spec(), limit_or_meta()) :: {[term()], continuation()} | :"$end_of_table" | [term()]
Select items in reverse order given a match spec and limit or metadata.
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.
The order in which results are returned might be not the same as the original ETS function.
See also: :ets.select_reverse/3.
select_reverse(tab, match_spec, limit, meta)
Specs
select_reverse(t() | tab(), match_spec(), limit(), meta()) :: {[term()], continuation()} | :"$end_of_table"
Equivalent to :ets.select_reverse/3.
The order in which results are returned might be not the same as the original ETS function.
See also: :ets.select_reverse/3.
setopts(tab, opts)
Equivalent to setopts(tab, opts, :shards_meta.get(tab)).
setopts(tab, opts, meta)
Specs
Equivalent to :ets.setopts/2
.
Returns true if the function was applied successfully on each partition, otherwise, false is returned.
See also: :ets.setopts/2.
size(tab)
Specs
Get the size of the table.
tab2file(tab, filename)
Specs
Equivalent to tab2file(tab, filename, []).
tab2file(tab, filename, options)
Specs
Equivalent to :ets.tab2file/3
.
This function generates one file per partition using :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.
tab2list(tab)
Specs
Equivalent to tab2list(tab, :shards_meta.get(tab)).
tab2list(tab, meta)
Specs
Equivalent to :ets.tab2list/1
.
See also: :ets.tab2list/1.
tabfile_info(filename)
Specs
tabfile_info(filename()) :: {:ok, tabinfo_item()} | {:error, term()}
Equivalent to :ets.tabfile_info/1
.
Adds extra information about the partitions.
See also: :shards.tabfile_info/1.
table(tab)
Specs
table(t() | tab()) :: :qlc.query_handle()
Equivalent to table(tab, []).
table(tab, options)
Specs
table(t() | tab(), options()) :: :qlc.query_handle()
Equivalent to table(tab, options, :shards_meta.get(tab)).
table(tab, meta, options)
Specs
table(t() | tab(), meta(), options()) :: :qlc.query_handle()
Similar to :ets.table/2
, but it returns a list of :qlc.query_handle(); one
per partition.
See also: :ets.table/2.
table_meta(tab)
Specs
Returns the metadata associated with the given table.
take(tab, key)
Specs
Equivalent to take(tab, key, :shards_meta.get(tab)).
take(tab, key, meta)
Specs
Equivalent to :ets.take/2
.
See also: :ets.take/2.
test_ms(tuple, match_spec)
Specs
test_ms(tuple(), match_spec()) :: boolean()
Equivalent to :ets.test_ms/2
.
to_list(tab)
Specs
Convert a table to a list of tuples.
See also: :ets.tab2list/1.
update_counter(tab, key, update_op)
Specs
update_counter(t() | tab(), term(), term()) :: t() | [integer()] | integer()
update_counter(t() | tab(), term(), tuple() | meta()) :: t() | [integer()] | integer()
Equivalent to update_counter(tab, key, update_op, :shards_meta.get(tab)).
Examples
iex> %{tab: tab} = :test |> XEts.new() |> XEts.insert({10, 10, 4, "description"})
iex> XEts.update_counter(tab, 10, {3, 1})
5
iex> XEts.lookup(tab, 10)
[{10, 10, 5, "description"}]
update_counter(tab, key, update_op, default_or_meta)
Specs
Equivalent to update_counter(tab, key, update_op, default_or_meta).
Examples
iex> %{tab: tab} = :test |> XEts.new()
iex> XEts.update_counter(tab, 10, {3, 1}, {10, 10, 4, "description"})
5
iex> XEts.lookup(tab, 10)
[{10, 10, 5, "description"}]
update_counter(tab, key, update_op, default, meta)
Equivalent to update_counter(tab, key, update_op, default, meta).
Examples
iex> %{tab: tab} = :test |> XEts.new() |> XEts.insert(x: 0, y: 1)
iex> meta = XEts.get_meta(tab)
iex> XEts.update_counter(tab, :x, {2, 3}, {:x, 0}, meta)
3
iex> XEts.update_counter(tab, :y, {2, 3}, {:y, 0}, meta)
4
iex> XEts.update_counter(tab, :z, {2, -1}, {:z, 5}, meta)
4
iex> XEts.to_list(tab) |> Enum.sort()
[x: 3, y: 4, z: 4]
update_element(tab, key, element_spec)
Specs
Equivalent to update_element(tab, key, element_spec, :shards_meta.get(tab)).
Examples
iex> %{tab: tab} = :test |> XEts.new() |> XEts.insert(x: 2, y: 4)
iex> XEts.update_element(tab, :x, {2, 10})
true
iex> XEts.lookup(tab, :x)
[{:x, 10}]
update_element(tab, key, element_spec, meta)
Specs
Equivalent to :ets.update_element/3
.
See also: :ets.update_element/3.
whereis(tab)
Specs
Equivalent to :ets.whereis/1
.
See also: :ets.whereis/1.
Examples
iex> XEts.new(:test, [:named_table])
iex> XEts.whereis(:test) |> is_reference()
true
iex> XEts.whereis(:test2)
:undefined