DatumRollingHash class
An incrementally maintainable set hash for change/drift detection.
Maintains a 256-bit XOR accumulator of per-entity digests. Because XOR is its own inverse, add and remove are O(1): the engine can keep this in sync as entities are created/updated/deleted instead of re-hashing the whole dataset each sync cycle (which DatumHashGenerator.hashEntities does in O(n)).
final rolling = DatumRollingHash()..addAll(entities);
// on update: swap the old snapshot for the new one
rolling..removeMap(oldMap)..addMap(newMap);
final digest = rolling.value; // compare against the remote's value
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether no entities are currently folded in (accumulator is all-zero).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → String
-
The current 64-character hex digest of the set.
no setter
Methods
-
add(
DatumEntityInterface entity) → void - Folds an entity into the accumulator.
-
addAll(
Iterable< DatumEntityInterface> entities) → void -
Folds all
entitiesinto the accumulator. -
addMap(
Map< String, dynamic> map) → void - Folds a pre-serialized entity map into the accumulator.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
DatumEntityInterface entity) → void - Removes an entity from the accumulator (XOR is self-inverse).
-
removeMap(
Map< String, dynamic> map) → void - Removes a pre-serialized entity map from the accumulator.
-
reset(
) → void - Resets the accumulator to empty.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited