MapCrdt class

A CRDT backed by a simple in-memory hashmap. Useful for testing, or for applications which only require small, ephemeral datasets. It is incredibly inefficient.

Inheritance

Constructors

MapCrdt(Iterable<String> tables)
Instantiate a MapCrdt object with empty tables.

Properties

canonicalTime Hlc
Represents the latest logical time seen in the stored data.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether this dataset is empty.
no setteroverride
isNotEmpty bool
Whether this dataset has at least one record.
no setteroverride
nodeId String
Get this CRDT's node id
no setterinherited
onTablesChanged Stream<({Hlc hlc, Iterable<String> tables})>
Emits a list of the tables affected by changes in the database and the timestamp at which they happened. Useful for guaranteeing atomic merges across multiple tables.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tables Set<String>
Names of all tables contained in this dataset.
finalinherited

Methods

get(String table, String key) → dynamic
Get a value from the local dataset.
inherited
getChangeset({Iterable<String>? onlyTables, String? onlyNodeId, String? exceptNodeId, Hlc? modifiedOn, Hlc? modifiedAfter}) CrdtChangeset
Get a Changeset using the provided changesetQueries.
inherited
getLastModified({String? onlyNodeId, String? exceptNodeId}) Hlc
Returns the last modified timestamp, optionally filtering for or against a specific node id. Useful to get "modified since" timestamps for synchronization. Returns Hlc.zero if no timestamp is found.
inherited
getMap(String table) Map<String, dynamic>
Get a table map from the local dataset.
inherited
getRecord(String table, String key) Record?
override
getRecords(String table) Map<String, Record>
override
merge(CrdtChangeset changeset) Future<void>
Merge changeset with the local dataset.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDatasetChanged(Iterable<String> affectedTables, Hlc hlc) → void
Notifies listeners and updates the canonical time.
inherited
put(String table, String key, dynamic value, [bool isDeleted = false]) Future<void>
Insert a single value into this dataset.
inherited
putAll(Map<String, Map<String, dynamic>> dataset, [bool isDeleted = false]) Future<void>
Insert multiple values into this dataset.
inherited
putRecords(Map<String, Map<String, Record>> dataset) → void
override
toString() String
A string representation of this object.
inherited
validateChangeset(CrdtChangeset changeset) Hlc
Checks if changeset is valid. This method is intended for implementations and shouldn't generally be called from outside.
inherited
watch(String table, {String? key}) Stream<({bool isDeleted, String key, dynamic value})>
Returns a stream of changes. Use the optional key parameter to filter events or leave it empty to get all changes.
override

Operators

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