Behaviours: riak_dt.
References
http://hal.upmc.fr/inria-00555588/
A G-Counter CRDT. A G-Counter is a Grow-only counter. Modeled as a list of two-tuples. Each entry in the list is an {actor, count} pair. The value of the counter is the sum of all entries in the list. An actor may only update its own entry. An entry can only be incremented. Borrows liberally from argv0 and Justin Sheehy's vclock module in implementation.
Seeriak_kv_pncounter for a counter that can be decremented
abstract datatype: gcounter()
gcounter_op() = increment | {increment, pos_integer()}
| equal/2 | Are two gcounter()s structurally equal? This is not value/1 equality. |
| from_binary/1 | Decode binary G-Counter. |
| merge/2 | Merge two gcounter()s to a single gcounter(). |
| new/0 | Create a new, empty gcounter() |
| new/2 | Create a gcounter() with an initial update. |
| parent_clock/2 | |
| stat/2 | |
| stats/1 | |
| to_binary/1 | Encode an effecient binary representation of a gcounter() |
| to_binary/2 | |
| to_version/2 | |
| update/3 | increment the entry in GCnt for Actor by 1 or {increment, Amt}. |
| update/4 | |
| value/1 | The single total value of a gcounter(). |
| value/2 | value/2 is just value/1 for a gcounter() |
equal(VA::gcounter(), VB::gcounter()) -> boolean()
Are two gcounter()s structurally equal? This is not value/1 equality.
Two counters might represent the total 42, and not be equal/2. Equality here is
that both counters contain the same actors and those actors have the same count.
from_binary(B::binary()) -> {ok, gcounter()} | {error, invalid_binary} | {error, unsupported_version, Vers::pos_integer()}
Decode binary G-Counter
merge(GCnt1::gcounter(), GCnt2::gcounter()) -> gcounter()
Merge two gcounter()s to a single gcounter(). This is the Least Upper Bound
function described in the literature.
new() -> gcounter()
Create a new, empty gcounter()
new(Id::riak_dt:actor(), Count::pos_integer()) -> gcounter()
Create a gcounter() with an initial update
parent_clock(Clock::riak_dt_vclock:vclock(), GCnt::gcounter()) -> gcounter()
stat(X1::atom(), GCnt::gcounter()) -> number() | undefined
stats(GCnt::gcounter()) -> [{atom(), number()}]
to_binary(GCnt::gcounter()) -> binary()
Encode an effecient binary representation of a gcounter()
to_binary(Vers::pos_integer(), C::gcounter()) -> {ok, binary()} | {error, unsupported_version, Vers::pos_integer()}
to_version(Version::pos_integer(), C::gcounter()) -> gcounter()
update(X1::gcounter_op(), Actor::riak_dt:actor(), GCnt::gcounter()) -> {ok, gcounter()}
increment the entry in GCnt for Actor by 1 or {increment, Amt}.
returns an updated gcounter() or error if Amt is not a pos_integer()
update(Op::gcounter_op(), Actor::riak_dt:actor(), GCnt::gcounter(), Ctx::riak_dt:context()) -> {ok, gcounter()}
value(GCnt::gcounter()) -> non_neg_integer()
The single total value of a gcounter().
value(X1::any(), GCnt::gcounter()) -> non_neg_integer()
value/2 is just value/1 for a gcounter()
Generated by EDoc