MVRegister

class MVRegister : DeltaCRDT, Iterable<String>

A delta-based CRDT multi-value register.

Values written concurrently in different replicas of a MVRegister are all retained until a write replaces them; accessors return the set of current values. A write (or delete) replaces every visible (local or merged) value.

On merging, a value is kept iff either:

  • it is in both replicas/deltas, or

  • it is in one replica and its associated timestamp is not in the causal context of the other replica.

Its JSON serialization respects the following schema:

{
"type": "MVRegister",
"metadata": VersionVector.toJson(),
"value": [
(( $value, )*( $value ))?
]
}

Constructors

MVRegister
Link copied to clipboard
common
fun MVRegister()
Default constructor creating an empty register.
MVRegister
Link copied to clipboard
common
fun MVRegister(env: Environment)
MVRegister
Link copied to clipboard
common
fun MVRegister(value: String, env: Environment)
Constructs a MVRegister instance initialized with a given value and environment.
MVRegister
Link copied to clipboard
common
fun MVRegister(other: MVRegister)
Copy constructor, discarding associated environment
MVRegister
Link copied to clipboard
common
fun MVRegister(entries: Set<Pair<String, Timestamp>>, causalContext: VersionVector, env: Environment)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

assign
Link copied to clipboard
common
fun assign(value: String): MVRegister
Assigns a value to the register.
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): MVRegister
Return a delta from a given version vector vv to current state.
get
Link copied to clipboard
common
fun get(): Set<String>
Gets the set of values currently stored in the register.
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
iterator
Link copied to clipboard
common
open operator override fun iterator(): Iterator<String>
Gets an iterator containing the values currently stored in the register.
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

causalContext
Link copied to clipboard
common
val causalContext: VersionVector
A version vector summarizing the entries seen by all values.
entries
Link copied to clipboard
common
var entries: MutableSet<Pair<String, Timestamp>>
A mutable set storing the different values with their associated timestamp.