]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os: avoid using KeyT in ns_oid_view_t
authorKefu Chai <tchaikov@gmail.com>
Sat, 20 Aug 2022 06:50:19 +0000 (14:50 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 20 Aug 2022 07:43:27 +0000 (15:43 +0800)
so we don't need to use it when instantiating the template member
functions of this class.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc
src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.h
src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h
src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.h
src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage_layout.h

index 85c05e3cb12ae3e4901572b308f1fbca4616aab5..165d61a96a962f08d5699b21b39c3ffaec2521de 100644 (file)
@@ -37,7 +37,7 @@ memory_range_t ITER_T::insert_prefix(
   p_insert -= sizeof(node_offset_t);
   node_offset_t back_offset = (p_insert - p_insert_front);
   mut.copy_in_absolute(p_insert, back_offset);
-  ns_oid_view_t::append<KT>(mut, key, p_insert);
+  ns_oid_view_t::append(mut, key, p_insert);
 
   return {p_insert_front, p_insert};
 }
@@ -179,7 +179,7 @@ APPEND_T::open_nxt(const full_key_t<KT>& key)
 {
   p_append -= sizeof(node_offset_t);
   p_offset_while_open = p_append;
-  ns_oid_view_t::append<KT>(*p_mut, key, p_append);
+  ns_oid_view_t::append(*p_mut, key, p_append);
   return {p_mut, p_append};
 }
 
index 3cc70752b418186c05c9381b347700c7f0e97a71..f09c931a314bc2b99c030a558fe62c69dafdaf65 100644 (file)
@@ -129,7 +129,7 @@ class item_iterator_t {
   template <KeyT KT>
   static node_offset_t estimate_insert(
       const full_key_t<KT>& key, const value_input_t&) {
-    return ns_oid_view_t::estimate_size<KT>(key) + sizeof(node_offset_t);
+    return ns_oid_view_t::estimate_size(key) + sizeof(node_offset_t);
   }
 
   template <KeyT KT>
index 45b46905a178d908c4fadd80d83a97f5a896d2f2..edcf956d856acde347e10e90f630308dbe77c082 100644 (file)
@@ -349,12 +349,12 @@ struct ns_oid_view_t {
     oid.reset_to(origin_base, new_base, node_size);
   }
 
-  template <KeyT KT>
-  static node_offset_t estimate_size(const full_key_t<KT>& key);
+  template <typename Key>
+  static node_offset_t estimate_size(const Key& key);
 
-  template <KeyT KT>
+  template <typename Key>
   static void append(NodeExtentMutable&,
-                     const full_key_t<KT>& key,
+                     const Key& key,
                      char*& p_append);
 
   static void append(NodeExtentMutable& mut,
@@ -368,8 +368,8 @@ struct ns_oid_view_t {
     }
   }
 
-  template <KeyT KT>
-  static void test_append(const full_key_t<KT>& key, char*& p_append);
+  template <typename Key>
+  static void test_append(const Key& key, char*& p_append);
 
   string_key_view_t nspace;
   string_key_view_t oid;
@@ -863,9 +863,10 @@ bool operator==(LHS lhs, RHS rhs) {
   return lhs <=> rhs == 0;
 }
 
-template <KeyT KT>
-node_offset_t ns_oid_view_t::estimate_size(const full_key_t<KT>& key) {
-  if constexpr (KT == KeyT::VIEW) {
+template <typename Key>
+node_offset_t ns_oid_view_t::estimate_size(const Key& key) {
+  static_assert(IsFullKey<Key>);
+  if constexpr (std::same_as<Key, key_view_t>) {
     return key.ns_oid_view().size();
   } else {
     if (key.dedup_type() != Type::STR) {
@@ -877,9 +878,10 @@ node_offset_t ns_oid_view_t::estimate_size(const full_key_t<KT>& key) {
   }
 }
 
-template <KeyT KT>
+template <typename Key>
 void ns_oid_view_t::append(
-    NodeExtentMutable& mut, const full_key_t<KT>& key, char*& p_append) {
+    NodeExtentMutable& mut, const Key& key, char*& p_append) {
+  static_assert(IsFullKey<Key>);
   if (key.dedup_type() == Type::STR) {
     string_key_view_t::append_str(mut, key.nspace(), p_append);
     string_key_view_t::append_str(mut, key.oid(), p_append);
@@ -888,8 +890,9 @@ void ns_oid_view_t::append(
   }
 }
 
-template <KeyT KT>
-void ns_oid_view_t::test_append(const full_key_t<KT>& key, char*& p_append) {
+template <typename Key>
+void ns_oid_view_t::test_append(const Key& key, char*& p_append) {
+  static_assert(IsFullKey<Key>);
   if (key.dedup_type() == Type::STR) {
     string_key_view_t::test_append_str(key.nspace(), p_append);
     string_key_view_t::test_append_str(key.oid(), p_append);
index 9084e954c6b3a3fdad22c32c331045a65d70b9b0..38a4ef5ccd7f04b89410b86923991ad434d867a2 100644 (file)
@@ -138,7 +138,7 @@ class node_extent_t {
       const full_key_t<KT>& key, const value_input_t& value) {
     auto size = FieldType::estimate_insert_one();
     if constexpr (FIELD_TYPE == field_type_t::N2) {
-      size += ns_oid_view_t::estimate_size<KT>(key);
+      size += ns_oid_view_t::estimate_size(key);
     } else if constexpr (FIELD_TYPE == field_type_t::N3 &&
                          NODE_TYPE == node_type_t::LEAF) {
       size += value.allocation_size();
index f65d628fd19dc2cc979a42edfaa7c627e6b00166..a3a3c69ad212744bcec2d1e7357c23be1972a252 100644 (file)
@@ -295,7 +295,7 @@ struct node_fields_2_t {
   template <KeyT KT>
   static void append_key(
       NodeExtentMutable& mut, const full_key_t<KT>& key, char*& p_append) {
-    ns_oid_view_t::append<KT>(mut, key, p_append);
+    ns_oid_view_t::append(mut, key, p_append);
   }
   static void append_offset(
       NodeExtentMutable& mut, node_offset_t offset_to_right, char*& p_append);