Module riakc_map

Encapsulates a map data-type.

Behaviours: riakc_datatype.

Description

Encapsulates a map data-type. Maps differ from Erlang's dict types in several ways:

Data Types

crdt_map()

crdt_map() = #map{value = [raw_entry()], updates = [entry()], removes = ordsets:ordset(key()), context = riakc_datatype:context()}

datatype()

datatype() = counter | flag | register | set | map

embedded_type_op()

embedded_type_op() = riakc_counter:counter_op() | riakc_set:set_op() | riakc_flag:flag_op() | riakc_register:register_op() | map_op()

entry()

entry() = {key(), riakc_datatype:datatype()}

field_update()

field_update() = {update, key(), embedded_type_op()}

key()

key() = {binary(), datatype()}

map_op()

map_op() = {update, [simple_map_op()]}

raw_entry()

raw_entry() = {key(), term()}

simple_map_op()

simple_map_op() = {remove, key()} | field_update()

update_fun()

update_fun() = fun((riakc_datatype:datatype()) -> riakc_datatype:datatype())

Function Index

erase/2Removes a key and its value from the map.
fetch/2Returns the "unwrapped" value associated with the key in the map.
fetch_keys/1Returns a list of all keys in the map.
find/2Searches for a key in the map.
fold/3Folds over the entries in the map.
is_key/2Test if the key is contained in the map.
is_type/1Determines whether the passed term is a map container.
new/0Creates a new, empty map container type.
new/1Creates a new map with the specified context.
new/2Creates a new map with the specified key-value pairs and context.
size/1Returns the number of entries in the map.
to_op/1Extracts an operation from the map that can be encoded into an update request.
type/0Returns the symbolic name of this container.
update/3Updates the value stored at the key by calling the passed function to get the new value.
value/1Gets the original value of the map.

Function Details

erase/2

erase(Key::key(), Map::crdt_map()) -> crdt_map()

throws context_required

Removes a key and its value from the map. Removing a key that does not exist simply records a remove operation.

fetch/2

fetch(Key::key(), Map::crdt_map()) -> term()

Returns the "unwrapped" value associated with the key in the map. If the key is not present, an exception is generated.

fetch_keys/1

fetch_keys(Map::crdt_map()) -> [key()]

Returns a list of all keys in the map.

find/2

find(Key::key(), Map::crdt_map()) -> {ok, term()} | error

Searches for a key in the map. Returns {ok, UnwrappedValue} when the key is present, or error if the key is not present in the map.

fold/3

fold(Fun::fun((key(), term(), term()) -> term()), Acc0::term(), Map::crdt_map()) -> term()

Folds over the entries in the map. This yields raw values, not container types.

is_key/2

is_key(Key::key(), Map::crdt_map()) -> boolean()

Test if the key is contained in the map.

is_type/1

is_type(T::term()) -> boolean()

Determines whether the passed term is a map container.

new/0

new() -> crdt_map()

Creates a new, empty map container type.

new/1

new(Context::riakc_datatype:context()) -> crdt_map()

Creates a new map with the specified context.

new/2

new(Values::[raw_entry()], Context::riakc_datatype:context()) -> crdt_map()

Creates a new map with the specified key-value pairs and context.

size/1

size(Map::crdt_map()) -> pos_integer()

Returns the number of entries in the map.

to_op/1

to_op(Map::crdt_map()) -> riakc_datatype:update(map_op())

Extracts an operation from the map that can be encoded into an update request.

type/0

type() -> atom()

Returns the symbolic name of this container.

update/3

update(Key::key(), Fun::update_fun(), M::crdt_map()) -> crdt_map()

Updates the value stored at the key by calling the passed function to get the new value. If the key did not previously exist, it will be initialized to the empty value for its type before being passed to the function.

value/1

value(Map::crdt_map()) -> [raw_entry()]

Gets the original value of the map.


Generated by EDoc, Dec 16 2016, 16:38:08.