# Module gen_ets_ns #
* [Data Types](#types)
* [Function Index](#index)
* [Function Details](#functions)
__This module defines the `gen_ets_ns` behaviour.__
Required callback functions: `open/2`, `destroy/2`, `repair/2`, `delete/1`, `delete/2`, `delete_all_objects/1`, `first/1`, `first_iter/1`, `info_memory/1`, `info_size/1`, `insert/2`, `insert_new/2`, `last/1`, `last_iter/1`, `lookup/2`, `lookup_element/3`, `member/2`, `next/2`, `next_iter/2`, `prev/2`, `prev_iter/2`, `notify/4`, `first/2`, `first_iter/2`, `last/2`, `last_iter/2`, `next/3`, `next_iter/3`, `prev/3`, `prev_iter/3`.
## Data Types ##
### cont() ###
__abstract datatype__: `cont()`
### gen_ns() ###
gen_ns() = atom()
### gen_tab() ###
gen_tab() = name() | gen_tid()
### gen_tid() ###
__abstract datatype__: `gen_tid()`
### impl_opt() ###
impl_opt() = term()
### impl_opts() ###
impl_opts() = [impl_opt()]
### item() ###
item() = owner | name | named_table | type | keypos | protection | compressed | async | memory | size
### key() ###
key() = term()
### limit() ###
limit() = pos_integer()
### match() ###
match() = term()
### match_pattern() ###
match_pattern() = atom() | tuple()
ets:match_pattern() is not exported!
### match_spec() ###
match_spec() = ets:match_spec()
### name() ###
name() = term()
### object() ###
object() = tuple()
### opt() ###
opt() = set | ordered_set | named_table | {keypos, pos_integer()} | public | protected | private | compressed | async
### opts() ###
opts() = [opt() | {impl, {module(), impl_opts()}}]
### pos() ###
pos() = pos_integer()
## Function Index ##
all/1 | Returns a list of all tables at the node. . |
behaviour_info/1 | |
delete/2 | Deletes the entire table |
delete/3 | Deletes all objects with the key |
delete_all_objects/2 | Delete all objects in the table |
destroy/3 | Destroy the contents of the specified table. . |
first/2 | Returns the first key |
foldl/4 | Fold from left to right over the elements of the table. . |
foldr/4 | Fold from right to left over the elements of the table. . |
info/2 | Returns information about the table |
info/3 | Returns the information associated with
|
insert/3 | Inserts the object or all of the objects in the list
|
insert_new/3 | This function works exactly like |
last/2 | Returns the last key |
lookup/3 | Returns a list of all objects with the key |
lookup_element/4 | Returns the |
match/2 | Continues a match started with |
match/3 | Matches the objects in the table |
match/4 | Matches the objects in the table |
match_delete/3 | Deletes all objects which match the pattern |
match_object/2 | Continues a match started with |
match_object/3 | Matches the objects in the table |
match_object/4 | Matches the objects in the table |
member/3 | Returns |
new/3 | Creates a new table and returns a table identifier which can be used in subsequent operations. The table identifier can be sent to other processes so that a table can be shared between different processes within a node.
|
next/3 | Returns the next key |
prev/3 | Returns the previous key |
repair/3 | If a table cannot be opened, you may attempt to call this method to resurrect as much of the contents of the table as possible. Some data may be lost, so be careful when calling this function on a table that contains important information. . |
select/2 | Continues a select started with |
select/3 | Matches the objects in the table |
select/4 | Matches the objects in the table |
select_count/3 | Counts all objects which match the spec |
select_delete/3 | Deletes all objects which match the spec |
select_reverse/2 | Continues a select reverse started with |
select_reverse/3 | Matches in reverse the objects in the table |
select_reverse/4 | Matches in reverse the objects in the table |
tab2list/2 | Returns a list of all objects in the table |
tid/2 | Returns a table's identifier. . |
tid/3 | Returns a copy of a table's identifier with the given implementation options. . |
all(NS::gen_ns()) -> [gen_tab()]
Returns a list of all tables at the node.
__See also:__ [ets:all/0](ets.md#all-0). ### behaviour_info/1 ### `behaviour_info(Other) -> any()` ### delete/2 ###
delete(NS::gen_ns(), Tab::gen_tab()) -> true
Deletes the entire table Tab
.
delete(NS::gen_ns(), Tab::gen_tab(), Key::key()) -> true
Deletes all objects with the key Key
from the table Tab
.
delete_all_objects(NS::gen_ns(), Tab::gen_tab()) -> true
Delete all objects in the table Tab
. The operation is
guaranteed to be atomic and isolated. This function only applies
to the ets
implementation.
destroy(NS::gen_ns(), Name::name(), Opts::opts()) -> true
Destroy the contents of the specified table.
### first/2 ###
first(NS::gen_ns(), Tab::gen_tab()) -> key() | '$end_of_table'
Returns the first key Key
in the table Tab
. If the table
is empty, $end_of_table
will be returned.
foldl(NS::gen_ns(), Fun, Acc0::term(), Tab::gen_tab()) -> Acc1::term()
Fun = fun((Element::term(), AccIn::term()) -> AccOut::term())
Fold from left to right over the elements of the table.
__See also:__ [ets:foldl/3](ets.md#foldl-3). ### foldr/4 ###
foldr(NS::gen_ns(), Fun, Acc0::term(), Tab::gen_tab()) -> Acc1::term()
Fun = fun((Element::term(), AccIn::term()) -> AccOut::term())
Fold from right to left over the elements of the table.
__See also:__ [ets:foldr/3](ets.md#foldr-3). ### info/2 ###
info(NS::gen_ns(), Tab::gen_tab()) -> [{item(), term()}]
Returns information about the table Tab
as a list of {Item,
Value}
tuples.
info(NS::gen_ns(), Tab::gen_tab(), Item::item()) -> term()
Returns the information associated with Item
for the table Tab
.
Valid +Item+ options are:
owner
name
named_table
only the ets implementation
type
keypos
protection
compressed
async
only the drv implementation
memory
only the ets implementation
size
only the ets implementation
insert(NS::gen_ns(), Tab::gen_tab(), ObjOrObjs::object() | [object()]) -> true
Inserts the object or all of the objects in the list
ObjOrObjs
into the table Tab
.
insert_new(NS::gen_ns(), Tab::gen_tab(), ObjOrObjs::object() | [object()]) -> true
This function works exactly like insert/2
, with the
exception that instead of overwriting objects with the same key, it
simply returns false. This function only applies to the ets
implementation.
last(NS::gen_ns(), Tab::gen_tab()) -> key() | '$end_of_table'
Returns the last key Key
in the table Tab
. If the table
is empty, $end_of_table
will be returned.
lookup(NS::gen_ns(), Tab::gen_tab(), Key::key()) -> [object()]
Returns a list of all objects with the key Key
in the table
Tab
.
lookup_element(NS::gen_ns(), Tab::gen_tab(), Key::key(), Pos::pos()) -> term()
Returns the Pos
:th element of the object with the key Key
in the table Tab
.
match(NS::gen_ns(), X2::cont() | '$end_of_table') -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Continues a match started with match/3
.
match(NS::gen_ns(), Tab::gen_tab(), Pattern::match_pattern()) -> [match()]
Matches the objects in the table Tab
against the pattern
Pattern
.
match(NS::gen_ns(), Tab::gen_tab(), Pattern::match_pattern(), Limit::limit()) -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Matches the objects in the table Tab
against the pattern
Pattern
and returns a limited (Limit
) number of matching
objects.
match_delete(NS::gen_ns(), Tab::gen_tab(), Pattern::match_pattern()) -> true
Deletes all objects which match the pattern Pattern
from the
table Tab
.
match_object(NS::gen_ns(), X2::cont() | '$end_of_table') -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Continues a match started with match_object/3
.
match_object(NS::gen_ns(), Tab::gen_tab(), Pattern::match_pattern()) -> [match()]
Matches the objects in the table Tab
against the pattern
Pattern
.
match_object(NS::gen_ns(), Tab::gen_tab(), Pattern::match_pattern(), Limit::limit()) -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Matches the objects in the table Tab
against the pattern
Pattern
and returns a limited (Limit
) number of matching
objects.
member(NS::gen_ns(), Tab::gen_tab(), Key::key()) -> true | false
Returns true
if one or more elements in the table Tab
has
the key Key
, false
otherwise.
new(NS::gen_ns(), Name::name(), Opts::opts()) -> gen_tab()
Creates a new table and returns a table identifier which can be used in subsequent operations. The table identifier can be sent to other processes so that a table can be shared between different processes within a node.
Valid GEN_ETS properties for +Options+ are:
set
The table is a set table - one key, one object, no order
among objects. This is the default table type.
ordered_set
The table is an ordered_set table - one key, one
object, ordered in Erlang term order, which is the order implied
by the <
and >
operators.
named_table
If this option is present, the name Name
is
associated with the table identifier.
{keypos,pos_integer()}
Specfies which element in the stored
tuples should be used as key. By default, it is the first
element, i.e. Pos=1
.
public
Any process may read or write to the table.
protected
The owner process can read and write to the table.
Other processes can only read the table. This is the default
setting for the access rights.
private
Only the owner process can read or write to the table.
compressed
If this option is present, the table data will be
stored in a compressed format.
async
If this option is present and supported by the
implementation, the emulator's async thread pool will be used
when accessing the table data.
{impl, module(), impl_opts()}
The module that implements
GEN_ETS callback functions. Implementation specific options can be
given. The default is {impl, gen_ets_impl_ets, []}
.
next(NS::gen_ns(), Tab::gen_tab(), Key::key()) -> key() | '$end_of_table'
Returns the next key Key2
, following the key Key1
in the
table Tab
. If there is no next key, $end_of_table
is
returned.
prev(NS::gen_ns(), Tab::gen_tab(), Key::key()) -> key() | '$end_of_table'
Returns the previous key Key2
, following the key Key1
in
the table Tab
. If there is no previous key, $end_of_table
is
returned.
repair(NS::gen_ns(), Name::name(), Opts::opts()) -> true
If a table cannot be opened, you may attempt to call this method to resurrect as much of the contents of the table as possible. Some data may be lost, so be careful when calling this function on a table that contains important information.
### select/2 ###
select(NS::gen_ns(), X2::cont() | '$end_of_table') -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Continues a select started with select/3
.
select(NS::gen_ns(), Tab::gen_tab(), Spec::match_spec()) -> [match()]
Matches the objects in the table Tab
against the spec
Spec
.
select(NS::gen_ns(), Tab::gen_tab(), Spec::match_spec(), Limit::limit()) -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Matches the objects in the table Tab
against the spec Spec
and returns a limited (Limit
) number of matching objects.
select_count(NS::gen_ns(), Tab::gen_tab(), Spec::match_spec()) -> pos_integer()
Counts all objects which match the spec Spec
from the
table Tab
and returns the number matched.
select_delete(NS::gen_ns(), Tab::gen_tab(), Spec::match_spec()) -> pos_integer()
Deletes all objects which match the spec Spec
from the
table Tab
and returns the number deleted.
select_reverse(NS::gen_ns(), X2::cont() | '$end_of_table') -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Continues a select reverse started with select_reverse/3
.
select_reverse(NS::gen_ns(), Tab::gen_tab(), Spec::match_spec()) -> [match()]
Matches in reverse the objects in the table Tab
against the
spec Spec
.
select_reverse(NS::gen_ns(), Tab::gen_tab(), Spec::match_spec(), Limit::limit()) -> {[match()], cont() | '$end_of_table'} | '$end_of_table'
Matches in reverse the objects in the table Tab
against the
spec Spec
and returns a limited (Limit
) number of matching
objects.
tab2list(NS::gen_ns(), Tab::gen_tab()) -> [object()]
Returns a list of all objects in the table Tab
. The
operation is not guaranteed to be atomic and isolated.
tid(NS::gen_ns(), Tab::gen_tab()) -> gen_tid()
Returns a table's identifier.
### tid/3 ###
tid(NS::gen_ns(), Tab::gen_tab(), Opts::term()) -> gen_tid()
Returns a copy of a table's identifier with the given implementation options.