RGA

class RGA : DeltaCRDT, Iterable<String>

A delta-based CRDT Replicated Growable Array (RGA).

Array nodes can be inserted and removed concurrently. When inserted, a node is linked ("anchored") to its precedent node. The tree thus formed is flattened to an array by depth-first search, ordering siblings by decreasing insertion timestamp. A node is removed by replacing it with a tombstone: a special empty node with the same uid still used as an anchor for previously inserted nodes.

When merging, a remove-wins policy is applied: all nodes are retained except those hidden by a tombstone.

Its JSON serialization respects the following schema:

{
"type": "RGA",
"metadata": [
({
( "atom": $value, )? // If atom is present removed should be true.
"anchor": RGAUId.toJson(),
"uid": RGAUId.toJson(),
"ts": Timestamp.toJson(),
"removed" : ( true | false )
})
],
"value": [
// Contains only values for which the corresponding metadata nodes have no atom field.
(( $value, )*( $value ))?
]
}

Constructors

RGA
Link copied to clipboard
common
fun RGA()
Default constructor.
RGA
Link copied to clipboard
common
fun RGA(env: Environment)
RGA
Link copied to clipboard
common
fun RGA(nodes: List<RGANode>, env: Environment)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

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): RGA
Return a delta from a given version vector vv to current state.
get
Link copied to clipboard
common
fun get(): List<String>
Returns a List containing all elements.
fun get(index: Int): String
Returns the element at the specified index in the RGA.
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
insertAt
Link copied to clipboard
common
fun insertAt(index: Int, atom: String): RGA
Inserts an atom into the RGA at the specified index.
iterator
Link copied to clipboard
common
open operator override fun iterator(): Iterator<String>
Returns an iterator over the elements of this RGA.
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.
removeAt
Link copied to clipboard
common
fun removeAt(index: Int): RGA
Removes an element at the specified index from the RGA.
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

nodes
Link copied to clipboard
common
val nodes: ArrayList<RGANode>
An array list storing the different elements.