-
Notifications
You must be signed in to change notification settings - Fork 2
/
db_debug.cpp
103 lines (72 loc) · 1.94 KB
/
db_debug.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include <fstream>
#include <sstream>
#include <deque>
#include "word.h"
#include "hash.h"
#include "bloom.h"
#include "maestro.h"
#include <ncbi-vdb/NGS.hpp> // For openReadCollection
// For non-temporal memory access that bypasses the cache
#include <smmintrin.h>
#include <emmintrin.h>
using namespace std;
int main(int argc, char *argv[])
{
try{
time_t profile = time(NULL);
const size_t num_bloom = 257;
deque<string> bloom_files;
for(size_t i = 0;i < num_bloom;++i){
stringstream filename;
filename << "temp/filter." << i << ".bloom";
bloom_files.push_back( filename.str() );
}
BloomParam param;
param.hash_func = MURMUR_HASH_32;
param.log_2_filter_len = 18;
param.kmer_len = 31;
param.num_hash = 3;
// Create Bloom filters
if(false){
for(deque<string>::const_iterator i = bloom_files.begin();
i != bloom_files.end();++i){
cerr << "Writing filter " << *i << endl;
ofstream fout(i->c_str(), ios::binary);
if(!fout){
throw __FILE__ ":main: Unable to open output filter for writing";
}
const size_t num_bits = 1ULL << param.log_2_filter_len;
BloomFilter filter(param);
filter.unset_all_bits();
for(size_t j = 0;j < num_bits;++j){
if(rand() % 2 == 1){
filter.set_bit(j);
}
}
// Updat the crc32 value
filter.update_crc32();
// Don't bother with any metadata
binary_write(fout, filter);
}
}
const bool ret = build_db("temp/debug_new.db", param, bloom_files);
if(ret){
cerr << "Successfully wrote the database file" << endl;
}
else{
cerr << "*Failed* to write the database file" << endl;
}
profile = time(NULL) - profile;
cerr << "Complete in " << profile << " sec" << endl;
}
catch(const char* error){
cerr << "Caught the error: " << error << endl;
return EXIT_FAILURE;
}
catch(...){
cerr << "Caught an unhandled error" << endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}