# 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 Tab.

.
delete/3

Deletes all objects with the key Key from the table Tab.

.
delete_all_objects/2

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/3

Destroy the contents of the specified table.

.
first/2

Returns the first key Key in the table Tab. If the table is empty, $end_of_table will be returned.

.
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 Tab as a list of {Item, Value} tuples.

.
info/3

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/3

Inserts the object or all of the objects in the list ObjOrObjs into the table Tab.

.
insert_new/3

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/2

Returns the last key Key in the table Tab. If the table is empty, $end_of_table will be returned.

.
lookup/3

Returns a list of all objects with the key Key in the table Tab.

.
lookup_element/4

Returns the Pos:th element of the object with the key Key in the table Tab.

.
match/2

Continues a match started with match/3.

.
match/3

Matches the objects in the table Tab against the pattern Pattern.

.
match/4

Matches the objects in the table Tab against the pattern Pattern and returns a limited (Limit) number of matching objects.

.
match_delete/3

Deletes all objects which match the pattern Pattern from the table Tab.

.
match_object/2

Continues a match started with match_object/3.

.
match_object/3

Matches the objects in the table Tab against the pattern Pattern.

.
match_object/4

Matches the objects in the table Tab against the pattern Pattern and returns a limited (Limit) number of matching objects.

.
member/3

Returns true if one or more elements in the table Tab has the key Key, false otherwise.

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

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/3

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/3

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

.
select/3

Matches the objects in the table Tab against the spec Spec.

.
select/4

Matches the objects in the table Tab against the spec Spec and returns a limited (Limit) number of matching objects.

.
select_count/3

Counts all objects which match the spec Spec from the table Tab and returns the number matched.

.
select_delete/3

Deletes all objects which match the spec Spec from the table Tab and returns the number deleted.

.
select_reverse/2

Continues a select reverse started with select_reverse/3.

.
select_reverse/3

Matches in reverse the objects in the table Tab against the spec Spec.

.
select_reverse/4

Matches in reverse the objects in the table Tab against the spec Spec and returns a limited (Limit) number of matching objects.

.
tab2list/2

Returns a list of all objects in the table Tab. The operation is not guaranteed to be atomic and isolated.

.
tid/2

Returns a table's identifier.

.
tid/3

Returns a copy of a table's identifier with the given implementation options.

.
## Function Details ## ### all/1 ###

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.

__See also:__ [ets:delete/1](ets.md#delete-1). ### delete/3 ###

delete(NS::gen_ns(), Tab::gen_tab(), Key::key()) -> true


Deletes all objects with the key Key from the table Tab.

__See also:__ [ets:delete/2](ets.md#delete-2). ### delete_all_objects/2 ###

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.

__See also:__ [ets:delete_all_objects/1](ets.md#delete_all_objects-1). ### destroy/3 ###

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.

__See also:__ [ets:first/1](ets.md#first-1). ### foldl/4 ###

foldl(NS::gen_ns(), Fun, Acc0::term(), Tab::gen_tab()) -> Acc1::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()

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.

__See also:__ [info/2](#info-2). ### info/3 ###

info(NS::gen_ns(), Tab::gen_tab(), Item::item()) -> term()


Returns the information associated with Item for the table Tab.

Valid +Item+ options are:
__See also:__ [ets:info/2](ets.md#info-2). ### insert/3 ###

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.

__See also:__ [ets:insert/2](ets.md#insert-2). ### insert_new/3 ###

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.

__See also:__ [ets:insert_new/2](ets.md#insert_new-2). ### last/2 ###

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.

__See also:__ [ets:last/1](ets.md#last-1). ### lookup/3 ###

lookup(NS::gen_ns(), Tab::gen_tab(), Key::key()) -> [object()]


Returns a list of all objects with the key Key in the table Tab.

__See also:__ [ets:lookup/2](ets.md#lookup-2). ### lookup_element/4 ###

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.

__See also:__ [ets:lookup_element/3](ets.md#lookup_element-3). ### match/2 ###

match(NS::gen_ns(), X2::cont() | '$end_of_table') -> {[match()], cont() | '$end_of_table'} | '$end_of_table'


Continues a match started with match/3.

__See also:__ [ets:match/1](ets.md#match-1). ### match/3 ###

match(NS::gen_ns(), Tab::gen_tab(), Pattern::match_pattern()) -> [match()]


Matches the objects in the table Tab against the pattern Pattern.

__See also:__ [ets:match/2](ets.md#match-2). ### match/4 ###

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.

__See also:__ [ets:match/3](ets.md#match-3). ### match_delete/3 ###

match_delete(NS::gen_ns(), Tab::gen_tab(), Pattern::match_pattern()) -> true


Deletes all objects which match the pattern Pattern from the table Tab.

__See also:__ [ets:match_delete/2](ets.md#match_delete-2). ### match_object/2 ###

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.

__See also:__ [ets:match_object/1](ets.md#match_object-1). ### 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.

__See also:__ [ets:match_object/2](ets.md#match_object-2). ### match_object/4 ###

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.

__See also:__ [ets:match_object/3](ets.md#match_object-3). ### member/3 ###

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.

__See also:__ [ets:member/2](ets.md#member-2). ### new/3 ###

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:
__See also:__ [ets:new/2](ets.md#new-2). ### next/3 ###

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.

__See also:__ [ets:next/2](ets.md#next-2). ### prev/3 ###

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.

__See also:__ [ets:prev/2](ets.md#prev-2). ### repair/3 ###

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.

__See also:__ [ets:select/1](ets.md#select-1). ### select/3 ###

select(NS::gen_ns(), Tab::gen_tab(), Spec::match_spec()) -> [match()]


Matches the objects in the table Tab against the spec Spec.

__See also:__ [ets:select/2](ets.md#select-2). ### select/4 ###

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.

__See also:__ [ets:select/3](ets.md#select-3). ### select_count/3 ###

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.

__See also:__ [ets:select_count/2](ets.md#select_count-2). ### select_delete/3 ###

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.

__See also:__ [ets:select_delete/2](ets.md#select_delete-2). ### select_reverse/2 ###

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.

__See also:__ [ets:select_reverse/1](ets.md#select_reverse-1). ### 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.

__See also:__ [ets:select_reverse/2](ets.md#select_reverse-2). ### select_reverse/4 ###

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.

__See also:__ [ets:select_reverse/3](ets.md#select_reverse-3). ### tab2list/2 ###

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.

__See also:__ [ets:tab2list/1](ets.md#tab2list-1). ### tid/2 ###

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.