View Source partisan_vclock (partisan v5.0.0-rc.8)

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

Summary

Types

The timestamp is present but not used, in case a client wishes to inspect it.

Functions

Return the list of all nodes that have ever incremented VClock.
Return true if Va is a direct descendant of Vb, else false -- remember, a vclock is its own descendant!
Compares two VClocks for equality.
Create a brand new vclock.
takes the output of to_binary/1 and returns a vclock
Get the counter value in VClock set from Node.
take two vclocks and return a vclock that summerizes only the events both have seen.
Increment VClock at Node.
Combine all VClocks in the input list into their least possible common descendant.
subtract the VClock from the DotList. what this means is that any {actor(), count()} pair in DotList that is <= an entry in VClock is removed from DotList Example [{a, 3}, {b, 2}, {d, 14}, {g, 22}] - [{a, 4}, {b, 1}, {c, 1}, {d, 14}, {e, 5}, {f, 2}] = [{{b, 2}, {g, 22}]
an efficient format for disk / wire. 5 @see from_binary/1

Types

-type binary_vclock() :: binary().
The timestamp is present but not used, in case a client wishes to inspect it.
-type counter() :: integer().
-type vc_entry() :: {vclock_node(), counter()}.
-type vclock() :: [vc_entry()].
-type vclock_node() :: term().

Functions

-spec all_nodes(VClock :: vclock()) -> [vclock_node()].
Return the list of all nodes that have ever incremented VClock.
-spec 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!
-spec dominates(vclock(), vclock()) -> boolean().
-spec equal(VClockA :: vclock(), VClockB :: vclock()) -> boolean().
Compares two VClocks for equality.
-spec fresh() -> vclock().
Create a brand new vclock.
-spec from_binary(binary_vclock()) -> vclock().
takes the output of to_binary/1 and returns a vclock
Link to this function

get_counter(Node, VClock)

View Source
-spec get_counter(Node :: vclock_node(), VClock :: vclock()) -> counter().
Get the counter value in VClock set from Node.
-spec glb(vclock(), vclock()) -> vclock().
take two vclocks and return a vclock that summerizes only the events both have seen.
-spec increment(Node :: vclock_node(), VClock :: vclock()) -> vclock().
Increment VClock at Node.
-spec merge(VClocks :: [vclock()]) -> vclock() | [].
Combine all VClocks in the input list into their least possible common descendant.
Link to this function

subtract_dots(DotList, VClock)

View Source
-spec subtract_dots(vclock(), vclock()) -> vclock().
subtract the VClock from the DotList. what this means is that any {actor(), count()} pair in DotList that is <= an entry in VClock is removed from DotList Example [{a, 3}, {b, 2}, {d, 14}, {g, 22}] - [{a, 4}, {b, 1}, {c, 1}, {d, 14}, {e, 5}, {f, 2}] = [{{b, 2}, {g, 22}]
-spec to_binary(vclock()) -> binary_vclock().
an efficient format for disk / wire. 5 @see from_binary/1