delta_crdt v0.2.1 DeltaCrdt.AWLWWMap

An add-wins last-write-wins map.

This CRDT is an add-wins last-write-wins map. This means:

  • The data structure is of a map. So you can store the following values:
%{key: "value"}
%{"1" => %{another_map: "what!"}}
%{123 => {:a, :tuple}}
  • Both keys and values are of type term() (aka any()).

  • Add-wins means that if there is a conflict between an add and a remove operation, the add operation will win out. This is in contrast to remove-wins, where the remove operation would win.

  • Last-write-wins means that if there is a conflict between two write operations, the latest (as marked with a timestamp) will win. Underwater, every delta contains a timestamp which is used to resolve the conflicts.

Link to this section Summary

Functions

Add (or overwrite) a key-value pair to the map

Remove all key-value pairs from the map

Convenience function to create an empty add-wins last-write-wins map

Read the state of the map

Remove a key and it’s corresponding value from the map

Link to this section Types

Link to this opaque crdt_delta() (opaque)
Link to this opaque crdt_state() (opaque)
Link to this type key()
key() :: term()
Link to this type node_id()
node_id() :: term()
Link to this type value()
value() :: term()

Link to this section Functions

Link to this function add(key, val, i, map)
add(key :: key(), val :: value(), i :: node_id(), crdt_state()) :: crdt_delta()

Add (or overwrite) a key-value pair to the map

Link to this function clear(i, map)
clear(node_id(), crdt_state()) :: crdt_delta()

Remove all key-value pairs from the map

Convenience function to create an empty add-wins last-write-wins map

Link to this function read(map)
read(map() :: crdt_state()) :: map()

Read the state of the map

Note: this operation is expensive, so it’s best not to call this more often than necessary.

Link to this function remove(key, i, map)
remove(key :: key(), i :: node_id(), crdt_state()) :: crdt_delta()

Remove a key and it’s corresponding value from the map