The bottommost node of a finger isn't necessarily the root for an
iterator's version. It could be "end"
This commit is contained in:
2024-06-03 12:56:17 -07:00
parent f5fdc3eaf1
commit fd618d0f07
2 changed files with 2 additions and 11 deletions

View File

@@ -406,10 +406,6 @@ struct Finger {
assert(searchPathSize_ > 0); assert(searchPathSize_ > 0);
--searchPathSize_; --searchPathSize_;
} }
uint32_t root() const {
assert(searchPathSize_ > 0);
return searchPath[0];
}
uint32_t backNode() const { uint32_t backNode() const {
assert(searchPathSize_ > 0); assert(searchPathSize_ > 0);
return searchPath[searchPathSize_ - 1]; return searchPath[searchPathSize_ - 1];
@@ -1241,18 +1237,14 @@ void VersionedMap::Impl::firstGeq(const weaselab::VersionedMap::Key *key,
weaselab::VersionedMap::Iterator *iterator; weaselab::VersionedMap::Iterator *iterator;
void begin(RootSet::ThreadSafeHandle handle) { void begin(RootSet::ThreadSafeHandle handle) {
uint32_t root;
if (iterator->impl != nullptr) { if (iterator->impl != nullptr) {
root = iterator->impl->version == version
? iterator->impl->finger.root()
: handle.rootForVersion(version);
iterator->impl->~Impl(); iterator->impl->~Impl();
new (iterator->impl) Iterator::Impl(); new (iterator->impl) Iterator::Impl();
} else { } else {
root = handle.rootForVersion(version);
iterator->impl = iterator->impl =
new (safe_malloc(sizeof(Iterator::Impl))) Iterator::Impl(); new (safe_malloc(sizeof(Iterator::Impl))) Iterator::Impl();
} }
uint32_t root = handle.rootForVersion(version);
Finger &finger = iterator->impl->finger; Finger &finger = iterator->impl->finger;
finger.clear(); finger.clear();
bool ignored = false; bool ignored = false;

View File

@@ -152,8 +152,7 @@ struct __attribute__((__visibility__("default"))) VersionedMap {
* and <= `getVersion()`. * and <= `getVersion()`.
* *
* Thread-safe as long as a version is not concurrently invalidated by * Thread-safe as long as a version is not concurrently invalidated by
* `setOldestVersion`. There's a performance benefit if you pass iterator[i] * `setOldestVersion`. */
* previously obtained at version[i]. */
void firstGeq(const Key *key, const int64_t *version, Iterator *iterator, void firstGeq(const Key *key, const int64_t *version, Iterator *iterator,
int count) const; int count) const;