Prepare to fully canonicalize views

This commit is contained in:
2024-05-28 21:38:08 -07:00
parent 93ff83e422
commit f1f4d66678
6 changed files with 20 additions and 15 deletions

View File

@@ -615,10 +615,9 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
// If `val` is set, then this is a point mutation at `latestVersion`.
// Otherwise it's the end of a range mutation at `latestVersion`.
// `finger` becomes the search path of `key`
// `finger` is a valid finger to the insertion path of `key` in the latest
// version (which can be obtained with `search`)
void insert(Key key, std::optional<Val> val, Finger &finger) {
search<std::memory_order_relaxed>(key, latestRoot, latestVersion, finger);
const bool inserted = finger.backNode() == 0;
int64_t pointVersion, rangeVersion;
@@ -878,9 +877,13 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
Finger iter;
switch (m.type) {
case Set: {
search<std::memory_order_relaxed>({m.param1, m.param1Len}, latestRoot,
latestVersion, iter);
insert({m.param1, m.param1Len}, {{m.param2, m.param2Len}}, iter);
} break;
case Clear: {
search<std::memory_order_relaxed>({m.param1, m.param1Len}, latestRoot,
latestVersion, iter);
insert({m.param1, m.param1Len}, {{nullptr, -1}}, iter);
if (m.param2Len > 0) {
move<std::memory_order_relaxed, true>(iter, latestVersion);
@@ -891,6 +894,8 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
}
// TODO reuse finger? It should be one rank away from its insertion
// point
search<std::memory_order_relaxed>({m.param2, m.param2Len}, latestRoot,
latestVersion, iter);
insert({m.param2, m.param2Len}, {}, iter);
}
} break;