replace parallel_hashmap with gtl (#4225)

This commit is contained in:
2025-07-01 19:42:00 -07:00
committed by GitHub
parent 34e43d3ce7
commit dc2bb1692a
5 changed files with 21 additions and 20 deletions
+8 -8
View File
@@ -141,19 +141,19 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht
bazel_dep(name = "flatbuffers", version = "25.2.10") bazel_dep(name = "flatbuffers", version = "25.2.10")
# #
# parallel-hashmap # gtl (for parallel_hashmap)
# #
parallel_hashmap_version = "1.4.1" gtl_version = "1.2.0"
parallel_hashmap_sha = "aac333eac3627698ca922102fd2a5921df8976906dff6b8e247a49e8cf363911" gtl_sha = "1969c45dd76eac0dd87e9e2b65cffe358617f4fe1bcd203f72f427742537913a"
http_archive( http_archive(
name = "parallel_hashmap", name = "gtl",
build_file = "@//external:BUILD.parallel_hashmap", build_file = "@//external:BUILD.gtl",
sha256 = parallel_hashmap_sha, sha256 = gtl_sha,
strip_prefix = "parallel-hashmap-%s" % parallel_hashmap_version, strip_prefix = "gtl-%s" % gtl_version,
url = "https://github.com/greg7mdp/parallel-hashmap/archive/refs/tags/v%s.zip" % parallel_hashmap_version, url = "https://github.com/greg7mdp/gtl/archive/refs/tags/v%s.zip" % gtl_version,
) )
# #
+6
View File
@@ -0,0 +1,6 @@
cc_library(
name = "gtl",
hdrs = glob(["include/gtl/*.hpp"]),
includes = ["include"],
visibility = ["//visibility:public"],
)
-5
View File
@@ -1,5 +0,0 @@
cc_library(
name = "parallel_hashmap",
hdrs = glob(["parallel_hashmap/*.h"]),
visibility = ["//visibility:public"],
)
@@ -12,7 +12,7 @@
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wthread-safety-analysis" #pragma GCC diagnostic ignored "-Wthread-safety-analysis"
#pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC diagnostic ignored "-Wunused-result"
#include "parallel_hashmap/phmap.h" #include <gtl/phmap.hpp>
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
namespace shardok { namespace shardok {
@@ -24,7 +24,7 @@ struct MapId {
int64_t modifierId; int64_t modifierId;
friend size_t hash_value(const MapId& id) { friend size_t hash_value(const MapId& id) {
return phmap::HashState::combine(0, id.terrainTypesId, id.modifierId); return gtl::HashState::combine(0, id.terrainTypesId, id.modifierId);
} }
auto operator==(const MapId& other) const -> bool { auto operator==(const MapId& other) const -> bool {
@@ -51,7 +51,7 @@ struct FullCacheKey {
// Hash function for FullCacheKey // Hash function for FullCacheKey
struct FullCacheKeyHash { struct FullCacheKeyHash {
size_t operator()(const FullCacheKey& key) const { size_t operator()(const FullCacheKey& key) const {
return phmap::HashState::combine( return gtl::HashState::combine(
hash_value(key.mapId), hash_value(key.mapId),
key.battalionTypeId, key.battalionTypeId,
key.includeBravingWater, key.includeBravingWater,
@@ -61,11 +61,11 @@ struct FullCacheKeyHash {
class ActionPointDistancesCache { class ActionPointDistancesCache {
private: private:
using APDMap = phmap::parallel_flat_hash_map< using APDMap = gtl::parallel_flat_hash_map<
APDKey, APDKey,
shared_ptr<ActionPointDistances>, shared_ptr<ActionPointDistances>,
phmap::priv::hash_default_hash<APDKey>, gtl::priv::hash_default_hash<APDKey>,
phmap::priv::hash_default_eq<APDKey>, gtl::priv::hash_default_eq<APDKey>,
std::allocator<std::pair<const APDKey, shared_ptr<ActionPointDistances>>>, std::allocator<std::pair<const APDKey, shared_ptr<ActionPointDistances>>>,
6, 6,
std::mutex>; std::mutex>;
@@ -30,7 +30,7 @@ cc_library(
":fixed_action_point_distances", ":fixed_action_point_distances",
"//src/main/cpp/net/eagle0/shardok/library/map:hex_map_hasher", "//src/main/cpp/net/eagle0/shardok/library/map:hex_map_hasher",
"//src/main/protobuf/net/eagle0/shardok/storage:action_result_cc_proto", "//src/main/protobuf/net/eagle0/shardok/storage:action_result_cc_proto",
"@parallel_hashmap", "@gtl",
], ],
) )