From 8c8550dcb5e33b9459cb461c4b99320c3d574355 Mon Sep 17 00:00:00 2001 From: "lisa0916lisa@163.com" Date: Tue, 30 May 2023 00:09:40 +0800 Subject: [PATCH] fix: add growth_left for dump and load, to fix the bug that when loading from a phmap which has a lot of deleted slots may cause further inserts to hang --- parallel_hashmap/phmap.h | 2 ++ parallel_hashmap/phmap_dump.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index 15a92a4..8550d59 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -2283,6 +2283,8 @@ private: size_t& growth_left() { return std::get<0>(settings_); } + const size_t& growth_left() const { return std::get<0>(settings_); } + template class RefSet, class M, class P, class H, class E, class A> diff --git a/parallel_hashmap/phmap_dump.h b/parallel_hashmap/phmap_dump.h index 93eda8c..aebf523 100644 --- a/parallel_hashmap/phmap_dump.h +++ b/parallel_hashmap/phmap_dump.h @@ -59,6 +59,7 @@ bool raw_hash_set::phmap_dump(OutputArchive& ar) const return true; ar.saveBinary(ctrl_, sizeof(ctrl_t) * (capacity_ + Group::kWidth + 1)); ar.saveBinary(slots_, sizeof(slot_type) * capacity_); + ar.saveBinary(&growth_left(), sizeof(size_t)); return true; } @@ -79,6 +80,7 @@ bool raw_hash_set::phmap_load(InputArchive& ar) { return true; ar.loadBinary(ctrl_, sizeof(ctrl_t) * (capacity_ + Group::kWidth + 1)); ar.loadBinary(slots_, sizeof(slot_type) * capacity_); + ar.loadBinary(&growth_left(), sizeof(size_t)); return true; }