Skip to content

Commit 2af1d1c

Browse files
authored
Merge pull request ceph#65717 from ronen-fr/wip-rf-evesrionhash
osd: hash function for eversion_t Reviewed-by: Samuel Just <[email protected]> Reviewed-by: Radoslaw Zarzynski <[email protected]> Reviewed-by: Alex Ainscow <[email protected]>
2 parents 98c0392 + 2e8c738 commit 2af1d1c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/osd/osd_types.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,19 @@ inline std::ostream& operator<<(std::ostream& out, const eversion_t& e) {
986986
return out << e.epoch << "'" << e.version;
987987
}
988988

989+
namespace std {
990+
template <>
991+
struct hash<eversion_t> {
992+
size_t operator()(const eversion_t& ev) const noexcept
993+
{
994+
// Combine epoch and version with a simple shift-based mix
995+
// This is fast and works well when differences are small
996+
return (size_t)ev.epoch ^ ((size_t)ev.version << 8 |
997+
(size_t)ev.version >> (sizeof(size_t) * 8 - 8));
998+
}
999+
};
1000+
} // namespace std
1001+
9891002
/**
9901003
* objectstore_perf_stat_t
9911004
*

0 commit comments

Comments
 (0)