LWWMap

class LWWMap : DeltaCRDT

A delta-based CRDT map implementing last writer wins (LWW) policy.

Each entry behaves like a LWWRegister: only the last written value is retained.

When merging, for each key, only the value associated with the greatest timestamp is retained. A deletion is represented as a null value and handled the same way.

Its JSON serialization respects the following schema:

{
"type": "LWWMap",
"metadata": {
"entries": {
// $key is a string
(( "$key": Timestamp.toJson(), )*( "$key": Timestamp.toJson() ))?
}
}
// $key is a string and $value can be Boolean, double, integer or string
( , "$key": "$value" )*
}

Constructors

LWWMap
Link copied to clipboard
common
fun LWWMap()
Default constructor.
LWWMap
Link copied to clipboard
common
fun LWWMap(env: Environment)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

deleteBoolean
Link copied to clipboard
common
fun deleteBoolean(key: String): LWWMap
Removes the specified key / Boolean value pair from this map.
deleteDouble
Link copied to clipboard
common
fun deleteDouble(key: String): LWWMap
Removes the specified key / Double value pair from this map.
deleteInt
Link copied to clipboard
common
fun deleteInt(key: String): LWWMap
Removes the specified key / Int value pair from this map.
deleteString
Link copied to clipboard
common
fun deleteString(key: String): LWWMap
Removes the specified key / String value pair from this map.
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): LWWMap
Return a delta from a given version vector vv to current state.
getBoolean
Link copied to clipboard
common
fun getBoolean(key: String): Boolean?
Get the Boolean value corresponding to a given key, or null if the key is not present in the map.
getDouble
Link copied to clipboard
common
fun getDouble(key: String): Double?
Get the Double value corresponding to a given key, or null if the key is not present in the map.
getInt
Link copied to clipboard
common
fun getInt(key: String): Int?
Get the Int value corresponding to a given key, or null if the key is not present in the map.
getString
Link copied to clipboard
common
fun getString(key: String): String?
Get the String value corresponding to a given key, or null if the key is not present in the map.
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
iteratorBoolean
Link copied to clipboard
common
fun iteratorBoolean(): Iterator<Pair<String, Boolean>>
Gets an iterator over the Boolean values in the map.
iteratorDouble
Link copied to clipboard
common
fun iteratorDouble(): Iterator<Pair<String, Double>>
Gets an iterator over the Double values in the map.
iteratorInt
Link copied to clipboard
common
fun iteratorInt(): Iterator<Pair<String, Int>>
Gets an iterator over the Int values in the map.
iteratorString
Link copied to clipboard
common
fun iteratorString(): Iterator<Pair<String, String>>
Gets an iterator over the String values in the map.
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.
put
Link copied to clipboard
common
fun put(key: String, value: Boolean?): LWWMap
Puts a key / Boolean value pair into the map.
fun put(key: String, value: Double?): LWWMap
Puts a key / Double value pair into the map.
fun put(key: String, value: Int?): LWWMap
Puts a key / Int value pair into the map.
fun put(key: String, value: String?): LWWMap
Puts a key / String value pair into the map.
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