Behaviours: riakc_datatype.
Encapsulates a map data-type. Maps differ from Erlang's dict types in several ways:
{<<"friends">>, set} -> riakc_set:set()
.
Regular Erlang terms may not be values in the map, but could be
serialized into register
fields if last-write-wins semantics are
sufficient.update/3
, which is analogous to dict:update/3
. If the
entry is not present, it will be populated with a new value before
the update function is applied. The update function will receive
the appropriate container type as its sole argument.crdt_map() = #map{value = [raw_entry()], updates = [entry()], removes = ordsets:ordset(key()), context = riakc_datatype:context()}
datatype() = counter | flag | register | set | map
embedded_type_op() = riakc_counter:counter_op() | riakc_set:set_op() | riakc_flag:flag_op() | riakc_register:register_op() | map_op()
entry() = {key(), riakc_datatype:datatype()}
field_update() = {update, key(), embedded_type_op()}
key() = {binary(), datatype()}
map_op() = {update, [simple_map_op()]}
raw_entry() = {key(), term()}
simple_map_op() = {remove, key()} | field_update()
update_fun() = fun((riakc_datatype:datatype()) -> riakc_datatype:datatype())
erase/2 | Removes a key and its value from the map. |
fetch/2 | Returns the "unwrapped" value associated with the key in the map. |
fetch_keys/1 | Returns a list of all keys in the map. |
find/2 | Searches for a key in the map. |
fold/3 | Folds over the entries in the map. |
is_key/2 | Test if the key is contained in the map. |
is_type/1 | Determines whether the passed term is a map container. |
new/0 | Creates a new, empty map container type. |
new/1 | Creates a new map with the specified context. |
new/2 | Creates a new map with the specified key-value pairs and context. |
size/1 | Returns the number of entries in the map. |
to_op/1 | Extracts an operation from the map that can be encoded into an update request. |
type/0 | Returns the symbolic name of this container. |
update/3 | Updates the value stored at the key by calling the passed function to get the new value. |
value/1 | Gets the original value of the map. |
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(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(Map::crdt_map()) -> [key()]
Returns a list of all keys in the map.
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(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(Key::key(), Map::crdt_map()) -> boolean()
Test if the key is contained in the map.
is_type(T::term()) -> boolean()
Determines whether the passed term is a map container.
new() -> crdt_map()
Creates a new, empty map container type.
new(Context::riakc_datatype:context()) -> crdt_map()
Creates a new map with the specified context.
new(Values::[raw_entry()], Context::riakc_datatype:context()) -> crdt_map()
Creates a new map with the specified key-value pairs and context.
size(Map::crdt_map()) -> pos_integer()
Returns the number of entries in the map.
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() -> atom()
Returns the symbolic name of this container.
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(Map::crdt_map()) -> [raw_entry()]
Gets the original value of the map.
Generated by EDoc, Dec 16 2016, 16:38:08.