-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAWBTree.h
88 lines (78 loc) · 2.6 KB
/
AWBTree.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
#ifndef _AWBTree_H
#define _AWBTree_H
#include <cstring>
#include "Util.h"
#include "ThreadPool.h"
using namespace std;
//using lbptree = BplusTree::bplus_tree<int, lowTreeEle>;
//using lbptree_node = BplusTree::Node<int, lowTreeEle>;
//using ltree_iter = BplusTree::bplus_tree<int, lowTreeEle>::iterator;
//using hbptree = BplusTree::bplus_tree<int, int>;
//using hbptree_node = BplusTree::Node<int, int>;
//using htree_iter = BplusTree::bplus_tree<int, int>::iterator;
using lbptree = BplusTree::Tree<int, lowTreeEle>;
using lbptree_node = BplusTree::Node<int, lowTreeEle>;
using ltree_iter = BplusTree::Tree<int, lowTreeEle>::iterator;
using hbptree = BplusTree::Tree<int, int>;
using hbptree_node = BplusTree::Node<int, int>;
using htree_iter = BplusTree::Tree<int, int>::iterator;
class AWBTree
{
private:
vector<vector<lbptree*>> ltree;
vector<vector<hbptree*>> htree;
uint32_t dim; // 维度
uint16_t width_size; // 宽度单元数目
uint16_t branch; // btree最大分支数
vector<uint16_t> pdr; // 记录正向匹配需要匹配的谓词数目
vector<vector<bool>> sig;
vector<uint16_t> counter;
//vector<atomic_uint16_t> atomic_counter;
bitset<subs> bit_forward;
ThreadPool pool;
double width; // 宽度单元大小
uint16_t dPoint; // 任务切分点
public:
vector<IntervalSub> subList;
vector<Pub> pubList;
public:
AWBTree(int type)
: dim(atts), width_size(WCsize), branch(awbTree_branch), width(
valDom / WCsize), sig(atts, vector<bool>(WCsize, 0)), counter(subs, 0), dPoint(
awbTree_Ppoint * WCsize), pdr(subs, 0)
{
ltree.resize(dim);
htree.resize(dim);
for (int i = 0; i < dim; i++)
{
ltree[i].resize(width_size);
htree[i].resize(width_size);
for (int j = 0; j < width_size; j++)
{
//ltree[i][j] = new lbptree(branch, new lbptree_node);
//htree[i][j] = new hbptree(branch, new hbptree_node);
ltree[i][j] = new lbptree(branch);
htree[i][j] = new hbptree(branch);
}
}
if (type == AWBPTREE_PARALLEL)
pool.initThreadPool(parallelDegree);
}
bool readSubs(string file);
bool readPus(string file);
void insert(IntervalSub sub);
void setbits();
void erase(IntervalSub sub);
void forward(const Pub& pub, int& matchSubs);
void forward_o(const Pub& pub, int& matchSubs);
void forward_p(const Pub& pub, int& matchSubs);
void backward(const Pub& pub, int& matchSubs);
void backward_o(const Pub& pub, int& matchSubs);
void backward_p(const Pub& pub, int& matchSubs);
void hybrid(const Pub& pub, int& matchSubs);
void hybrid_a(const Pub& pub, int& matchSubs);
void hybrid_p(const Pub& pub, int& matchSubs);
size_t calMemory();
bool check(vector<uint32_t>& matchSubList);
};
#endif // !_AWBTree