File: dump_load.cc

package info (click to toggle)
parallel-hashmap 1.4.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,872 kB
  • sloc: cpp: 20,492; ansic: 1,114; python: 492; makefile: 85; haskell: 56; perl: 43; sh: 23
file content (53 lines) | stat: -rw-r--r-- 1,361 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <parallel_hashmap/phmap_dump.h>

void dump_load_uint64_uint32() {
    phmap::flat_hash_map<uint64_t, uint32_t> mp1 = { {100, 99}, {300, 299} };

    for (const auto& n : mp1)
        std::cout << n.first << "'s value is: " << n.second << "\n";
 
    {
        phmap::BinaryOutputArchive ar_out("./dump.data");
        mp1.phmap_dump(ar_out);
    }

    phmap::flat_hash_map<uint64_t, uint32_t> mp2;
    {
        phmap::BinaryInputArchive ar_in("./dump.data");
        mp2.phmap_load(ar_in);
    }

    for (const auto& n : mp2)
        std::cout << n.first << "'s value is: " << n.second << "\n";
}

void dump_load_parallel_flat_hash_map() {
    phmap::parallel_flat_hash_map<uint64_t, uint32_t> mp1 = {
        {100, 99}, {300, 299}, {101, 992} };

    for (const auto& n : mp1)
        std::cout << "key: " << n.first << ", value: " << n.second << "\n";
 
    {
        phmap::BinaryOutputArchive ar_out("./dump.data");
        mp1.phmap_dump(ar_out);
    }

    phmap::parallel_flat_hash_map<uint64_t, uint32_t> mp2;
    {
        phmap::BinaryInputArchive ar_in("./dump.data");
        mp2.phmap_load(ar_in);
    }

     for (const auto& n : mp2)
        std::cout << "key: " << n.first << ", value: " << n.second << "\n";
}

int main()
{
    dump_load_uint64_uint32();
    dump_load_parallel_flat_hash_map();
    return 0;
}