LatticeDotFun

@Serializable(with = LatticeDotFunSerializer::class)
class LatticeDotFun<V : Quilted<V>>(val values: Map<Dot, V> = emptyMap()) : DotStore<LatticeDotFun<V>>

A DotStore mapping each Dot to a value V that is itself a lattice, so a dot's value can keep growing after the dot is minted, and a dot both sides hold keeps the join of the two values.

DotFun is the store for values that never change: a dot names one write, so wherever it appears it carries the same value, and DotFun.join keeps either copy. That premise is what an MV register needs, and a per-element tombstone would break it. The motivating case is a sequence whose elements are dots (#3126): marking an element deleted has to grow its payload in place, under the dot that inserted it, because dropping the dot would orphan whatever was positioned after it. One dot then carries two different values on two replicas, and keeping either copy makes the join depend on which side is this. This store joins them instead, which is the DotFun⟨V⟩ of Almeida, Shoker and Baquero, Delta State Replicated Data Types (arXiv:1603.01529, Fig. 12):

(m, c) ⊔ (m′, c′) = { d ↦ m(d) ⊔ m′(d) | d ∈ dom m ∩ dom m′ }
∪ { (d, v) ∈ m | d ∉ c′ }
∪ { (d, v) ∈ m′ | d ∉ c }

An observed remove beats a concurrent growth. A dot one side holds and the other side has witnessed but no longer holds was removed on purpose, and it is dropped whatever its value grew to meanwhile. A type that wants a removal growth can survive expresses the removal as growth (a deleted flag in the value), not as dropping the dot.

The join is associative, commutative and idempotent over states that satisfy Causal's invariant (every dot in the store is in the context), given that V's own Quilted.piece is.

Serialized by LatticeDotFunSerializer, which emits entries sorted by Dot so the encoding is a function of the logical value and not of merge order — provided V's own serializer is canonical too, since a payload is encoded by it.

Constructors

Link copied to clipboard
constructor(values: Map<Dot, V> = emptyMap())

Properties

Link copied to clipboard
open override val dots: Set<Dot>

Every dot currently live in this store.

Link copied to clipboard
open override val empty: LatticeDotFun<V>

The empty (bottom) store of this shape — no dots.

Link copied to clipboard
open val isBottom: Boolean

True when the store holds no dots.

Link copied to clipboard
val values: Map<Dot, V>

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun join(other: LatticeDotFun<V>, context: DotContext, otherContext: DotContext): LatticeDotFun<V>

The causal join with other. A dot is kept when it is live in both stores, or live in one and not yet witnessed by the other side's context; it is dropped only when one side still has it while the other has it in otherContext but not in its store — the signature of a deliberate remove. context is this store's surrounding causal history; otherContext is the other's.

Link copied to clipboard
open override fun toString(): String