MapCrdt<K, V> class Null safety

A CRDT backed by a in-memory map. Useful for testing, or for applications which only require temporary datasets.

Inheritance

Constructors

MapCrdt(dynamic nodeId, [Map<K, Record<V>> seed = const {}])

Properties

canonicalTime Hlc
read-onlyinherited
hashCode int
The hash code for this object.
read-onlyinherited
isEmpty bool
Returns true if CRDT has any non-deleted records.
read-onlyinherited
keys List<K>
read-onlyinherited
length int
Get size of dataset excluding deleted records.
read-onlyinherited
map Map<K, V>
Returns a simple key-value map without HLCs or deleted records. See recordMap.
read-onlyinherited
nodeId → dynamic
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
values List<V>
read-onlyinherited

Methods

clear({bool purge = false}) → void
Marks all records as deleted. Note: by default this doesn't actually delete the records since the deletion needs to be propagated when merging with other CRDTs. Set purge to true to clear the records. Useful for testing or to reset a store.
inherited
containsKey(K key) bool
override
delete(K key) → void
Marks the record as deleted. Note: this doesn't actually delete the record since the deletion needs to be propagated when merging with other CRDTs.
inherited
get(K key) → V?
Gets a stored value. Returns null if value doesn't exist.
inherited
getRecord(K key) Record<V>?
Gets record containing value and HLC.
override
isDeleted(K key) bool?
Checks if a record is marked as deleted Returns null if record does not exist
inherited
merge(Map<K, Record<V>> remoteRecords) → void
Merges two CRDTs and updates record and canonical clocks accordingly. See also mergeJson().
inherited
mergeJson(String json, {KeyDecoder<K>? keyDecoder, ValueDecoder<V>? valueDecoder}) → void
Merges two CRDTs and updates record and canonical clocks accordingly. Use keyDecoder to convert non-string keys. Use valueDecoder to convert non-native value types. See also merge().
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
purge() → void
Clear all records. Records will be removed rather than being marked as deleted. Useful for testing or to reset a store. See also clear.
override
put(K key, V? value) → void
Inserts or updates a value in the CRDT and increments the canonical time.
inherited
putAll(Map<K, V?> values) → void
Inserts or updates all values in the CRDT and increments the canonical time accordingly.
inherited
putRecord(K key, Record<V> value) → void
Stores record without updating the HLC. Meant for subclassing, clients should use put() instead. Make sure to call refreshCanonicalTime() if using this method directly.
override
putRecords(Map<K, Record<V>> recordMap) → void
Stores records without updating the HLC. Meant for subclassing, clients should use putAll() instead. Make sure to call refreshCanonicalTime() if using this method directly.
override
recordMap({Hlc? modifiedSince}) Map<K, Record<V>>
Retrieves CRDT map including HLCs. Useful for merging with other CRDTs. Use modifiedSince to get only the most recently modified records. See also toJson().
override
refreshCanonicalTime() → void
Iterates through the CRDT to find the highest HLC timestamp. Used to seed the Canonical Time. Should be overridden if the implementation can do it more efficiently.
inherited
toJson({Hlc? modifiedSince, KeyEncoder<K>? keyEncoder, ValueEncoder<K, V>? valueEncoder}) String
Outputs the contents of this CRDT in Json format. Use modifiedSince to encode only the most recently modified records. Use keyEncoder to convert non-string keys. Use valueEncoder to convert non-native value types.
inherited
toString() String
A string representation of this object.
inherited
watch({K? key}) Stream<MapEntry<K, V?>>
Watch for changes to this CRDT. Use key to monitor a specific key.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited