hashEntitiesUnordered<T extends DatumEntityInterface> method
An order-independent hash of a set of entities.
Each entity is hashed individually and the digests are XOR-combined, so the result does not depend on iteration order — no sort is required. This is the basis for incremental maintenance via DatumRollingHash: to update the set hash after one write, XOR the changed entity's digest in/out instead of re-hashing everything.
Implementation
String hashEntitiesUnordered<T extends DatumEntityInterface>(List<T> entities) {
final acc = Uint8List(32);
for (final e in entities) {
final d = datumEntityDigest(e.toDatumMap(target: MapTarget.remote));
for (var i = 0; i < 32; i++) {
acc[i] ^= d[i];
}
}
return _hex(acc);
}