Module riak_dt_gcounter

A G-Counter CRDT.

Behaviours: riak_dt.

References

Description

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.

See riak_kv_pncounter for a counter that can be decremented

Data Types

gcounter()

abstract datatype: gcounter()

gcounter_op()

gcounter_op() = increment | {increment, pos_integer()}

Function Index

equal/2Are two gcounter()s structurally equal? This is not value/1 equality.
from_binary/1Decode binary G-Counter.
merge/2Merge two gcounter()s to a single gcounter().
new/0Create a new, empty gcounter()
new/2Create a gcounter() with an initial update.
parent_clock/2
stat/2
stats/1
to_binary/1Encode an effecient binary representation of a gcounter()
to_binary/2
to_version/2
update/3increment the entry in GCnt for Actor by 1 or {increment, Amt}.
update/4
value/1The single total value of a gcounter().
value/2value/2 is just value/1 for a gcounter()

Function Details

equal/2

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/1

from_binary(B::binary()) -> {ok, gcounter()} | {error, invalid_binary} | {error, unsupported_version, Vers::pos_integer()}

Decode binary G-Counter

merge/2

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/0

new() -> gcounter()

Create a new, empty gcounter()

new/2

new(Id::riak_dt:actor(), Count::pos_integer()) -> gcounter()

Create a gcounter() with an initial update

parent_clock/2

parent_clock(Clock::riak_dt_vclock:vclock(), GCnt::gcounter()) -> gcounter()

stat/2

stat(X1::atom(), GCnt::gcounter()) -> number() | undefined

stats/1

stats(GCnt::gcounter()) -> [{atom(), number()}]

to_binary/1

to_binary(GCnt::gcounter()) -> binary()

Encode an effecient binary representation of a gcounter()

to_binary/2

to_binary(Vers::pos_integer(), C::gcounter()) -> {ok, binary()} | {error, unsupported_version, Vers::pos_integer()}

to_version/2

to_version(Version::pos_integer(), C::gcounter()) -> gcounter()

update/3

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/4

update(Op::gcounter_op(), Actor::riak_dt:actor(), GCnt::gcounter(), Ctx::riak_dt:context()) -> {ok, gcounter()}

value/1

value(GCnt::gcounter()) -> non_neg_integer()

The single total value of a gcounter().

value/2

value(X1::any(), GCnt::gcounter()) -> non_neg_integer()

value/2 is just value/1 for a gcounter()


Generated by EDoc