From fd618d0f075093bb75171a0ec6880b4c6d48d803 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 3 Jun 2024 12:56:17 -0700 Subject: [PATCH] Bug fix The bottommost node of a finger isn't necessarily the root for an iterator's version. It could be "end" --- VersionedMap.cpp | 10 +--------- include/VersionedMap.h | 3 +-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/VersionedMap.cpp b/VersionedMap.cpp index 290e79e..a58a822 100644 --- a/VersionedMap.cpp +++ b/VersionedMap.cpp @@ -406,10 +406,6 @@ struct Finger { assert(searchPathSize_ > 0); --searchPathSize_; } - uint32_t root() const { - assert(searchPathSize_ > 0); - return searchPath[0]; - } uint32_t backNode() const { assert(searchPathSize_ > 0); return searchPath[searchPathSize_ - 1]; @@ -1241,18 +1237,14 @@ void VersionedMap::Impl::firstGeq(const weaselab::VersionedMap::Key *key, weaselab::VersionedMap::Iterator *iterator; void begin(RootSet::ThreadSafeHandle handle) { - uint32_t root; if (iterator->impl != nullptr) { - root = iterator->impl->version == version - ? iterator->impl->finger.root() - : handle.rootForVersion(version); iterator->impl->~Impl(); new (iterator->impl) Iterator::Impl(); } else { - root = handle.rootForVersion(version); iterator->impl = new (safe_malloc(sizeof(Iterator::Impl))) Iterator::Impl(); } + uint32_t root = handle.rootForVersion(version); Finger &finger = iterator->impl->finger; finger.clear(); bool ignored = false; diff --git a/include/VersionedMap.h b/include/VersionedMap.h index df1aa73..4a9d70e 100644 --- a/include/VersionedMap.h +++ b/include/VersionedMap.h @@ -152,8 +152,7 @@ struct __attribute__((__visibility__("default"))) VersionedMap { * and <= `getVersion()`. * * Thread-safe as long as a version is not concurrently invalidated by - * `setOldestVersion`. There's a performance benefit if you pass iterator[i] - * previously obtained at version[i]. */ + * `setOldestVersion`. */ void firstGeq(const Key *key, const int64_t *version, Iterator *iterator, int count) const;