DVV

public struct DVV : Equatable
extension DVV: CustomStringConvertible

A dotted version vector. The dot represents a server-side counter that is incremented at every write/store/put action.

  • vv

    The collection of counters that define the version history for key

    Declaration

    Swift

    internal let vv: DotVector
  • dot

    The server/replica counter

    Declaration

    Swift

    internal let dot: Dot?
  • Construct new instance with the given (default) values.

    Declaration

    Swift

    init(vv: DotVector = [], dot: Dot? = nil)

    Parameters

    vv

    the version vector to initialize with (default is empty array)

    dot

    the server counter to use (default is nil)

  • Declaration

    Swift

    public var description: String { get }
  • Obtain a new DVV with the given key incremented by 1

    Declaration

    Swift

    public func increment(key: String) -> DVV

    Parameters

    key

    the key to increment

    Return Value

    new DVV instance

  • Merge the existing dot into the version vector and acquire a new Dot.

    Declaration

    Swift

    public func merge(dot: Dot) -> DVV

    Parameters

    dot

    the Dot to use in the new DVV

    Return Value

    new DVV instance

  • Obtain the counter for a given key. Looks first in the dot and then in the version vector.

    Declaration

    Swift

    public func counter(of key: String) -> UInt64

    Parameters

    key

    the key to fetch

    Return Value

    the counter value

  • Determine if this DVV descends from another. Note that this is true when rhs is nil.

    Declaration

    Swift

    public func descends(_ rhs: DVV?) -> Bool

    Parameters

    rhs

    the DVV to check against

    Return Value

    true if this instance descends from or is equal to rhs

  • Determine if this DVV strictly descends from another, where strictly means the two instances cannot be equal. Note that this is true when rhs is nil.

    Declaration

    Swift

    public func descendsStrictly(_ rhs: DVV?) -> Bool

    Parameters

    rhs

    the DVV to check against.

    Return Value

    true if this instance descends from rhs

Internal Implementation Methods

  • Obtain a DotVector containing the merge of the version vector and the dot

    Declaration

    Swift

    internal func mergeDot() -> DotVector

    Return Value

    new DotVector

  • Obtain a new Dot instance containing the counter of the given key

    Declaration

    Swift

    internal func dot(of key: String) -> Dot

    Parameters

    key

    the key to use

    Return Value

    the new Dot instance

DVV transformations and reductions

  • Obtain a clock that is newer than the client and server clocks at the given key counter.

    Declaration

    Swift

    public static func update(client: DVV?, server: DVV?, key: String) -> DVV

    Parameters

    client

    the version vector from a client

    server

    the version vector from a server

    key

    the server key

    Return Value

    new DVV

  • Obtain a clock that is newer than the client and server clocks at the given key counter.

    Declaration

    Swift

    public static func update(client: [DVV], server: [DVV], key: String) -> DVV

    Parameters

    client

    one or more version vectors from a client

    server

    one or more version vectors from a server

    key

    the server key

    Return Value

    new DVV

  • Merges a collection of clocks into a new DVV, removing redundant information (old entries).

    Declaration

    Swift

    public static func merge(_ dvvs: [DVV]) -> DVV

    Parameters

    dvvs

    collection of DVV instances to merge

    Return Value

    new DVV

  • Takes two clock sets and returns a set of concurrent clocks, each belonging to one of the sets, and that together cover both sets while discarding obsolete knowledge.

    Declaration

    Swift

    public static func sync(_ lhs: [DVV], _ rhs: [DVV]) -> [DVV]

    Parameters

    lhs

    collection of DVV instances to sync

    rhs

    collection of DVV instances to sync

    Return Value

    new DVV collection that represents the two input collections