]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: hash function for eversion_t wip-rf-evesrionhash
authorRonen Friedman <rfriedma@redhat.com>
Mon, 29 Sep 2025 14:36:14 +0000 (09:36 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Mon, 29 Sep 2025 15:20:03 +0000 (10:20 -0500)
(required by ModeCollector when using eversion_t as key type)

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/osd_types.h

index 4012d727d6edc77f0f8655d81e23b42c308305b2..f28c31f57bc6aadd1b866cb70578a89bdbae1adf 100644 (file)
@@ -985,6 +985,19 @@ inline std::ostream& operator<<(std::ostream& out, const eversion_t& e) {
   return out << e.epoch << "'" << e.version;
 }
 
+namespace std {
+template <>
+struct hash<eversion_t> {
+  size_t operator()(const eversion_t& ev) const noexcept
+  {
+    // Combine epoch and version with a simple shift-based mix
+    // This is fast and works well when differences are small
+    return (size_t)ev.epoch ^ ((size_t)ev.version << 8 |
+                              (size_t)ev.version >> (sizeof(size_t) * 8 - 8));
+  }
+};
+}  // namespace std
+
 /**
  * objectstore_perf_stat_t
  *