-
Notifications
You must be signed in to change notification settings - Fork 1
/
db.h
125 lines (100 loc) · 3.2 KB
/
db.h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once
using namespace std;
#include "stdafx.h"
#include "options.h"
#include "BF_bit.h"
class db
{
private:
// log path
string out_path;
// db path
string bf_dir;
string index_dir;
string data_dir;
string settings_file;
string fence_file;
int file_read_flags;
// db parameter
int P;
int B;
int E;
int K;
int size_ratio;
int buffer_size;
int num_levels = 0;
int num_sst = 0;
vector <int> num_sstPerLevel;
int last_sst_keys;
// BF related
int bpk;
int mod_bf;
bool fastlocal_bf;
int num_filter_units;
int filter_unit_size;
int filter_unit_byte;
int filter_unit_index;
int filter_size;
int last_filter_size;
uint32_t num_lines;
uint32_t last_num_lines;
int num_probes;
int index_size;
int data_size;
vector<vector<string> > fence_pointers;
char**** bf_prime;
char**** blk_fp_prime;
int** blk_size_prime;
vector<uint64_t> hash_digests;
// stats
public:
// get starting timepoint
fsec total_duration = std::chrono::microseconds::zero();
fsec data_duration = std::chrono::microseconds::zero();
fsec hash_duration = std::chrono::microseconds::zero();
fsec bs_duration = std::chrono::microseconds::zero();
uint64_t total_n = 0;
uint64_t total_p = 0;
uint64_t total_fp = 0;
vector<uint64_t> fp_vec;
vector<uint64_t> n_vec;
unsigned int num_lookups = 0;
unsigned int lnum_single = 0;
unsigned int qnum_single = 0;
unsigned int lnum = 0;
unsigned int qnum = 0;
vector<int> positive_counters;
vector<int>* qnum_histogram;
vector<int>* lnum_histogram;
// bf evaluating counter
vector<int>* bf_eval_histogram;
// bf true positive counter
vector<int>* bf_tp_eval_histogram;
//vector<int>* bf_eval_histogram = new vector<int> (num_levels, 0);
//vector<int>* bf_tp_eval_histogram = new vector<int> (num_levels, 0);
// experiments
int tries;
int delay;
db( options op );
void split_keys( vector<string> table_in, vector<vector<vector<string> > > & reallocated_keys );
void split_keys_sst(int sst_capacity, vector<string> keys_one_level, vector<vector<string> > & sst, vector<string> & fence_pointer );
void Build( vector<vector<vector<string>>> reallocated_keys, bool bf_only );
int ReadSettings();
string Get( string key, bool * result );
string GetLevel( int i, BFHash & bfHash, string & key, bool * result );
bool QueryFilter( int i, int bf_no, vector<uint64_t>* hash_digests, char** bf_list);
void read_bf(string filename, char* bf, int size);
void flushBFfile(string filename, const char* filterunit, uint32_t size);
void flushfile( string file, vector<string>* table);
void flushIndexes( string file, char** indexes, int size, int key_size);
int GetFromIndex( int i, int bf_no, string key);
int read_index_size(string filename);
void read_index( string filename, int index_size, char** index);
string GetFromData( int i, int bf_no, int index_pos, string key, bool * result );
int read_data ( string filename, int pos, int key_size, vector<string> & data_block );
int binary_search(string key, vector<string> & fence_pointer);
int binary_search(string key, char** indexes, int size);
void SetTreeParam();
fsec loadBFAndIndex();
void PrintStat(double program_total=0.0, double data_load_total=0.0);
};