Module riak_dt_pncounter

A PN-Counter CRDT.

Behaviours: riak_dt.

References

See also: riak_kv_gcounter.

Description

A PN-Counter CRDT. A PN-Counter is essentially two G-Counters: one for increments and one for decrements. The value of the counter is the difference between the value of the Positive G-Counter and the value of the Negative G-Counter.

Data Types

any_pncounter()

any_pncounter() = pncounter() | v1_pncounter()

decrement_op()

decrement_op() = decrement | {decrement, pos_integer()}

pncounter()

abstract datatype: pncounter()

pncounter_op()

pncounter_op() = riak_dt_gcounter:gcounter_op() | decrement_op()

pncounter_q()

pncounter_q() = positive | negative

v1_pncounter()

v1_pncounter() = {riak_dt_gcounter:gcounter(), riak_dt_gcounter:gcounter()}

version()

version() = integer()

Function Index

change_versions/3
current_version/1
equal/2Are two pncounter()s structurally equal? This is not value/1 equality.
from_binary/1
merge/2Merge two pncounter()s to a single pncounter().
new/0Create a new, empty pncounter()
new/2Create a pncounter() with an initial Value for Actor.
parent_clock/2no-op.
stat/2
stats/1
to_binary/1Encode an effecient binary representation of pncounter()
to_binary/2
to_version/2
update/3Update a pncounter().
update/4
value/1The single, total value of a pncounter()
value/2query the parts of a pncounter() valid queries are positive or negative.

Function Details

change_versions/3

change_versions(Version::version(), X2::version(), PNCnt::any_pncounter()) -> any_pncounter()

current_version/1

current_version(PNCnt::any_pncounter()) -> version()

equal/2

equal(PNCntA::pncounter(), PNCntB::pncounter()) -> boolean()

Are two pncounter()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 represent exactly the same information.

from_binary/1

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

merge/2

merge(PNCntA::pncounter(), PNCntB::pncounter()) -> pncounter()

Merge two pncounter()s to a single pncounter(). This is the Least Upper Bound function described in the literature.

new/0

new() -> pncounter()

Create a new, empty pncounter()

new/2

new(Actor::term(), Value::integer()) -> pncounter()

Create a pncounter() with an initial Value for Actor.

parent_clock/2

parent_clock(Clock::riak_dt_vclock:vclock(), Cntr::pncounter()) -> pncounter()

no-op

stat/2

stat(X1::atom(), PNCounter::pncounter()) -> number() | undefined

stats/1

stats(PNCounter::pncounter()) -> [{atom(), number()}]

to_binary/1

to_binary(PNCnt::any_pncounter()) -> binary()

Encode an effecient binary representation of pncounter()

to_binary/2

to_binary(Vers::version(), PNCnt::any_pncounter()) -> {ok, binary()} | {error, unsupported_version, Vers::pos_integer()}

to_version/2

to_version(ToVer::pos_integer(), C::any_pncounter()) -> any_pncounter()

update/3

update(Op::pncounter_op(), Actor::riak_dt:actor() | riak_dt:dot(), PNCnt::pncounter()) -> {ok, pncounter()}

Update a pncounter(). The first argument is either the atom increment or decrement or the two tuples {increment, pos_integer()} or {decrement, pos_integer()}. In the case of the former, the operation's amount is 1. Otherwise it is the value provided in the tuple's second element. Actor is any term, and the 3rd argument is the pncounter() to update.

returns the updated pncounter()

update/4

update(Op, Actor, Cntr, Ctx) -> any()

value/1

value(PNCnt::pncounter()) -> integer()

The single, total value of a pncounter()

value/2

value(X1::pncounter_q(), PNCnt::pncounter()) -> integer()

query the parts of a pncounter() valid queries are positive or negative.


Generated by EDoc