remove
Remove key — and return the change: the tags currently on it, retired, and nothing else. Absorbing that patch drops the key; the retired tags stay witnessed, so the removal propagates on merge. To hold the resulting map locally, map.piece(map.remove(…)).
The context carries exactly key's live tags — never the sender's full history. A delta that carried the whole context would be indistinguishable from "I have removed every key I ever saw", and joining it would empty the receiver's map.
Removing a key that is absent yields the lattice identity — an empty store and an empty context — so absorbing it changes nothing.
Samples
val a = ReplicaId("A")
val b = ReplicaId("B")
// Two peers have converged: "team" already holds a long roster, put there by B.
var alpha = ORMap.empty<String, GSet<String>>()
.piece { it.put(b, "team", GSet.of("alice", "bob", "carol", "dan")) }
var bravo = alpha
// A adds one member and puts only the change on the wire. The delta carries A's one name —
// not the merged roster — because the receiver re-does that merge against its own copy.
val hire = alpha.put(a, "team", GSet.of("erin"))
check(hire.delta["team"] == GSet.of("erin"))
// A's tag joins B's rather than replacing it, so the key's value is both writes together.
alpha = alpha.piece(hire)
bravo = bravo.piece(hire)
check(alpha == bravo)
check(alpha["team"] == GSet.of("alice", "bob", "carol", "dan", "erin"))
// A concurrent put beats a concurrent remove: B's put mints a tag A's remove never saw.
val concurrent = alpha.put(b, "team", GSet.of("frank"))
check("team" in alpha.piece(alpha.remove("team")).piece(concurrent).keys)
// A remove lands everywhere, because both peers agree on which tags are live. Had A already
// held a tag on "team" and the delta kept quiet about it, that older tag would still be alive
// on bravo — and "team" would come back from the dead there.
val disband = alpha.remove("team")
alpha = alpha.piece(disband)
bravo = bravo.piece(disband)
check("team" !in alpha.keys)
check("team" !in bravo.keys)Content copied to clipboard