Require non-adjacent mutations

This should make it so that mutations can only be adjacent if they're at
different versions
This commit is contained in:
2024-05-09 16:59:19 -07:00
parent 7efd68f084
commit b89b7b7f8e

View File

@@ -66,7 +66,7 @@ struct VersionedMap {
MutationType type; MutationType type;
}; };
/** Mutations must be sorted and non-overlapping. `version` /** Mutations must be sorted, non-overlapping, and non-adjacent. `version`
* must be strictly increasing. Postcondition: `getVersion()` == `version` */ * must be strictly increasing. Postcondition: `getVersion()` == `version` */
void addMutations(const Mutation *mutations, int numMutations, void addMutations(const Mutation *mutations, int numMutations,
int64_t version); int64_t version);
@@ -86,14 +86,15 @@ struct VersionedMap {
/** The version of the most recent call to `setOldestVersion`. */ /** The version of the most recent call to `setOldestVersion`. */
int64_t getOldestVersion() const; int64_t getOldestVersion() const;
/** Iterates through a partially canonicalized[1] view of all the mutations /** Iterates through a canonicalized[1] view of all the mutations
* from `oldestVersion` to the iterator's version. There may be mutations from * from `oldestVersion` to the iterator's version. There may be mutations from
* versions < `oldestVersion`, but they won't affect the result. It's * versions < `oldestVersion`, but they won't affect the result. It's
* thread-safe to operate on an iterator concurrently with any method of * thread-safe to operate on an iterator concurrently with any method of
* `VersionedMap`, as long as it's not invalidated by `setOldestVersion`. * `VersionedMap`, as long as it's not invalidated by `setOldestVersion`.
* @warning must not outlive its `VersionedMap`. * @warning must not outlive its `VersionedMap`.
* *
* [1]: Mutations are sorted and non-overlapping, but may be adjacent. * [1]: Mutations at different versions may be adjacent. This is necessary for
* precisely tracking at what version the mutations take effect.
*/ */
struct Iterator { struct Iterator {