assert(is_latest());
#ifndef NDEBUG
auto [_key_view, _p_value_header] = node.get_kv(pos);
- assert(*key_view == _key_view);
+ assert(key_view->compare_to(_key_view) == MatchKindCMP::EQ);
assert(p_value_header == _p_value_header);
#endif
}
assert(child.impl->is_level_tail());
} else {
assert(!child.impl->is_level_tail());
- assert(impl->get_key_view(child_pos) == child.impl->get_largest_key_view());
+ assert(impl->get_key_view(child_pos).compare_to(
+ child.impl->get_largest_key_view()) == MatchKindCMP::EQ);
}
// XXX(multi-type)
assert(impl->field_type() <= child.impl->field_type());
assert(!cursor.is_end());
auto [key, p_value_header] = get_kv(cursor.get_position());
auto magic = p_value_header->magic;
- assert(key == cursor.get_key_view(magic));
+ assert(key.compare_to(cursor.get_key_view(magic)) == MatchKindCMP::EQ);
assert(p_value_header == cursor.read_value_header(magic));
#endif
}
if (!result_raw.is_end()) {
full_key_t<KeyT::VIEW> index;
STAGE_T::get_key_view(node_stage, result_raw.position, index);
- assert(index == *index_key);
+ assert(index.compare_to(*index_key) == MatchKindCMP::EQ);
}
#endif
} else {
logger().trace("OTree::Layout::Insert: -- dump\n{}", sos.str());
}
validate_layout();
- assert(get_key_view(insert_pos) == key);
+ assert(get_key_view(insert_pos).compare_to(key) == MatchKindCMP::EQ);
return ret;
}
insert_pos, insert_stage);
p_value = extent.template split_insert_replayable<KEY_TYPE>(
split_at, key, value, insert_pos, insert_stage, insert_size);
- assert(get_key_view(_insert_pos) == key);
+ assert(get_key_view(_insert_pos).compare_to(key) == MatchKindCMP::EQ);
} else {
logger().debug("OTree::Layout::Split: -- left trim ...");
- assert(right_impl.get_key_view(_insert_pos) == key);
+ assert(right_impl.get_key_view(_insert_pos).compare_to(key) == MatchKindCMP::EQ);
extent.split_replayable(split_at);
}
if (unlikely(logger().is_enabled(seastar::log_level::debug))) {
return ghobj.generation;
}
- bool operator==(const full_key_t<KeyT::VIEW>& o) const;
- bool operator==(const full_key_t<KeyT::HOBJ>& o) const;
- bool operator!=(const full_key_t<KeyT::VIEW>& o) const {
- return !operator==(o);
- }
- bool operator!=(const full_key_t<KeyT::HOBJ>& o) const {
- return !operator==(o);
- }
+ MatchKindCMP compare_to(const full_key_t<KeyT::VIEW>&) const;
+ MatchKindCMP compare_to(const full_key_t<KeyT::HOBJ>&) const;
std::ostream& dump(std::ostream& os) const {
os << "key_hobj(" << (unsigned)shard() << ","
return snap_gen_packed().gen;
}
- bool operator==(const full_key_t<KeyT::VIEW>& o) const;
- bool operator==(const full_key_t<KeyT::HOBJ>& o) const;
- bool operator!=(const full_key_t<KeyT::VIEW>& o) const {
- return !operator==(o);
- }
- bool operator!=(const full_key_t<KeyT::HOBJ>& o) const {
- return !operator==(o);
- }
+ MatchKindCMP compare_to(const full_key_t<KeyT::VIEW>&) const;
+ MatchKindCMP compare_to(const full_key_t<KeyT::HOBJ>&) const;
/**
* key_view_t specific interfaces
ceph::encode(key.gen(), bl);
}
-inline MatchKindCMP compare_to(std::string_view l, std::string_view r) {
- return toMatchKindCMP(l, r);
-}
template <KeyT TypeL, KeyT TypeR>
-bool compare_full_key(const full_key_t<TypeL>& l, const full_key_t<TypeR>& r) {
- if (l.shard() != r.shard())
- return false;
- if (l.pool() != r.pool())
- return false;
- if (l.crush() != r.crush())
- return false;
- if (compare_to(l.nspace(), r.nspace()) != MatchKindCMP::EQ)
- return false;
- if (compare_to(l.oid(), r.oid()) != MatchKindCMP::EQ)
- return false;
- if (l.snap() != r.snap())
- return false;
- if (l.gen() != r.gen())
- return false;
- return true;
-}
-
-inline bool key_hobj_t::operator==(const full_key_t<KeyT::VIEW>& o) const {
+MatchKindCMP compare_full_key(
+ const full_key_t<TypeL>& l, const full_key_t<TypeR>& r) {
+ auto ret = toMatchKindCMP(l.shard(), r.shard());
+ if (ret != MatchKindCMP::EQ)
+ return ret;
+ ret = toMatchKindCMP(l.pool(), r.pool());
+ if (ret != MatchKindCMP::EQ)
+ return ret;
+ ret = toMatchKindCMP(l.crush() != r.crush());
+ if (ret != MatchKindCMP::EQ)
+ return ret;
+ ret = toMatchKindCMP(l.nspace(), r.nspace());
+ if (ret != MatchKindCMP::EQ)
+ return ret;
+ ret = toMatchKindCMP(l.oid(), r.oid());
+ if (ret != MatchKindCMP::EQ)
+ return ret;
+ ret = toMatchKindCMP(l.snap(), r.snap());
+ if (ret != MatchKindCMP::EQ)
+ return ret;
+ return toMatchKindCMP(l.gen(), r.gen());
+}
+
+inline MatchKindCMP key_hobj_t::compare_to(
+ const full_key_t<KeyT::VIEW>& o) const {
return compare_full_key<KeyT::HOBJ, KeyT::VIEW>(*this, o);
}
-inline bool key_hobj_t::operator==(const full_key_t<KeyT::HOBJ>& o) const {
+inline MatchKindCMP key_hobj_t::compare_to(
+ const full_key_t<KeyT::HOBJ>& o) const {
return compare_full_key<KeyT::HOBJ, KeyT::HOBJ>(*this, o);
}
-inline bool key_view_t::operator==(const full_key_t<KeyT::VIEW>& o) const {
+inline MatchKindCMP key_view_t::compare_to(
+ const full_key_t<KeyT::VIEW>& o) const {
return compare_full_key<KeyT::VIEW, KeyT::VIEW>(*this, o);
}
-inline bool key_view_t::operator==(const full_key_t<KeyT::HOBJ>& o) const {
+inline MatchKindCMP key_view_t::compare_to(
+ const full_key_t<KeyT::HOBJ>& o) const {
return compare_full_key<KeyT::VIEW, KeyT::HOBJ>(*this, o);
}