-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rein.h
executable file
·150 lines (128 loc) · 6.32 KB
/
Rein.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef _REIN_H
#define _REIN_H
#include <cstring>
#include "Util.h"
#include "constant.h"
#include <algorithm>
#include <unordered_set>
#define _for(i,a,b) for( int i=(a); i<(b); ++i)
#define __for(i,a,b) for( int i=(a); i<=(b); ++i)
#define mfor(i,a,b) for(int i=(a);i>(b);--i)
#define mmfor(i,a,b) for(int i=(a);i>=(b);--i)
//const int MAX_SUBS = 2000001;
//const int MAX_ATTS = 101;
//const int MAX_BUCKS = 500;
// 01�ڵ�һά
class Rein {
int numSub, numDimension, buckStep;
vector<vector<vector<Combo>>> data[2]; // original Rein and AWRein 0:left parenthesis, 1:right parenthesis
vector<vector<vector<IntervalCombo>>> fData[2]; // forward Rein (fRein)
// vector<vector<vector<vector<IntervalCombo>>>> awData[2]; // l/h->attr->level->buck->i
int subPredicate[subs]; // forward Rein; for AWRein, it means the number of predicates inserted to fData for forward matching
int counter[subs]; // forward Rein
vector<bitset<subs>> nB; // null bitset for forward Rein with C-BOMP
vector<bitset<subs>> nnB; // non-null bitset for backward matching, same as HEM
vector<vector<int32_t>> fix[2]; // For each attribute, LVE上前缀桶大小和,HVE上后缀桶大小和,相当于HEM的动态分组优化LGS
public:
int numBucket;
double compareTime = 0.0; // ����ά�����¼�ֵ������Ǹ�cell�������ȷ�Ƚϵ�ʱ��
double markTime = 0.0;
double bitTime = 0.0;
vector<unordered_set<int>> bucketSub; // 同一桶号的所有桶的元素集合
Rein(int);
// Original Rein
//void insert(Sub sub);
void insert_backward_original(IntervalSub sub);
//void match(const Pub& pub, int& matchSubs, const vector<Sub>& subList);
void match_backward_original(const Pub& pub, int& matchSubs);
bool deleteSubscription_backward_original(IntervalSub sub);
int calMemory_backward_original(); // ����ռ���ڴ��С, ����MB
// FBMAD: Forward Rein
void insert_forward_native(IntervalSub sub);
void match_forward_native(const Pub& pub, int& matchSubs);
bool deleteSubscription_forward_native(IntervalSub sub);
int calMemory_forward_native();
// Forward Rein with C-BOMP
void insert_forward_CBOMP(IntervalSub sub);
void match_forward_CBOMP(const Pub& pub, int& matchSubs);
bool deleteSubscription_forward_CBOMP(IntervalSub sub);
int calMemory_forward_CBOMP();
// FBCMOP:HybridRein (AWRein)
void insert_hybrid_native(IntervalSub sub);
void match_hybrid_native(const Pub& pub, int& matchSubs);
bool deleteSubscription_hybrid_native(IntervalSub sub);
int calMemory_hybrid_native();
// HybridRein (AWRein) with C-BOMP
void insert_hybrid_CBOMP(IntervalSub sub);
void match_hybrid_CBOMP(const Pub& pub, int& matchSubs);
bool deleteSubscription_hybrid_CBOMP(IntervalSub sub);
int calMemory_hybrid_CBOMP();
// LGS 谓词粒度负载优化 PGWO -----------------------------------------------------------
void initFix();
// FBMAD: Forward Rein with PGWO
void insert_forward_PGWO(IntervalSub sub);
void match_forward_PGWO(const Pub& pub, int& matchSubs);
bool deleteSubscription_forward_PGWO(IntervalSub sub);
int calMemory_forward_PGWO(){return -1;}
// Forward Rein with PGWO and C-BOMP
void insert_forward_PGWO_CBOMP(IntervalSub sub);
void match_forward_PGWO_CBOMP(const Pub& pub, int& matchSubs);
bool deleteSubscription_forward_PGWO_CBOMP(IntervalSub sub){return false;}
int calMemory_forward_PGWO_CBOMP(){return -1;}
// FBCMOP:HybridRein (AWRein) with PGWO
void insert_hybrid_PGWO(IntervalSub sub);
void match_hybrid_PGWO(const Pub& pub, int& matchSubs);
bool deleteSubscription_hybrid_PGWO(IntervalSub sub){return false;}
int calMemory_hybrid_PGWO(){return -1;}
// HybridRein (AWRein) with PGWO and C-BOMP
void insert_hybrid_PGWO_CBOMP(IntervalSub sub);
void match_hybrid_PGWO_CBOMP(const Pub& pub, int& matchSubs);
bool deleteSubscription_hybrid_PGWO_CBOMP(IntervalSub sub){return false;}
int calMemory_hybrid_PGWO_CBOMP(){return -1;}
void calBucketSize(); // ����bucketSize
vector<int> calMarkNumForBuckets(); // �����¼��䵽ÿ��Ͱ��ʱ��Ҫ��ǺͱȽϵ�ν�ʸ���
// DMFT 方向匹配基本定理,把反向 REIN 转正向 REIN-F,把正向 REIN-C-BOMP 转反向 REIN-C-B
void insert_forward_DMFT_REIN(IntervalSub sub);
void match_forward_DMFT_REIN(const Pub& pub, int& matchSubs); // Original Rein to REIN-Forward
bool deleteSubscription_forward_DMFT_REIN(IntervalSub sub){return false;}
int calMemory_forward_DMFT_REIN(){return calMemory_backward_original();}
void insert_backward_DMFT_fREIN_CBOMP(IntervalSub sub);
void match_backward_DMFT_fREIN_CBOMP(const Pub& pub, int& matchSubs);
bool deleteSubscription_backward_DMFT_fREIN_CBOMP(IntervalSub sub){return false;}
int calMemory_backward_DMFT_fREIN_CBOMP(){return calMemory_forward_CBOMP();}
};
// 01�ڵڶ�ά��ȫ��̬
//class Rein {
// int numSub, numDimension, buckStep, numBucket; // ά�ȣ�Ͱ���ȣ�Ͱ��
// vector<vector<vector<vector<Combo>>>> data; // 0:left parenthesis, 1:right parenthesis
//
//public:
// Rein(int valDom, int numSubscription, int numDim, int numBuck) :numSub(numSubscription), numDimension(numDim) {
// buckStep = (valDom - 1) / numBuck + 1;
// numBucket = (valDom - 1) / buckStep + 1;
// cout << "Rein: bucketStep = " << buckStep << ", numBucket = " << numBucket << endl;
// data.resize(numDimension, vector<vector<vector<Combo>>>(2, vector<vector<Combo>>(numBucket)));
// }
// //void insert(Sub sub);
// void insert(IntervalSub sub);
// //void match(const Pub& pub, int& matchSubs, const vector<Sub>& subList);
// void match(const Pub& pub, int& matchSubs);
//};
// 01�ڵ�һά��д��
//class Rein {
// int numSub, numDimension, buckStep, numBucket; // ά�ȣ�Ͱ���ȣ�Ͱ��
// vector<Combo> data[MAX_ATTS][2][MAX_BUCKS];
//
//public:
// Rein(int valDom, int numSubscription, int numDim, int numBuck) :numSub(numSubscription), numDimension(numDim) {
// buckStep = (valDom - 1) / numBuck + 1;
// numBucket = (valDom - 1) / buckStep + 1;
// cout << "Rein: bucketStep = " << buckStep << ", numBucket = " << numBucket << endl;
// //data.resize(numDimension, vector<vector<vector<Combo>>>(2, vector<vector<Combo>>(numBucket)));
// }
// //void insert(Sub sub);
// void insert(IntervalSub sub);
// //void match(const Pub& pub, int& matchSubs, const vector<Sub>& subList);
// void match(const Pub& pub, int& matchSubs);
//};
#endif