-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRelOp.h
More file actions
162 lines (122 loc) · 3.59 KB
/
RelOp.h
File metadata and controls
162 lines (122 loc) · 3.59 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
#ifndef REL_OP_H
#define REL_OP_H
#include "Pipe.h"
#include "DBFile.h"
#include "Record.h"
#include "Function.h"
static char *SUM_ATT_NAME = "SUM";
static Attribute doubleAtt = {SUM_ATT_NAME, Double};
static Schema sumSchema("sum_schema", 1, &doubleAtt);
class RelationalOp {
protected:
pthread_t thread;
int runLength;
public:
RelationalOp();
// blocks the caller until the particular relational operator
// has run to completion
void WaitUntilDone();
// tell us how much internal memory the operation can use
void Use_n_Pages(int n);
};
struct SelectFileData {
DBFile *dbFile;
Pipe *outputPipe;
CNF *cnf;
Record *literal;
};
void *SelectFileThreadMethod(void *threadData);
class SelectFile : public RelationalOp {
public:
void Run(DBFile &inFile, Pipe &outPipe, CNF &selOp, Record &literal);
};
struct SelectPipeData {
Pipe *inputPipe;
Pipe *outputPipe;
CNF *cnf;
Record *literal;
};
void *SelectPipeThreadMethod(void *threadData);
class SelectPipe : public RelationalOp {
public:
void Run(Pipe &inPipe, Pipe &outPipe, CNF &selOp, Record &literal);
};
struct ProjectData {
Pipe *inputPipe;
Pipe *outputPipe;
int *keepMe;
int numAttsInput;
int numAttsOutput;
};
void *ProjectThreadMethod(void *threadData);
class Project : public RelationalOp {
public:
void Run(Pipe &inPipe, Pipe &outPipe, int *keepMe, int numAttsInput, int numAttsOutput);
};
struct JoinData {
Pipe *leftInputPipe;
Pipe *rightInputPipe;
Pipe *outputPipe;
CNF *cnf;
Record *literal;
int runLength;
};
void *JoinThreadMethod(void *threadData);
void NestedBlockJoin(Pipe *leftInputPipe, Pipe *rightInputPipe, Pipe *outputPipe, int runLength);
void LoadVectorFromBlock(vector<Record *> *loadMe, Page *block, int blockLength);
void JoinUsingSortMerge(Pipe *leftInputPipe, Pipe *rightInputPipe, Pipe *outputPipe,
OrderMaker *leftOrderMaker, OrderMaker *rightOrderMaker);
void JoinTableBlocks(vector<Record *> *leftBlockRecords, vector<Record *> *rightBlockRecords, Pipe *outputPipe);
class Join : public RelationalOp {
public:
void Run(Pipe &inPipeL, Pipe &inPipeR, Pipe &outPipe, CNF &selOp, Record &literal);
};
struct DuplicateRemovalData {
Pipe *inputPipe;
Pipe *outputPipe;
Schema *schema;
int runLength;
};
void *DuplicateRemovalThreadMethod(void *threadData);
class DuplicateRemoval : public RelationalOp {
public:
void Run(Pipe &inPipe, Pipe &outPipe, Schema &mySchema);
};
struct SumData {
Pipe *inputPipe;
Pipe *outputPipe;
Function *computeMe;
int distinctFunc;
};
void *SumThreadMethod(void *threadData);
void SumAll(Pipe *inPipe, Pipe *outPipe, Function *computeMe);
void SumDistinct(Pipe *inPipe, Pipe *outPipe, Function *computeMe);
class Sum : public RelationalOp {
public:
void Run(Pipe &inPipe, Pipe &outPipe, Function &computeMe, int distinctFunc);
};
struct GroupByData {
Pipe *inputPipe;
Pipe *outputPipe;
OrderMaker *groupAtts;
Function *computeMe;
int distinctFunc;
int runLength;
};
void *GroupByThreadMethod(void *threadData);
void AddGroupByRecordToPipe(Pipe *outputPipe, Record *tableRecord, Record *sumRecord, OrderMaker *order);
class GroupBy : public RelationalOp {
public:
void Run(Pipe &inPipe, Pipe &outPipe, OrderMaker &groupAtts, Function &computeMe, int distinctFunc);
};
struct WriteOutData {
Pipe *inputPipe;
FILE *outputFile;
Schema *schema;
};
void *WriteOutThreadMethod(void *threadData);
class WriteOut : public RelationalOp {
public:
void Run(Pipe &inPipe, FILE *outFile, Schema &mySchema);
};
#endif