Ratchet

class Ratchet : DeltaCRDT

A delta-based CRDT join semi-lattice ratchet.

A join (or upper) semi-lattice is a partially ordered set endowed with a join operation: for any two elements, the result of the join operation is their greatest upper bound with respect to the partial order.

A Ratchet is a register whose value is the join of all assigned values: when assigning or merging, the retained value is the join of the two values. Note that join is not max: on a partially ordered set, the join of two values is not necessarily one of them.

This is a sample implementation using Strings, with default (total) ordering.

Its JSON serialization respects the following schema:

{
"type": "Ratchet",
"value": $value
}

Constructors

Ratchet
Link copied to clipboard
common
fun Ratchet()
Constructs an empty Ratchet instance.
Ratchet
Link copied to clipboard
common
fun Ratchet(env: Environment)
Constructs an empty Ratchet instance with provided environment.
Ratchet
Link copied to clipboard
common
fun Ratchet(value: String?, env: Environment? = null)
Constructs a Ratchet instance with initial value and environment.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

assign
Link copied to clipboard
common
fun assign(value: String?): Ratchet
Assigns a given value to the ratchet.
equals
Link copied to clipboard
common
open operator fun equals(other: Any?): Boolean
generateDelta
Link copied to clipboard
common
open override fun generateDelta(vv: VersionVector): Ratchet
Return a delta from a given version vector vv to current state.
get
Link copied to clipboard
common
fun get(): String?
Gets the value stored in the ratchet.
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
merge
Link copied to clipboard
common
open override fun merge(delta: DeltaCRDT)
Merge a given delta into this DeltaCRDTThe merge is unidirectional: only the local replica is modified.
toJson
Link copied to clipboard
common
open override fun toJson(): String
Serialize this DeltaCRDT to a JSON string.
toString
Link copied to clipboard
common
open fun toString(): String

Properties

value
Link copied to clipboard
common
var value: String? = null