-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRelOp.h
135 lines (112 loc) · 3.46 KB
/
RelOp.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
#ifndef REL_OP_H
#define REL_OP_H
#include "DBFile.h"
#include "Function.h"
#include "Pipe.h"
#include "Record.h"
#include "Schema.h"
class RelationalOp {
public:
// blocks the caller until the particular relational operator
// has run to completion
virtual void WaitUntilDone() = 0;
// tell us how much internal memory the operation can use
virtual void Use_n_Pages(int n) = 0;
const char *GenTempFileName();
void WritePipeToFile(DBFile *dbfile, Pipe *pipe);
};
class SelectFile : public RelationalOp {
friend void *SelectFileProxyFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
Record *tempRec = new Record;
public:
void *Worker(void *args);
void Run(DBFile &inFile, Pipe &outPipe, CNF &selOp, Record &literal);
void WaitUntilDone();
void Use_n_Pages(int n);
};
class SelectPipe : public RelationalOp {
friend void *SelectPipeProxyFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
Record *tempRec = new Record;
public:
void *Worker(void *args);
void Run(Pipe &inPipe, Pipe &outPipe, CNF &selOp, Record &literal);
void WaitUntilDone();
void Use_n_Pages(int n);
};
class Project : public RelationalOp {
friend void *ProjectProxyFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
// Record *tempRec = new Record;
public:
void *Worker(void *args);
void Run(Pipe &inPipe, Pipe &outPipe, int *keepMe, int numAttsInput, int numAttsOutput);
void WaitUntilDone();
void Use_n_Pages(int n) {}
};
class Join : public RelationalOp {
friend void *JoinProxyFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
Record *tempRec = new Record;
int num_pages = 10;
public:
void *Worker(void *args);
void Run(Pipe &inPipeL, Pipe &inPipeR, Pipe &outPipe, CNF &selOp, Record &literal);
void WaitUntilDone();
void Use_n_Pages(int n);
};
class DuplicateRemoval : public RelationalOp {
friend void *DuplicateRemovalProxyFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
Record *tempRec = new Record;
int num_pages = 10;
public:
void *Worker(void *args);
void Run(Pipe &inPipe, Pipe &outPipe, Schema &mySchema);
void WaitUntilDone();
void Use_n_Pages(int n);
};
class Sum : public RelationalOp {
friend void *SumProxyFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
Record *tempRec = new Record;
int num_pages = 10;
public:
void *Worker(void *args);
void Run(Pipe &inPipe, Pipe &outPipe, Function &computeMe);
void WaitUntilDone();
void Use_n_Pages(int n);
};
class GroupBy : public RelationalOp {
friend void *GroupByFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
Record *tempRec = new Record;
int num_pages= 10;
void BuildRecord(Record *sum, Record *record, Type result, int result_i, double result_d, OrderMaker *groupAtts);
public:
void *Worker(void *args);
void Run(Pipe &inPipe, Pipe &outPipe, OrderMaker &groupAtts, Function &computeMe);
void WaitUntilDone();
void Use_n_Pages(int n);
};
class WriteOut : public RelationalOp {
friend void *GroupByFunction(void *foo_ptr, void *args);
private:
pthread_t thread;
Record *tempRec = new Record;
int num_pages = 10;
public:
void *Worker(void *args);
void Run(Pipe &inPipe, FILE *outFile, Schema &mySchema);
void WaitUntilDone();
void Use_n_Pages(int n) {}
};
#endif