Module vclock

A simple Erlang implementation of vector clocks as inspired by Lamport logical clocks.

References

Description

A simple Erlang implementation of vector clocks as inspired by Lamport logical clocks.

Data Types

counter()

counter() = integer()

dot()

dot() = {vclock_node(), {counter(), timestamp()}}

pure_dot()

pure_dot() = {vclock_node(), counter()}

timestamp()

timestamp() = integer()

vclock()

vclock() = [dot()]

vclock_node()

vclock_node() = term()

Function Index

all_nodes/1Return the list of all nodes that have ever incremented VClock.
descends/2Return true if Va is a direct descendant of Vb, else false -- remember, a vclock is its own descendant!
descends_dot/2does the given vclock() descend from the given dot().
dominates/2true if A strictly dominates B.
equal/2Compares two VClocks for equality.
fresh/0Create a brand new vclock.
fresh/2
get_counter/2Get the counter value in VClock set from Node.
get_dot/2Get the entry dot() for vclock_node() from vclock().
get_timestamp/2Get the timestamp value in a VClock set from Node.
increment/2Increment VClock at Node.
increment/3Increment VClock at Node.
merge/1Combine all VClocks in the input list into their least possible common descendant.
prune/3Possibly shrink the size of a vclock, depending on current age and size.
pure_dot/1in some cases the dot without timestamp data is needed.
timestamp/0Return a timestamp for a vector clock.
valid_dot/1is the given argument a valid dot, or entry?.

Function Details

all_nodes/1

all_nodes(VClock::vclock()) -> [vclock_node()]

Return the list of all nodes that have ever incremented VClock.

descends/2

descends(Va::vclock(), Vb::vclock()) -> boolean()

Return true if Va is a direct descendant of Vb, else false -- remember, a vclock is its own descendant!

descends_dot/2

descends_dot(Vclock::vclock(), Dot::dot()) -> boolean()

does the given vclock() descend from the given dot(). The dot() can be any vclock entry returned from get_entry/2. returns true if the vclock() has an entry for the actor in the dot(), and that the counter for that entry is at least that of the given dot(). False otherwise. Call with a valid entry or you'll get an error.

See also: descends/2, dominates/2, get_entry/3.

dominates/2

dominates(A::vclock(), B::vclock()) -> boolean()

true if A strictly dominates B. Note: ignores timestamps. In Riak it is possible to have vclocks that are identical except for timestamps. When two vclocks descend each other, but are not equal, they are concurrent. See source comment for more details. (Actually you can have indentical clocks including timestamps, that represent different events, but let's not go there.)

equal/2

equal(VClockA::vclock(), VClockB::vclock()) -> boolean()

Compares two VClocks for equality.

fresh/0

fresh() -> vclock()

Create a brand new vclock.

fresh/2

fresh(Node::vclock_node(), Count::counter()) -> vclock()

get_counter/2

get_counter(Node::vclock_node(), VClock::vclock()) -> counter()

Get the counter value in VClock set from Node.

get_dot/2

get_dot(Node::vclock_node(), VClock::vclock()) -> {ok, dot()} | undefined

Get the entry dot() for vclock_node() from vclock().

get_timestamp/2

get_timestamp(Node::vclock_node(), VClock::vclock()) -> timestamp() | undefined

Get the timestamp value in a VClock set from Node.

increment/2

increment(Node::vclock_node(), VClock::vclock()) -> vclock()

Increment VClock at Node.

increment/3

increment(Node::vclock_node(), IncTs::timestamp(), VClock::vclock()) -> vclock()

Increment VClock at Node.

merge/1

merge(VClocks::[vclock()]) -> vclock()

Combine all VClocks in the input list into their least possible common descendant.

prune/3

prune(V::vclock(), Now::integer(), BucketProps::term()) -> vclock()

Possibly shrink the size of a vclock, depending on current age and size.

pure_dot/1

pure_dot(X1::dot()) -> pure_dot()

in some cases the dot without timestamp data is needed.

timestamp/0

timestamp() -> timestamp()

Return a timestamp for a vector clock

valid_dot/1

valid_dot(X1::dot()) -> boolean()

is the given argument a valid dot, or entry?


Generated by EDoc