-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcompute_mphf_hem.cpp
45 lines (35 loc) · 1005 Bytes
/
compute_mphf_hem.cpp
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
#include <iostream>
#include <fstream>
#include <iterator>
#include <random>
#include "common.hpp"
#include "mphf_hem.hpp"
#include "mmap_memory_model.hpp"
#include "base_hash.hpp"
#include "perfutils.hpp"
int main(int argc, char** argv)
{
using namespace emphf;
if (argc < 2) {
std::cerr << "Expected: " << argv[0]
<< " <filename> [output_filename]" << std::endl;
std::terminate();
}
const char* filename = argv[1];
std::string output_filename;
if (argc >= 3) {
output_filename = argv[2];
}
logger() << "Processing " << filename << std::endl;
file_lines lines(filename);
size_t n = lines.size();
logger() << n << " strings to process." << std::endl;
stl_string_adaptor adaptor;
mmap_memory_model mm;
mphf_hem<jenkins32_hasher> mphf(mm, n, lines, adaptor);
if (output_filename.size()) {
std::ofstream os(output_filename, std::ios::binary);
mphf.save(os);
}
return 0;
}