From 6c9030408e23de557b0c3d618ca3370dcca312e1 Mon Sep 17 00:00:00 2001 From: Ata E Husain Bohra Date: Fri, 22 Apr 2022 13:16:30 -0700 Subject: [PATCH] Fix Build: use boost::hash to compute hash for std::pair Description Fix Build: use boost::hash to compute hash for std::pair Testing 1. Build - gcc/clang 2. Simulation test: EncryptKeyProxyTest, EncryptionOps 3. Unit test: flow/BlobCipher 4. Running 10k correctness Joshua run --- fdbserver/EncryptKeyProxy.actor.cpp | 15 +++------------ flow/BlobCipher.h | 16 ++++------------ 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/fdbserver/EncryptKeyProxy.actor.cpp b/fdbserver/EncryptKeyProxy.actor.cpp index 20c0116fc7..22e1dbf1e8 100644 --- a/fdbserver/EncryptKeyProxy.actor.cpp +++ b/fdbserver/EncryptKeyProxy.actor.cpp @@ -154,17 +154,6 @@ public: } }; -struct pair_hash { - template - std::size_t operator()(const std::pair& pair) const { - auto hash1 = std::hash{}(pair.first); - auto hash2 = std::hash{}(pair.second); - - // Equal hashes XOR would be ZERO. - return hash1 == hash2 ? hash1 : hash1 ^ hash2; - } -}; - ACTOR Future getCipherKeysByBaseCipherKeyIds(Reference ekpProxyData, KmsConnectorInterface kmsConnectorInf, EKPGetBaseCipherKeysByIdsRequest req) { @@ -179,7 +168,9 @@ ACTOR Future getCipherKeysByBaseCipherKeyIds(Reference // TODO: endpoint serialization of std::unordered_set isn't working at the moment - std::unordered_set, pair_hash> dedupedCipherIds; + std::unordered_set, + boost::hash>> + dedupedCipherIds; for (const auto& item : req.baseCipherIds) { dedupedCipherIds.emplace(item); } diff --git a/flow/BlobCipher.h b/flow/BlobCipher.h index 75a4e8b947..7db574d60b 100644 --- a/flow/BlobCipher.h +++ b/flow/BlobCipher.h @@ -233,20 +233,12 @@ private: // required encryption key, however, CPs/SSs cache-miss would result in RPC to // EncryptKeyServer to refresh the desired encryption key. -struct pair_hash { - template - std::size_t operator()(const std::pair& pair) const { - auto hash1 = std::hash{}(pair.first); - auto hash2 = std::hash{}(pair.second); - - // Equal hashes XOR would be ZERO. - return hash1 == hash2 ? hash1 : hash1 ^ hash2; - } -}; using BlobCipherKeyIdCacheKey = std::pair; -using BlobCipherKeyIdCacheMap = std::unordered_map, pair_hash>; +using BlobCipherKeyIdCacheKeyHash = boost::hash; +using BlobCipherKeyIdCacheMap = + std::unordered_map, BlobCipherKeyIdCacheKeyHash>; using BlobCipherKeyIdCacheMapCItr = - std::unordered_map, pair_hash>::const_iterator; + std::unordered_map, BlobCipherKeyIdCacheKeyHash>::const_iterator; struct BlobCipherKeyIdCache : ReferenceCounted { public: