-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpIndex.h
118 lines (86 loc) · 2.85 KB
/
OpIndex.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
#ifndef _OPINDEX_H
#define _OPINDEX_H
#include <ctime>
#include "data_structure.h"
#include "generator.h"
#include "printer.h"
#include "chrono_time.h"
#include <string>
#include <cstring>
#include"constant.h"
#include <bitset>
const int MAX_ATTS = 10001;
const int MAX_SUBS = 1000001;
//const int SEGMENTS = 32;
//const int MAX_SIGNATURE = 61;
class OpIndex {
// 其实这些都可以变成动态的, 方括号里的值就不需要写死为常量了
vector<ConElement> data[MAX_ATTS][3][SEGMENTS][MAX_SIGNATURE];
bool sig[MAX_ATTS][3][SEGMENTS][MAX_SIGNATURE];
int counter[MAX_SUBS];
int fre[MAX_ATTS];
void initCounter(const vector<Sub>& subList);
void initCounter(const vector<IntervalSub>& subList);
int getMinFre(Sub x);
int getMinFre(IntervalSub x);
int signatureHash1(int att, int val); // for == operation
int signatureHash2(int att); // for <= and >= operation
public:
int numSub;
bool isPivot[MAX_ATTS];
OpIndex() :numSub(0)
{
memset(isPivot, 0, sizeof(isPivot));
memset(sig, 0, sizeof(sig));
}
void calcFrequency(const vector<Sub>& subList);
void calcFrequency(const vector<IntervalSub>& subList);
void insert(Sub x);
void insert(IntervalSub x);
bool deleteSubscription(IntervalSub sub);
void match(Pub x, int& matchSubs, const vector<Sub>& subList);
void match(Pub x, int& matchSubs, const vector<IntervalSub>& subList);
int calMemory(); // 计算占用内存大小, 返回MB
};
class OpIndex2 { // Simple Version by Swhua
vector<vector<vector<IntervalCombo>>> data;
vector<int> fre;
vector<int> pivotCount; // record how many subs in this pivot attribute, use for deletion decision
int getMinFre(Sub x);
int getMinFre(IntervalSub x);
public:
int numSub;
vector<bool> isPivot;
OpIndex2();
~OpIndex2();
void calcFrequency(const vector<Sub>& subList);
void calcFrequency(const vector<IntervalSub>& subList);
// void insert(Sub x);
void insert(IntervalSub x);
bool deleteSubscription(IntervalSub sub);
// void match(Pub x, int& matchSubs, const vector<Sub>& subList);
void match(Pub x, int& matchSubs, const vector<IntervalSub>& subList);
int calMemory(); // 计算占用内存大小, 返回MB
};
class bOpIndex2 {
vector<vector<vector<IntervalCombo>>> data;
vector<int> fre;
vector<int> pivotCount; // record how many subs in this pivot attribute, use for deletion decision
vector<bitset<subs>> nB; // null bitset
int getMinFre(Sub x);
int getMinFre(IntervalSub x);
public:
int numSub;
vector<bool> isPivot;
bOpIndex2();
~bOpIndex2();
void calcFrequency(const vector<Sub>& subList);
void calcFrequency(const vector<IntervalSub>& subList);
// void insert(Sub x);
void insert(IntervalSub x);
bool deleteSubscription(IntervalSub sub);
// void match(Pub x, int& matchSubs, const vector<Sub>& subList);
void match(Pub x, int& matchSubs, const vector<IntervalSub>& subList);
int calMemory(); // 计算占用内存大小, 返回MB
};
#endif