ReplicatedList

rdts.datatypes.ReplicatedList
See theReplicatedList companion object
case class ReplicatedList[E](order: Epoch[GrowOnlyList[Dot]], elements: Map[Dot, LastWriterWins[E]], deleted: Dots)

An RGA (Replicated Growable Array) is a Delta CRDT modeling a list.

When two values are concurrently inserted at an index i, the value of the insert operation with the later timestamp will be at index i while the earlier inserted value will be pushed to index i+1. When an element is subject to two concurrent updates, the later update overwrites the earlier update. If an element is concurrently updated and deleted, the element will simply be deleted, ignoring the update.

Note that RGAs are implemented as linked lists, thus the time needed to execute operations toward the end of the list will scale linearly with the size of the list.

To correctly handle concurrent remote inserts next to elements that were deleted locally, the RGA implementation internally keeps deleted elements as hidden tombstones in the list. Since many tombstones will slow down the operations on this data structure, purgeTombstones should be executed periodically to remove tombstones from the list. Note however that this invalidates any concurrent insert operations. Ideally, purgeTombstones should only be called in downtime periods and only by privileged replicas.

This implementation was modeled after the RGA proposed by Roh et al. in "Replicated abstract data types: Building blocks for collaborative applications", see here However, since then the implementation was changed significantly, thus it may be a different or even a novel strategy by now.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Type members

Types

type C = ReplicatedList[E]

Value members

Concrete methods

def append(using LocalUid)(e: E): C
def appendAll(using LocalUid)(elems: Iterable[E]): C
def clear(): C
def delete(i: Int): C
def deleteBy(cond: E => Boolean): C
def findInsertIndex(n: Int): Option[Int]
def findUpdateIndex(n: Int): Option[Int]
def insert(i: Int, e: E)(using LocalUid): C

Inserts at list index i

Inserts at list index i

Attributes

def insertAll(i: Int, elems: Iterable[E])(using LocalUid): C
def prepend(using LocalUid)(e: E): C
def prependAll(using LocalUid)(elems: Iterable[E]): C

Note: this operation may drop concurrent additions to removed items.

Note: this operation may drop concurrent additions to removed items.

Attributes

def read(i: Int): Option[E]
def setAtIndex(i: Int, e: Option[E]): C
def size: Int
def toList: List[E]
def update(i: Int, e: E): C
def updateBy(cond: E => Boolean, e: E): C

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Concrete fields

lazy val observed: Dots