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)).

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.

i()

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))

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 select_delete(tab, match_spec, :shards_meta.get(tab)).

Equivalent to select_replace(tab, match_spec, :shards_meta.get(tab)).

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)).

Get the size of the table.

Equivalent to tab2file(tab, filename, []).

Equivalent to tab2list(tab, :shards_meta.get(tab)).

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)).

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

Link to this type

continuation()

Specs

continuation() :: :shards.continuation()
Link to this type

element_spec()

Specs

element_spec() :: {pos_integer(), term()} | [{pos_integer(), term()}]

Specs

filename() :: charlist() | binary() | atom()

Specs

info_item() :: :shards.info_item()
Link to this type

info_tuple()

Specs

info_tuple() :: :shards.info_tuple()

Specs

limit() :: pos_integer()
Link to this type

limit_or_meta()

Specs

limit_or_meta() :: limit() | meta()
Link to this type

match_spec()

Specs

match_spec() :: :ets.match_spec()

Specs

meta() :: :shards_meta.t()

Specs

n_objects() :: :default | pos_integer()

Specs

opt() :: {:heir, :none} | {:heir, pid(), term()}

Specs

option() :: {:n_objects, n_objects()} | {:traverse, traversal_method()}

Specs

options() :: [option()] | option()

Specs

opts() :: opt() | [opt()]

Specs

t() :: %XEts{keypos: integer(), tab: atom()}

Specs

tab() :: atom() | :ets.tid()
Link to this type

tabinfo_item()

Specs

tabinfo_item() :: :shards.tabinfo_item()
Link to this type

traversal_method()

Specs

traversal_method() ::
  :first_next | :last_prev | :select | {:select, match_spec()}

Link to this section Functions

Specs

all() :: [tab()]

Returns a list of all tables at the node.

Equivalent to :ets.all/0.

Specs

delete(t()) :: true

Deletes the entire table.

Equivalent to :ets.delete/1.

Link to this function

delete(tab, key)

Specs

delete(t(), any()) :: tab()
delete(tab(), any()) :: true

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}]
Link to this function

delete(tab, key, meta)

Specs

delete(t(), any(), meta()) :: t()
delete(tab(), any(), meta()) :: true

Delete a key given metadata.

Link to this function

delete_all_objects(tab)

Specs

delete_all_objects(t()) :: t()
delete_all_objects(tab()) :: true

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)
[]
Link to this function

delete_all_objects(tab, meta)

Specs

delete_all_objects(t(), meta()) :: t()
delete_all_objects(tab(), meta()) :: true

Delete all objects from the table given metadata.

Link to this function

delete_object(tab, key)

Specs

delete_object(t(), any()) :: t()
delete_object(tab(), any()) :: boolean()

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}]
Link to this function

delete_object(tab, key, meta)

Specs

delete_object(t(), any(), meta()) :: t()
delete_object(tab(), any(), meta()) :: boolean()

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}]
Link to this function

fetch(tab, key)

Specs

fetch(t(), any()) :: {:ok, any()} | :error

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
Link to this function

file2tab(filename)

Specs

file2tab(charlist() | binary()) :: {:ok, tab()} | {:error, any()}
Link to this function

file2tab(filename, options)

Specs

file2tab(
  charlist() | binary(),
  keyword()
) :: {:ok, tab()} | {:error, any()}

Specs

first(t() | tab()) :: term() | :"$end_of_table"

Equivalent to first(tab, :shards_meta.get(tab)).

Link to this function

first(tab, meta)

Specs

first(t() | tab(), meta()) :: term() | :"$end_of_table"

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.

Link to this function

foldl(tab, acc, fun)

Specs

foldl(t(), any(), function()) :: t()
foldl(tab(), any(), function()) :: any()

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]
Link to this function

foldl(tab, acc, meta, fun)

Specs

foldl(t(), any(), meta(), function()) :: t()
foldl(tab(), any(), meta(), function()) :: t()

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]
Link to this function

foldr(tab, acc, fun)

Specs

foldr(t(), any(), function()) :: t()
foldr(tab(), any(), function()) :: t()

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]
Link to this function

foldr(tab, acc, meta, fun)

Specs

foldr(t(), any(), meta(), function()) :: t()
foldr(tab(), any(), meta(), function()) :: t()

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]
Link to this function

get(tab, value, default \\ nil)

Specs

get(t(), any(), any()) :: any()

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
Link to this function

get_and_update(tab, key, fun)

Specs

get_and_update(t(), any(), any()) :: any()

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}

