Grove.Set.GSet (Grove v0.1.1)
View SourceA Grow-only Set (G-Set) CRDT.
Elements can only be added, never removed. This makes it the simplest set CRDT with straightforward merge semantics (union).
Delta-State Support
This CRDT supports delta-state replication for efficient synchronization:
delta/1- Returns accumulated changes since last resetreset_delta/1- Clears the delta buffer after synchronization
Example
iex> set = Grove.Set.GSet.new(:node_a)
iex> set = Grove.Set.GSet.add(set, "apple")
iex> set = Grove.Set.GSet.add(set, "banana")
iex> Grove.Set.GSet.value(set) |> Enum.sort()
["apple", "banana"]
Summary
Functions
Adds an element to the set.
Returns the accumulated delta since the last reset.
Checks if an element is in the set.
Merges two G-Sets.
Creates a new G-Set for the given actor.
Resets the delta buffer after synchronization.
Returns the number of elements in the set.
Returns the elements as a list.
Returns the elements as a MapSet.
Types
Functions
Adds an element to the set.
Adding an element that already exists is a no-op.
Returns the accumulated delta since the last reset.
The delta contains only the elements added locally, which can be sent to other replicas for efficient synchronization.
Checks if an element is in the set.
Merges two G-Sets.
The result is the union of both sets.
Creates a new G-Set for the given actor.
Resets the delta buffer after synchronization.
Call this after sending the delta to other replicas.
@spec size(t()) :: non_neg_integer()
Returns the number of elements in the set.
Returns the elements as a list.
Returns the elements as a MapSet.