wangyong9999 commented on code in PR #254:
URL: https://github.com/apache/paimon-cpp/pull/254#discussion_r3870600286
##########
src/paimon/common/utils/concurrent_hash_map.h:
##########
@@ -22,56 +22,173 @@
#include <algorithm>
#include <cstddef>
#include <cstdint>
+#include <functional>
+#include <memory>
+#include <mutex>
#include <optional>
+#include <shared_mutex>
#include <string>
+#include <unordered_map>
#include <vector>
+#include "paimon/common/utils/concurrent_backend_factory.h"
#include "paimon/common/utils/murmurhash_utils.h"
+#ifdef PAIMON_USE_TBB
#include "tbb/concurrent_hash_map.h"
+#endif
namespace paimon {
-template <typename Key, typename T, typename HashCompare =
tbb::tbb_hash_compare<Key>>
+
+template <typename Key>
+class DefaultHashCompare {
+ public:
+ size_t hash(const Key& key) const {
+ return std::hash<Key>{}(key);
+ }
+
+ bool equal(const Key& lhs, const Key& rhs) const {
+ return lhs == rhs;
+ }
+};
+
+template <typename Key, typename HashCompare>
+class HashCompareHasher {
+ public:
+ size_t operator()(const Key& key) const {
+ return HashCompare{}.hash(key);
Review Comment:
HashCompare{} creates a fresh comparator for every hash/equality call,
unlike the TBB map which owns one comparator instance. With a stateful
comparator (for example, one whose default constructor chooses a seed),
PAIMON_USE_TBB=OFF can insert into one bucket and immediately search another;
an insert-then-find repro returns missing. Please keep one comparator per
backend and initialize both unordered-map adapters from that same state, with a
regression test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]