1#if !defined(phmap_dump_h_guard_)
2#define phmap_dump_h_guard_
29namespace type_traits_internal {
31#if defined(__GLIBCXX__) && __GLIBCXX__ < 20150801
32 template<
typename T>
struct IsTriviallyCopyable :
public std::integral_constant<bool, __has_trivial_copy(T)> {};
37template <
class T1,
class T2>
45#if !defined(PHMAP_NON_DETERMINISTIC) && !defined(PHMAP_DISABLE_DUMP)
50template <
class Policy,
class Hash,
class Eq,
class Alloc>
51template<
typename OutputArchive>
54 "value_type should be trivially copyable");
56 ar.saveBinary(&size_,
sizeof(
size_t));
57 ar.saveBinary(&capacity_,
sizeof(
size_t));
61 ar.saveBinary(slots_,
sizeof(
slot_type) * capacity_);
65template <
class Policy,
class Hash,
class Eq,
class Alloc>
66template<
typename InputArchive>
69 "value_type should be trivially copyable");
71 ar.loadBinary(&size_,
sizeof(
size_t));
72 ar.loadBinary(&capacity_,
sizeof(
size_t));
76 initialize_slots(capacity_);
81 ar.loadBinary(slots_,
sizeof(
slot_type) * capacity_);
89 template <
class,
class,
class,
class>
class RefSet,
91 class Policy,
class Hash,
class Eq,
class Alloc>
92template<
typename OutputArchive>
95 "value_type should be trivially copyable");
97 size_t submap_count = subcnt();
98 ar.saveBinary(&submap_count,
sizeof(
size_t));
99 for (
size_t i = 0; i < sets_.size(); ++i) {
100 auto& inner = sets_[i];
102 if (!inner.set_.phmap_dump(ar)) {
103 std::cerr <<
"Failed to dump submap " << i << std::endl;
111 template <
class,
class,
class,
class>
class RefSet,
113 class Policy,
class Hash,
class Eq,
class Alloc>
114template<
typename InputArchive>
117 "value_type should be trivially copyable");
119 size_t submap_count = 0;
120 ar.loadBinary(&submap_count,
sizeof(
size_t));
121 if (submap_count != subcnt()) {
122 std::cerr <<
"submap count(" << submap_count <<
") != N(" << N <<
")" << std::endl;
126 for (
size_t i = 0; i < submap_count; ++i) {
127 auto& inner = sets_[i];
129 if (!inner.set_.phmap_load(ar)) {
130 std::cerr <<
"Failed to load submap " << i << std::endl;
153 ofs_.open(file_path, std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
157 ofs_.write(
reinterpret_cast<const char*
>(p), sz);
162 typename std::enable_if<type_traits_internal::IsTriviallyCopyable<V>::value,
bool>::type
164 ofs_.write(
reinterpret_cast<const char *
>(&v),
sizeof(V));
168 template<
typename Map>
171 return v.phmap_dump(*
this);
182 ifs_.open(file_path, std::ofstream::in | std::ofstream::binary);
186 ifs_.read(
reinterpret_cast<char*
>(p), sz);
191 typename std::enable_if<type_traits_internal::IsTriviallyCopyable<V>::value,
bool>::type
193 ifs_.read(
reinterpret_cast<char *
>(v),
sizeof(V));
197 template<
typename Map>
200 return v->phmap_load(*
this);
210#ifdef CEREAL_SIZE_TYPE
219 template <
class K,
class V,
class Hash,
class Eq,
class A>
220 void save(
typename std::enable_if<PhmapTrivCopyable<K>::value && PhmapTrivCopyable<V>::value,
typename cereal::BinaryOutputArchive>::type &ar,
226 template <
class K,
class V,
class Hash,
class Eq,
class A>
227 void load(
typename std::enable_if<PhmapTrivCopyable<K>::value && PhmapTrivCopyable<V>::value,
typename cereal::BinaryInputArchive>::type &ar,
236 template <
class K,
class V,
class Hash,
class Eq,
class A,
size_t N,
class Mtx_>
237 void save(
typename std::enable_if<PhmapTrivCopyable<K>::value && PhmapTrivCopyable<V>::value,
typename cereal::BinaryOutputArchive>::type &ar,
243 template <
class K,
class V,
class Hash,
class Eq,
class A,
size_t N,
class Mtx_>
244 void load(
typename std::enable_if<PhmapTrivCopyable<K>::value && PhmapTrivCopyable<V>::value,
typename cereal::BinaryInputArchive>::type &ar,
252 template <
class K,
class Hash,
class Eq,
class A>
253 void save(
typename std::enable_if<PhmapTrivCopyable<K>::value,
typename cereal::BinaryOutputArchive>::type &ar,
259 template <
class K,
class Hash,
class Eq,
class A>
260 void load(
typename std::enable_if<PhmapTrivCopyable<K>::value,
typename cereal::BinaryInputArchive>::type &ar,
268 template <
class K,
class Hash,
class Eq,
class A,
size_t N,
class Mtx_>
269 void save(
typename std::enable_if<PhmapTrivCopyable<K>::value,
typename cereal::BinaryOutputArchive>::type &ar,
275 template <
class K,
class Hash,
class Eq,
class A,
size_t N,
class Mtx_>
276 void load(
typename std::enable_if<PhmapTrivCopyable<K>::value,
typename cereal::BinaryInputArchive>::type &ar,
Definition: phmap_dump.h:150
auto saveBinary(const Map &v) -> decltype(v.phmap_dump(*this), bool())
Definition: phmap_dump.h:169
std::ofstream ofs_
Definition: phmap_dump.h:175
std::enable_if< type_traits_internal::IsTriviallyCopyable< V >::value, bool >::type saveBinary(const V &v)
Definition: phmap_dump.h:163
bool saveBinary(const void *p, size_t sz)
Definition: phmap_dump.h:156
BinaryOutputArchive(const char *file_path)
Definition: phmap_dump.h:152
typename Base::WriteLock UniqueLock
Definition: phmap_base.h:5043
bool phmap_load(InputArchive &ar)
Definition: phmap_dump.h:115
bool phmap_dump(OutputArchive &ar) const
Definition: phmap_dump.h:93
bool phmap_load(InputArchive &)
Definition: phmap_dump.h:67
bool phmap_dump(OutputArchive &) const
Definition: phmap_dump.h:52
void swap(raw_hash_set &that) noexcept(IsNoThrowSwappable< hasher >() &&IsNoThrowSwappable< key_equal >() &&(!AllocTraits::propagate_on_container_swap::value||IsNoThrowSwappable< allocator_type >()))
Definition: phmap.h:1647
typename PolicyTraits::slot_type slot_type
Definition: phmap.h:849
signed char ctrl_t
Definition: phmap.h:284
unsigned char bool
Definition: stdbool.h:25
Definition: phmap_utils.h:139
@ kWidth
Definition: phmap.h:471
Definition: phmap_dump.h:34