LWWMap
このコンテンツはまだ日本語訳がありません。
Defined in: src/crdt/LWWMap.ts:46
Conflict-free Replicated Data Type — a value that converges under
replication without coordination. Every implementation is a
state-based CvRDT: replicas exchange full state, and merge
forms a join-semilattice.
Three properties every implementation must satisfy — tests/unit/crdt
verifies them by hand-rolled property tests against generated samples:
- Idempotent:
merge(a, a) === a - Commutative:
merge(a, b) === merge(b, a) - Associative:
merge(merge(a, b), c) === merge(a, merge(b, c))
Together these mean: gossip can deliver state updates in any order, deduplicate, retransmit, and the world converges as long as every replica eventually sees every state.
Why state-based and not delta-state. Delta-CRDTs ship only the incremental change rather than the full state — much cheaper on the wire, but the implementation has more moving parts and you need delta acknowledgement protocols. State-based is the simplest thing that converges; we ship it first and revisit if payload size hurts.
Type Parameters
Section titled “Type Parameters”K
The concrete CRDT type. F-bounded so subclass
merge keeps the right return type without casting at every call
site.
V
Implements
Section titled “Implements”Crdt<LWWMap<K,V>>
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get size():
number
Defined in: src/crdt/LWWMap.ts:128
Number of currently-live keys (tombstones excluded).
Returns
Section titled “Returns”number
Methods
Section titled “Methods”entriesArray()
Section titled “entriesArray()”entriesArray(): readonly readonly [
K,V][]
Defined in: src/crdt/LWWMap.ts:118
Snapshot of currently-live [key, value] pairs.
Returns
Section titled “Returns”readonly readonly [K, V][]
equals()
Section titled “equals()”equals(
other):boolean
Defined in: src/crdt/LWWMap.ts:186
Parameters
Section titled “Parameters”LWWMap<K, V>
Returns
Section titled “Returns”boolean
get(
key):V|undefined
Defined in: src/crdt/LWWMap.ts:97
Read key — undefined for missing keys or tombstones.
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”V | undefined
has(
key):boolean
Defined in: src/crdt/LWWMap.ts:106
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”boolean
keys()
Section titled “keys()”keys(): readonly
K[]
Defined in: src/crdt/LWWMap.ts:109
Snapshot of currently-live keys (tombstones excluded).
Returns
Section titled “Returns”readonly K[]
merge()
Section titled “merge()”merge(
other):LWWMap<K,V>
Defined in: src/crdt/LWWMap.ts:134
Join two replicas. Must be a join-semilattice operation: total, idempotent, commutative, associative.
Parameters
Section titled “Parameters”LWWMap<K, V>
Returns
Section titled “Returns”LWWMap<K, V>
Implementation of
Section titled “Implementation of”put(
replica,key,value,timestamp?):LWWMap<K,V>
Defined in: src/crdt/LWWMap.ts:68
Set key to value on behalf of replica, stamped at timestamp.
Parameters
Section titled “Parameters”replica
Section titled “replica”string
K
V
timestamp?
Section titled “timestamp?”number = ...
Returns
Section titled “Returns”LWWMap<K, V>
remove()
Section titled “remove()”remove(
replica,key,timestamp?):LWWMap<K,V>
Defined in: src/crdt/LWWMap.ts:83
Tombstone key on behalf of replica. Internally an assign
with a null value at the given timestamp — older values are
displaced; concurrent values with newer timestamps still win.
Parameters
Section titled “Parameters”replica
Section titled “replica”string
K
timestamp?
Section titled “timestamp?”number = ...
Returns
Section titled “Returns”LWWMap<K, V>
toJSON()
Section titled “toJSON()”toJSON():
LWWMapJson<V>
Defined in: src/crdt/LWWMap.ts:147
Wire-friendly representation — every CRDT must be JSON-encodable
so it can travel through the cluster transport without bespoke
codecs. toJSON() is the inverse of the static fromJSON
factory each impl exposes.
Returns
Section titled “Returns”LWWMapJson<V>
Implementation of
Section titled “Implementation of”empty()
Section titled “empty()”
staticempty<K,V>(options?):LWWMap<K,V>
Defined in: src/crdt/LWWMap.ts:60
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”options?
Section titled “options?”LWWMapOptions<K> = {}
Returns
Section titled “Returns”LWWMap<K, V>
fromJSON()
Section titled “fromJSON()”
staticfromJSON<K,V>(json,options?):LWWMap<K,V>
Defined in: src/crdt/LWWMap.ts:163
Type Parameters
Section titled “Type Parameters”K
V
Parameters
Section titled “Parameters”LWWMapJson<V>
options?
Section titled “options?”LWWMapOptions<K> = {}
Returns
Section titled “Returns”LWWMap<K, V>