Specs

get_meta(t()) :: tuple()
get_meta(tab()) :: tuple()

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()

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.

Specs

info(t() | tab(), info_item()) :: term()

Equivalent to :ets.info/2.

See the added items by XEts.info/1.

See also: :ets.info/2.

Link to this function

insert(tab, item)

Specs

insert(t(), any()) :: t()
insert(tab(), any()) :: any()

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}]
Link to this function

insert(tab, key, meta)

Specs

insert(t(), any(), meta()) :: t()
insert(tab(), any(), meta()) :: any()

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}]
Link to this function

insert_new(tab, item)

Specs

insert_new(t(), any()) :: t()
insert_new(tab(), any()) :: boolean()

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}]
Link to this function

insert_new(tab, item, meta)

Specs

insert_new(t(), any(), meta()) :: t()
insert_new(tab(), any(), meta()) :: boolean()

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}]
Link to this function

is_compiled_ms(item)

Specs

is_compiled_ms(any()) :: boolean()

Check if an item is a compiled match spec.

Examples

iex> XEts.is_compiled_ms({:x, 1})
false

Specs

last(t()) :: any()
last(tab()) :: any()

Get the last item in the table.

Examples

iex> tab = XEts.new(:table) |> XEts.insert(x: 1, y: 2)
iex> XEts.last(tab)
:y
Link to this function

lookup(tab, key)

Specs

lookup(t(), any()) :: any()
lookup(tab(), any()) :: any()

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]
Link to this function

lookup(tab, key, meta)

Specs

lookup(t(), any(), meta()) :: any()
lookup(tab(), any(), meta()) :: any()

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]
Link to this function

lookup_element(tab, key, pos)

Specs

lookup_element(t(), any(), integer()) :: any()
lookup_element(tab(), any(), integer()) :: any()

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
Link to this function

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
Link to this function

match(continuation)

Specs

match(any()) :: any()
Link to this function

match(tab, pattern)

Specs

match(t(), any()) :: any()
match(tab(), any()) :: any()

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]]
Link to this function

match(tab, pattern, limit_or_meta)

Specs

match(t(), any(), any()) :: any()
match(tab(), any(), any()) :: any()

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]]
Link to this function

match(tab, pattern, limit, meta)

Specs

match(t(), any(), any(), any()) :: any()
match(tab(), any(), any(), any()) :: any()

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]]
Link to this function

match_delete(tab, pattern)

Specs

match_delete(t(), any()) :: t() | boolean()
match_delete(tab(), any()) :: any()

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()
[]
Link to this function

match_delete(tab, pattern, meta)

Specs

match_delete(t(), any(), meta()) :: t()
match_delete(tab(), any(), meta()) :: any()

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}]
Link to this function

match_object(tab, pattern)

Specs

match_object(t(), any()) :: any()
match_object(tab(), any()) :: any()

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}]
Link to this function

match_object(tab, pattern, limit_or_meta)

Specs

match_object(t(), any(), any()) :: any()
match_object(tab(), any(), any()) :: any()

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}]
Link to this function

match_object(tab, pattern, limit, meta)

Specs

match_object(t(), any(), any(), any()) :: any()
match_object(tab(), any(), any(), any()) :: any()

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}]
Link to this function

match_spec_compile(match_spec)

Specs

match_spec_compile(any()) :: any()
Link to this function

match_spec_run(list, compiled_match_spec)

Specs

match_spec_run(list(), any()) :: any()
Link to this function

member?(tab, key)

Specs

member?(t(), any()) :: boolean()
member?(tab(), any()) :: boolean()

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
Link to this function

member?(tab, key, meta)

Specs

member?(t(), any(), meta()) :: boolean()
member?(tab(), any(), meta()) :: boolean()

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
Link to this function

new(tab, opts \\ [])

Specs

new(
  atom(),
  keyword()
) :: t()

Create a new table.

Examples

iex> %{tab: tab, keypos: 1} = XEts.new(:table)
iex> is_reference(tab)
true
Link to this function

next(tab, key1, meta)

Specs

next(t(), any(), meta()) :: any()
next(tab(), any(), meta()) :: any()

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"
Link to this function

partition_owners(tab_or_pid)

Specs

partition_owners(pid() | tab() | t()) :: [pid()]

Returns the partition PIDs associated with the given table TabOrPid.

Link to this function

pop(tab, key, default \\ nil)

Specs

pop(t(), any(), any()) :: {any(), t()}

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}
Link to this function

prev(tab, key1)

