Crdt<K, V> class Null safety

Implementers

Constructors

Crdt()

Properties

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

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.
containsKey(K key) bool
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.
get(K key) → V?
Gets a stored value. Returns null if value doesn't exist.
getRecord(K key) Record<V>?
Gets record containing value and HLC.
isDeleted(K key) bool?
Checks if a record is marked as deleted Returns null if record does not exist
merge(Map<K, Record<V>> remoteRecords) → void
Merges two CRDTs and updates record and canonical clocks accordingly. See also mergeJson().
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().
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.
put(K key, V? value) → void
Inserts or updates a value in the CRDT and increments the canonical time.
putAll(Map<K, V?> values) → void
Inserts or updates all values in the CRDT and increments the canonical time accordingly.
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.
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.
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().
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.
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.
toString() String
A string representation of this object.
override
watch({K key}) Stream<MapEntry<K, V?>>
Watch for changes to this CRDT. Use key to monitor a specific key.

Operators

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