final class ORSet[A] extends OpCrdt[DeltaOp]
Implements a 'Observed Remove Set' operation based CRDT, also called a 'OR-Set'. Elements can be added and removed any number of times. Concurrent add wins over remove.
It is not implemented as in the paper A comprehensive study of Convergent and Commutative Replicated Data Types. This is more space efficient and doesn't accumulate garbage for removed elements. It is described in the paper An optimized conflict-free replicated set The implementation is inspired by the Riak DT riak_dt_orswot.
The ORSet has a version vector that is incremented when an element is added to
the set. The DC -> count
pair for that increment is stored against the
element as its "birth dot". Every time the element is re-added to the set,
its "birth dot" is updated to that of the DC -> count
version vector entry
resulting from the add. When an element is removed, we simply drop it, no tombstones.
When an element exists in replica A and not replica B, is it because A added
it and B has not yet seen that, or that B removed it and A has not yet seen that?
In this implementation we compare the dot
of the present element to the version vector
in the Set it is absent from. If the element dot is not "seen" by the Set version vector,
that means the other set has yet to see this add, and the item is in the merged
Set. If the Set version vector dominates the dot, that means the other Set has removed this
element already, and the item is not in the merged Set.
This class is immutable, i.e. "modifying" methods return a new instance.
- Source
- ORSet.scala
- Alphabetic
- By Inheritance
- ORSet
- OpCrdt
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(element: A): DeltaOp
Adds an element to the set
- def -(element: A): DeltaOp
Removes an element from the set.
- def ->[B](y: B): (ORSet[A], B)
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def add(element: A): DeltaOp
Adds an element to the set
- def addAll(elems: Set[A]): DeltaOp
Scala API: Add several elements to the set.
Scala API: Add several elements to the set.
elems
must not be empty. - def addAll(elems: Set[A]): DeltaOp
Java API: Add several elements to the set.
Java API: Add several elements to the set.
elems
must not be empty. - def applyOperation(thatDelta: DeltaOp): ORSet[A]
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clear(): DeltaOp
Removes all elements from the set, but keeps the history.
Removes all elements from the set, but keeps the history. This has the same result as using #remove for each element, but it is more efficient.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def contains(a: A): Boolean
- def elements: Set[A]
Scala API
- def ensuring(cond: (ORSet[A]) => Boolean, msg: => Any): ORSet[A]
- def ensuring(cond: (ORSet[A]) => Boolean): ORSet[A]
- def ensuring(cond: Boolean, msg: => Any): ORSet[A]
- def ensuring(cond: Boolean): ORSet[A]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(o: Any): Boolean
- Definition Classes
- ORSet → AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def getElements(): Set[A]
Java API
- def hashCode(): Int
- Definition Classes
- ORSet → AnyRef → Any
- def isEmpty: Boolean
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- val originReplica: String
- def remove(element: A): DeltaOp
Removes an element from the set.
- def removeAll(elems: Set[A]): DeltaOp
Scala API: Remove several elements from the set.
Scala API: Remove several elements from the set.
elems
must not be empty. - def removeAll(elems: Set[A]): DeltaOp
Java API: Remove several elements from the set.
Java API: Remove several elements from the set.
elems
must not be empty. - def size: Int
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- ORSet → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Shadowed Implicit Value Members
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from ORSet[A] toany2stringadd[ORSet[A]] performed by method any2stringadd in scala.Predef.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(oRSet: any2stringadd[ORSet[A]]).+(other)
- Definition Classes
- any2stringadd
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ORSet[A] toStringFormat[ORSet[A]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (ORSet[A], B)
- Implicit
- This member is added by an implicit conversion from ORSet[A] toArrowAssoc[ORSet[A]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.