From 9e90d5aadfa9d86c79e9a2f95230562c0af2a38d Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 3 Jun 2024 13:26:27 -0700 Subject: [PATCH] Use more conventional field order in Mutation --- ApiTest.cpp | 4 ++-- Bench.cpp | 4 ++-- FacadeFuzz.cpp | 6 +++--- FacadeTest.cpp | 6 +++--- FdbVersionedMap.cpp | 2 +- VersionedMap.cpp | 16 ++++++++-------- include/VersionedMap.h | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ApiTest.cpp b/ApiTest.cpp index 2123aad..a846ece 100644 --- a/ApiTest.cpp +++ b/ApiTest.cpp @@ -17,9 +17,9 @@ void setAndClearPrev() { const int64_t k = __builtin_bswap64(version); const int64_t zero = __builtin_bswap64(0); weaselab::VersionedMap::Mutation m[] = { - {(const uint8_t *)&zero, (const uint8_t *)&k, 8, 8, + {(const uint8_t *)&zero, 8, (const uint8_t *)&k, 8, weaselab::VersionedMap::Clear}, - {(const uint8_t *)&k, (const uint8_t *)&k, 8, 8, + {(const uint8_t *)&k, 8, (const uint8_t *)&k, 8, weaselab::VersionedMap::Set}, }; versionedMap.addMutations(m, sizeof(m) / sizeof(m[0]), version); diff --git a/Bench.cpp b/Bench.cpp index b27af67..b4e9002 100644 --- a/Bench.cpp +++ b/Bench.cpp @@ -14,9 +14,9 @@ void monotonicallyIncreasing() { const int64_t remove = __builtin_bswap64(facade.getVersion() - kWindow); const int64_t next = __builtin_bswap64(facade.getVersion()); weaselab::VersionedMap::Mutation mutations[] = { - {(const uint8_t *)&remove, nullptr, 8, 0, + {(const uint8_t *)&remove, 8, nullptr, 0, weaselab::VersionedMap::Clear}, - {(const uint8_t *)&next, (const uint8_t *)&next, 8, 8, + {(const uint8_t *)&next, 8, (const uint8_t *)&next, 8, weaselab::VersionedMap::Set}, }; facade.addMutations(mutations, sizeof(mutations) / sizeof(mutations[0]), diff --git a/FacadeFuzz.cpp b/FacadeFuzz.cpp index a98f8fb..1d9cab4 100644 --- a/FacadeFuzz.cpp +++ b/FacadeFuzz.cpp @@ -164,20 +164,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case 0: { // Point write auto val = randomKey(arena); - mutations.push_back({keys[i].p, val.p, keys[i].len, val.len, + mutations.push_back({keys[i].p, keys[i].len, val.p, val.len, weaselab::VersionedMap::Set}); ++i; } break; case 1: { // Point clear - mutations.push_back({keys[i].p, nullptr, keys[i].len, 0, + mutations.push_back({keys[i].p, keys[i].len, nullptr, 0, weaselab::VersionedMap::Clear}); ++i; } break; case 2: { // Range clear if (i + 1 < int(keys.size())) { - mutations.push_back({keys[i].p, keys[i + 1].p, keys[i].len, + mutations.push_back({keys[i].p, keys[i].len, keys[i + 1].p, keys[i + 1].len, weaselab::VersionedMap::Clear}); i += 2; diff --git a/FacadeTest.cpp b/FacadeTest.cpp index e260dbd..0eb89e3 100644 --- a/FacadeTest.cpp +++ b/FacadeTest.cpp @@ -13,16 +13,16 @@ inline String operator"" _s(const char *str, size_t size) { weaselab::VersionedMap::Mutation set(weaselab::VersionedMap::Key k, weaselab::VersionedMap::Key v) { - return {k.p, v.p, k.len, v.len, weaselab::VersionedMap::Set}; + return {k.p, k.len, v.p, v.len, weaselab::VersionedMap::Set}; } weaselab::VersionedMap::Mutation clear(weaselab::VersionedMap::Key k) { - return {k.p, nullptr, k.len, 0, weaselab::VersionedMap::Clear}; + return {k.p, k.len, nullptr, 0, weaselab::VersionedMap::Clear}; } weaselab::VersionedMap::Mutation clear(weaselab::VersionedMap::Key begin, weaselab::VersionedMap::Key end) { - return {begin.p, end.p, begin.len, end.len, weaselab::VersionedMap::Clear}; + return {begin.p, begin.len, end.p, end.len, weaselab::VersionedMap::Clear}; } void breakpoint_me() {} diff --git a/FdbVersionedMap.cpp b/FdbVersionedMap.cpp index 15b30ad..9a224c1 100644 --- a/FdbVersionedMap.cpp +++ b/FdbVersionedMap.cpp @@ -1235,7 +1235,7 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl { } verUpdateRef.mutations.push_back( - Mutation{param1.p, param2.p, param1.len, param2.len, m.type}); + Mutation{param1.p, param1.len, param2.p, param2.len, m.type}); } } diff --git a/VersionedMap.cpp b/VersionedMap.cpp index a58a822..38fa53a 100644 --- a/VersionedMap.cpp +++ b/VersionedMap.cpp @@ -1488,26 +1488,26 @@ int main() { printf("Bytes: %" PRId64 "\n", versionedMap.getBytes()); { weaselab::VersionedMap::Mutation m[] = { - {(const uint8_t *)"a", nullptr, 1, 0, weaselab::VersionedMap::Set}, - {(const uint8_t *)"b", nullptr, 1, 0, weaselab::VersionedMap::Set}, - {(const uint8_t *)"c", nullptr, 1, 0, weaselab::VersionedMap::Set}, - {(const uint8_t *)"d", nullptr, 1, 0, weaselab::VersionedMap::Set}, - {(const uint8_t *)"e", nullptr, 1, 0, weaselab::VersionedMap::Set}, - {(const uint8_t *)"f", nullptr, 1, 0, weaselab::VersionedMap::Set}, + {(const uint8_t *)"a", 1, nullptr, 0, weaselab::VersionedMap::Set}, + {(const uint8_t *)"b", 1, nullptr, 0, weaselab::VersionedMap::Set}, + {(const uint8_t *)"c", 1, nullptr, 0, weaselab::VersionedMap::Set}, + {(const uint8_t *)"d", 1, nullptr, 0, weaselab::VersionedMap::Set}, + {(const uint8_t *)"e", 1, nullptr, 0, weaselab::VersionedMap::Set}, + {(const uint8_t *)"f", 1, nullptr, 0, weaselab::VersionedMap::Set}, }; versionedMap.addMutations(m, sizeof(m) / sizeof(m[0]), 1); } printf("Bytes: %" PRId64 "\n", versionedMap.getBytes()); { weaselab::VersionedMap::Mutation m[] = { - {(const uint8_t *)"a", (const uint8_t *)"d", 1, 1, + {(const uint8_t *)"a", 1, (const uint8_t *)"d", 1, weaselab::VersionedMap::Clear}, }; versionedMap.addMutations(m, sizeof(m) / sizeof(m[0]), 2); } { weaselab::VersionedMap::Mutation m[] = { - {(const uint8_t *)"b", (const uint8_t *)"", 1, 0, + {(const uint8_t *)"b", 1, (const uint8_t *)"", 0, weaselab::VersionedMap::Clear}, }; versionedMap.addMutations(m, sizeof(m) / sizeof(m[0]), 3); diff --git a/include/VersionedMap.h b/include/VersionedMap.h index 4a9d70e..0175984 100644 --- a/include/VersionedMap.h +++ b/include/VersionedMap.h @@ -60,8 +60,8 @@ struct __attribute__((__visibility__("default"))) VersionedMap { /** Mutations are bitwise-lexicographically ordered by param1. */ struct Mutation { const uint8_t *param1; - const uint8_t *param2; int param1Len; + const uint8_t *param2; int param2Len; MutationType type; };