From 58f0a75b7b88bc24bc96c3b54ddd83dcde190345 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Thu, 18 Apr 2024 11:55:40 +0100 Subject: [PATCH] [maint]: Remove use of folly/hash/Hash.h Signed-off-by: Ian Thomas --- cpp/arcticdb/entity/atom_key.hpp | 13 ++++-- cpp/arcticdb/util/hash.hpp | 2 - cpp/arcticdb/util/test/test_hash.cpp | 67 ---------------------------- 3 files changed, 9 insertions(+), 73 deletions(-) diff --git a/cpp/arcticdb/entity/atom_key.hpp b/cpp/arcticdb/entity/atom_key.hpp index a78b1d1997..3747d8ba93 100644 --- a/cpp/arcticdb/entity/atom_key.hpp +++ b/cpp/arcticdb/entity/atom_key.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace arcticdb::entity { @@ -101,10 +102,14 @@ class AtomKeyImpl { size_t get_cached_hash() const { if (!hash_) { - // arcticdb::commutative_hash_combine needs extra template specialisations for our variant types, folly's - // built-in variant forwards to std::hash which should be good enough for these simple types - hash_ = folly::hash::hash_combine(id_, version_id_, creation_ts_, content_hash_, key_type_, index_start_, - index_end_); + auto seed = hash(id_); + boost::hash_combine(seed, version_id_); + boost::hash_combine(seed, creation_ts_); + boost::hash_combine(seed, content_hash_); + boost::hash_combine(seed, key_type_); + boost::hash_combine(seed, index_start_); + boost::hash_combine(seed, index_end_); + hash_ = seed; } return *hash_; } diff --git a/cpp/arcticdb/util/hash.hpp b/cpp/arcticdb/util/hash.hpp index 33aad0054e..a980680a3d 100644 --- a/cpp/arcticdb/util/hash.hpp +++ b/cpp/arcticdb/util/hash.hpp @@ -10,8 +10,6 @@ #include #include -#include - #define XXH_STATIC_LINKING_ONLY #include #undef XXH_STATIC_LINKING_ONLY diff --git a/cpp/arcticdb/util/test/test_hash.cpp b/cpp/arcticdb/util/test/test_hash.cpp index db3b24aa1b..aecb478707 100644 --- a/cpp/arcticdb/util/test/test_hash.cpp +++ b/cpp/arcticdb/util/test/test_hash.cpp @@ -29,70 +29,3 @@ TEST(HashAccum, NotCommutative) { EXPECT_NE(h1.digest(), h2.digest()); } - -TEST(HashComm, Commutative) { - using namespace arcticdb; - using namespace folly::hash; - - auto h = commutative_hash_combine(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - - EXPECT_EQ(h, commutative_hash_combine(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)); - EXPECT_EQ(h, commutative_hash_combine(10, 2, 3, 4, 5, 6, 7, 8, 9, 1)); - - EXPECT_EQ( - commutative_hash_combine(12345, 6789), - commutative_hash_combine(6789, 12345) - ); - - auto v1 = commutative_hash_combine(0, 1629821389809000000,std::string("FIXT.1.1"),454.0,std::string("IOI"),3224.0,std::string("MA"),std::string("20210824-16:09:49.809"),std::string("GLGMKTLIST2"),std::string("IOIID-1629821389809"),std::string("REPLACE"),std::string("[N/A]"),std::string("437076CG5"),1.0,std::string("US437076CG52"),4,std::string("CORP"),std::string("USD_HGD"),20210826,std::string("BUY"),800000.0,std::string("USD"),std::string("SPREAD"),std::string("20210824-16:07:49"),std::string("20210824-16:05:49"),std::string("912810SX7"),1.0,std::string("MKTX"),std::string("C"),std::string("CONTRA_FIRM"),std::string("Spread"),120.0,std::string("MarketList-Orders"),std::string("Did Not Trade"),std::string("Holding_Bin"),std::string("OneStep"),std::string("4 2"),std::string("YES"),0.0,std::string("N"),std::string("N"),std::string("ILQD"),10467391.0,2.0); - auto v2 = commutative_hash_combine(0, 1629821389809000000,std::string("FIXT.1.1"),454.0,std::string("IOI"),3224.0,std::string("MA"),std::string("20210824-16:09:49.809"),std::string("GLGMKTLIST2"),std::string("IOIID-1629821389809"),std::string("REPLACE"),10467391.0,std::string("[N/A]"),std::string("437076CG5"),1.0,std::string("US437076CG52"),4,std::string("CORP"),std::string("USD_HGD"),20210826,std::string("BUY"),800000.0,std::string("USD"),std::string("SPREAD"),std::string("20210824-16:07:49"),std::string("20210824-16:05:49"),std::string("912810SX7"),1.0,std::string("MKTX"),std::string("C"),std::string("CONTRA_FIRM"),std::string("Spread"),120.0,std::string("MarketList-Orders"),std::string("Did Not Trade"),std::string("Holding_Bin"),std::string("OneStep"),std::string("4 2"),std::string("YES"),2.0,0.0,std::string("N"),std::string("N"),std::string("ILQD")); - - std::cout<