MapCrdt<K, V> class
A CRDT backed by a in-memory map. Useful for testing, or for applications which only require temporary datasets.
Properties
- canonicalTime → Hlc
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Returns
true
if CRDT has any non-deleted records.no setterinherited -
keys
→ List<
K> -
no setterinherited
- length → int
-
Get size of dataset excluding deleted records.
no setterinherited
-
map
→ Map<
K, V?> -
Returns a simple key-value map without HLCs or deleted records.
See recordMap.
no setterinherited
- nodeId → dynamic
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ List<
V?> -
no setterinherited
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< remoteRecords) → voidV> > -
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. UsevalueDecoder
to convert non-native value types. See also merge().inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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< recordMap) → voidV> > -
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. UsekeyEncoder
to convert non-string keys. UsevalueEncoder
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