diff options
author | Adityavardhan Agrawal <aa729@cornell.edu> | 2022-09-07 15:16:35 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-07 16:44:56 +0000 |
commit | a40f6505e1a1ac8f886cb5946ca00e60ac4d3c41 (patch) | |
tree | f337df8e2d6ff6de0c981908f6644b1188782568 /src/mongo/bson/oid.h | |
parent | 44c8b34f1d6d01d67e454fb2d0073d7e07cd652a (diff) | |
download | mongo-a40f6505e1a1ac8f886cb5946ca00e60ac4d3c41.tar.gz |
SERVER-68837: removed the double hashing in AbslHashValue for TenantId
Diffstat (limited to 'src/mongo/bson/oid.h')
-rw-r--r-- | src/mongo/bson/oid.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/mongo/bson/oid.h b/src/mongo/bson/oid.h index afe716e5b17..3ff6a0e12ab 100644 --- a/src/mongo/bson/oid.h +++ b/src/mongo/bson/oid.h @@ -72,15 +72,6 @@ class SecureRandom; */ class OID { public: - /** - * Functor compatible with std::hash for std::unordered_{map,set} - * Warning: The hash function is subject to change. Do not use in cases where hashes need - * to be consistent across versions. - */ - struct Hasher { - size_t operator()(const OID& oid) const; - }; - OID() : _data() {} enum { kOIDSize = 12, kTimestampSize = 4, kInstanceUniqueSize = 5, kIncrementSize = 3 }; @@ -180,11 +171,29 @@ public: } /** + * Functor compatible with std::hash for std::unordered_{map,set} + * Warning: The hash function is subject to change. Do not use in cases where hashes need + * to be consistent across versions. + */ + struct Hasher { + size_t operator()(const OID& oid) const; + }; + + /** * this is not consistent * do not store on disk */ void hash_combine(size_t& seed) const; + /** + * Hash function compatible with absl::Hash for absl::unordered_{map,set} + */ + template <typename H> + friend H AbslHashValue(H h, const OID& oid) { + const auto& d = oid._data; + return H::combine(std::move(h), std::string_view(d, sizeof(d))); + } + /** call this after a fork to update the process id */ static void justForked(); |