Specs

prev(t() | tab(), any()) :: term() | :"$end_of_table"

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.

Specs

put(t(), any()) :: t()

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]
Link to this function

put(tab, key, value)

Specs

put(t(), any(), any()) :: t()

Put an item into the table.

Examples

iex> XEts.new(:table) |> XEts.put(:x, 1) |> XEts.to_list()
[x: 1]
Link to this function

put_meta(tab, key, value)

Specs

put_meta(t() | tab(), term(), term()) :: t() | :ok

Put metadata into the table.

Wrapper for :shards_meta.put/3.

Link to this function

rename(tab, name)

Specs

rename(t() | tab(), atom()) :: t() | atom()

Equivalent to rename(tab, name, :shards_meta.get(tab))

Link to this function

rename(tab, name, meta)

Specs

rename(t() | tab(), atom(), meta()) :: t() | atom()
rename(tab(), any(), meta()) :: any()

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.

Link to this function

safe_fixtable(tab, fix)

Specs

safe_fixtable(t() | tab(), any()) :: t() | term()

Equivalent to :ets.safe_fixtable/2.

Link to this function

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.

Link to this function

select(tab, match_spec)

Equivalent to :ets.select/2.

See also: ets:select/2.

Link to this function

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 likeets:select/2.

The order in which results are returned might be not the same as the original ETS function.

See also: :ets.select/3.

Link to this function

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 likeets:select/2.

The order in which results are returned might be not the same as the original ETS function.

See also: :ets.select/3.

Link to this function

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)).

Link to this function

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.

Link to this function

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)).

Link to this function

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.

Link to this function

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)).

Link to this function

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.

Link to this function

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.

Link to this function

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)).

Link to this function

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.

Link to this function

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.

Link to this function

setopts(tab, opts)

Equivalent to setopts(tab, opts, :shards_meta.get(tab)).

Link to this function

setopts(tab, opts, meta)

Specs

setopts(t() | tab(), opts(), meta()) :: boolean()

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.

Specs

size(t()) :: integer()

Get the size of the table.

Link to this function

tab2file(tab, filename)

Specs

tab2file(t() | tab(), filename()) :: t() | :ok | {:error, term()}

Equivalent to tab2file(tab, filename, []).

Link to this function

tab2file(tab, filename, options)

Specs

tab2file(t() | tab(), filename(), keyword()) :: t() | :ok | {:error, term()}

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.

Specs

tab2list(t() | tab()) :: [tuple()]

Equivalent to tab2list(tab, :shards_meta.get(tab)).

Link to this function

tab2list(tab, meta)

Specs

tab2list(t() | tab(), meta()) :: [tuple()]

Equivalent to :ets.tab2list/1.

See also: :ets.tab2list/1.

Link to this function

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.

Specs

table(t() | tab()) :: :qlc.query_handle()

Equivalent to table(tab, []).

Link to this function

table(tab, options)

Specs

table(t() | tab(), options()) :: :qlc.query_handle()

Equivalent to table(tab, options, :shards_meta.get(tab)).

Link to this function

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.

Link to this function

table_meta(tab)

Specs

table_meta(t() | tab()) :: :shards_meta.t()

Returns the metadata associated with the given table.

Specs

take(t() | tab(), term()) :: [tuple()]

Equivalent to take(tab, key, :shards_meta.get(tab)).

Link to this function

take(tab, key, meta)

Specs

take(t() | tab(), term(), meta()) :: [tuple()]

Equivalent to :ets.take/2.

See also: :ets.take/2.

Link to this function

test_ms(tuple, match_spec)

Specs

test_ms(tuple(), match_spec()) :: boolean()

Equivalent to :ets.test_ms/2.

Specs

to_list(tab()) :: [tuple()]

Convert a table to a list of tuples.

See also: :ets.tab2list/1.

Link to this function

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"}]
Link to this function

update_counter(tab, key, update_op, default_or_meta)

Specs

update_counter(t() | tab(), term(), tuple(), meta()) ::
  t() | [integer()] | integer()

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"}]
Link to this function

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]
Link to this function

update_element(tab, key, element_spec)

Specs

update_element(t() | tab(), term(), element_spec()) :: t() | boolean()

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}]
Link to this function

update_element(tab, key, element_spec, meta)

Specs

update_element(t() | tab(), term(), element_spec(), meta()) :: t() | boolean()

Equivalent to :ets.update_element/3.

See also: :ets.update_element/3.

Specs

whereis(t() | tab()) :: reference() | :undefined

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