diff --git a/fdbserver/IPager.h b/fdbserver/IPager.h index 31ff36ef88..bc2a0f68f1 100644 --- a/fdbserver/IPager.h +++ b/fdbserver/IPager.h @@ -56,7 +56,7 @@ public: if (userData != nullptr && userDataDestructor != nullptr) { userDataDestructor(userData); } - if(buffer != nullptr) { + if (buffer != nullptr) { VALGRIND_MAKE_MEM_UNDEFINED(buffer, bufferSize); } } diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index b5c1e85dfd..8a919fd190 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -6372,10 +6372,9 @@ public: return result; } - ACTOR static Future> readValuePrefix_impl(KeyValueStoreRedwoodUnversioned* self, - Key key, - int maxLength, - Optional debugID) { + ACTOR static Future> readValue_impl(KeyValueStoreRedwoodUnversioned* self, + Key key, + Optional debugID) { state VersionedBTree::BTreeCursor cur; wait(self->m_tree->initBTreeCursor(&cur, self->m_tree->getLastCommittedVersion())); @@ -6390,23 +6389,25 @@ public: Value v; v.arena().dependsOn(cur.back().page->getArena()); v.contents() = cur.get().value.get(); - if (v.size() > maxLength) { - v.contents() = v.substr(0, maxLength); - } return v; } return Optional(); } + Future> readValue(KeyRef key, Optional debugID = Optional()) override { + return catchError(readValue_impl(this, key, debugID)); + } + Future> readValuePrefix(KeyRef key, int maxLength, Optional debugID = Optional()) override { - return catchError(readValuePrefix_impl(this, key, maxLength, debugID)); - } - - Future> readValue(KeyRef key, Optional debugID = Optional()) override { - return catchError(readValuePrefix_impl(this, key, std::numeric_limits::max(), debugID)); + return catchError(map(readValue_impl(this, key, debugID), [maxLength](Optional v) { + if (v.present() && v.get().size() > maxLength) { + v.get().contents() = v.get().substr(0, maxLength); + } + return v; + })); } ~KeyValueStoreRedwoodUnversioned() override{};