forked from mzz235711/Selectivity-Estimation-for-Queries-Containing-Predicates-over-Set-Valued-Attributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
63 lines (52 loc) · 1.75 KB
/
utils.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
#include <boost/functional/hash.hpp>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <utility>
//typedef std::vector<std::vector<std::pair<int, int>>> Weightedgraph;
//typedef std::vector<std::unordered_map<int, int>> Subgraph;
struct TreeNode{
int level = 0;
int id = -1;
bool last_flag = false;
int freq = 0;
int total_freq = 0;
int hist_freq = 0;
std::pair<int, int> range = std::make_pair(-1, -1);
int hist_val = -1;
std::vector<TreeNode> children;
std::unordered_map<int, double> percentage;
std::vector<int> full_nodes;
double all_null = 1;
};
template<typename Container> // we can make this generic for any container [1]
struct container_hash {
std::size_t operator()(Container const& c) const {
return boost::hash_range(c.begin(), c.end());
}
};
template<class InputIterator, class T>
InputIterator find_pair(InputIterator first, InputIterator last, const T& val) {
while (first != last) {
if ((*first).first == val) return first;
++first;
}
return last;
}
template<class InputIterator, class T>
InputIterator find_node(InputIterator first, InputIterator last, const T& val) {
while (first != last) {
if ((*first).id == val) return first;
++first;
}
return last;
}
typedef std::vector<std::unordered_map<int, int>> Weightedgraph;
typedef std::vector<std::vector<int>> Unweightedgraph;
typedef std::vector<std::pair<std::vector<int>, std::vector<int>>> UnweightedDirectgraph;
//typedef std::vector<std::vector<int>> Weightedgraph;
typedef std::unordered_map<std::vector<int>, int, container_hash<std::vector<int>>> Vectormap;
typedef std::vector<std::vector<int>> Setvector;
typedef std::vector<std::vector<int>> Adjmatrix;
const int FREQ_THRES = 10;