needs_update_all = false;
version = current_version;
+ p_node_base = ref_leaf_node->read();
key_view = _key_view;
p_value_header = _p_value_header;
-
- auto p_node_base = ref_leaf_node->read();
- assert((const char*)_p_value_header > p_node_base);
- offset_value_header = (const char*)_p_value_header - p_node_base;
- assert(offset_value_header < NODE_BLOCK_SIZE);
+ assert((const char*)p_value_header > p_node_base);
+ assert((const char*)p_value_header - p_node_base < NODE_BLOCK_SIZE);
value_payload_mut.reset();
p_value_recorder = nullptr;
{
assert(version.layout == current_version.layout);
if (!version.is_duplicate && current_version.is_duplicate) {
- assert(p_value_header);
- auto _p_value_header = reinterpret_cast<const value_header_t*>(
- ref_leaf_node->read() + offset_value_header);
- assert(_p_value_header != p_value_header);
- assert(*_p_value_header == *p_value_header);
-
+ assert(p_node_base != nullptr);
+ assert(key_view.has_value());
+ assert(p_value_header != nullptr);
assert(!value_payload_mut);
- assert(!p_value_recorder);
+ assert(p_value_recorder == nullptr);
+
+ auto current_p_node_base = ref_leaf_node->read();
+ assert(current_p_node_base != p_node_base);
version.is_duplicate = true;
- p_value_header = _p_value_header;
+ reset_ptr(p_value_header, p_node_base, current_p_node_base);
+ key_view->reset_to(p_node_base, current_p_node_base);
+
+ p_node_base = current_p_node_base;
} else {
// cache must be latest.
// node cannot change is_duplicate from true to false.
assert(version == ref_leaf_node->get_version());
auto [_key_view, _p_value_header] = ref_leaf_node->get_kv(pos);
+ assert(p_node_base == ref_leaf_node->read());
assert(key_view->compare_to(_key_view) == MatchKindCMP::EQ);
assert(p_value_header == _p_value_header);
- auto p_node_base = ref_leaf_node->read();
- assert((const char*)_p_value_header - p_node_base == offset_value_header);
#endif
}
}
bool operator!=(const string_key_view_t& x) const { return !(*this == x); }
+ void reset_to(const char* origin_base, const char* new_base) {
+ reset_ptr(p_key, origin_base, new_base);
+ reset_ptr(p_length, origin_base, new_base);
+#ifndef NDEBUG
+ string_size_t current_length;
+ std::memcpy(¤t_length, p_length, sizeof(string_size_t));
+ assert(length == current_length);
+#endif
+ }
+
static void append_str(
NodeExtentMutable&, std::string_view, char*& p_append);
}
bool operator!=(const ns_oid_view_t& x) const { return !(*this == x); }
+ void reset_to(const char* origin_base, const char* new_base) {
+ nspace.reset_to(origin_base, new_base);
+ oid.reset_to(origin_base, new_base);
+ }
+
template <KeyT KT>
static node_offset_t estimate_size(const full_key_t<KT>& key);
replace(key);
}
+ void reset_to(const char* origin_base, const char* new_base) {
+ if (p_shard_pool != nullptr) {
+ reset_ptr(p_shard_pool, origin_base, new_base);
+ }
+ if (p_crush != nullptr) {
+ reset_ptr(p_crush, origin_base, new_base);
+ }
+ if (p_ns_oid.has_value()) {
+ p_ns_oid->reset_to(origin_base, new_base);
+ }
+ if (p_snap_gen != nullptr) {
+ reset_ptr(p_snap_gen, origin_base, new_base);
+ }
+ }
+
std::ostream& dump(std::ostream& os) const {
os << "key_view(";
if (has_shard_pool()) {