-
Notifications
You must be signed in to change notification settings - Fork 5
/
a2-1test.h
116 lines (98 loc) · 3.23 KB
/
a2-1test.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
#ifndef TEST_H
#define TEST_H
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include "Pipe.h"
#include "DBFile.h"
#include "Record.h"
using namespace std;
// make sure that the information below is correct
char *catalog_path = "catalog";
//char *tpch_dir ="/cise/tmp/dbi_sp11/DATA/10M/"; // dir where dbgen tpch files (extension *.tbl) can be found
char *tpch_dir ="/Users/morganbauer/Downloads/tpch_2_14_3/dbgen/"; // dir where dbgen tpch files (extension *.tbl) can be found
char *dbfile_dir = "/tmp/mhb/"; // dir where binary heap files should be stored
extern "C" {
int yyparse(void); // defined in y.tab.c
}
extern struct AndList *final;
typedef struct {
Pipe *pipe;
OrderMaker *order;
bool print;
bool write;
}testutil;
class relation {
private:
char *rname;
char *prefix;
char rpath[100];
Schema *rschema;
public:
relation (char *_name, Schema *_schema, char *_prefix) :
rname (_name), rschema (_schema), prefix (_prefix) {
sprintf (rpath, "%s%s.bin", prefix, rname);
}
~relation()
{
delete rschema;
}
char* name () { return rname; }
char* path () { return rpath; }
Schema* schema () { return rschema;}
void info () {
cout << " relation info\n";
cout << "\t name: " << name () << endl;
cout << "\t path: " << path () << endl;
}
void get_cnf (CNF &cnf_pred, Record &literal) {
cout << " Enter CNF predicate (when done press ctrl-D):\n\t";
if (yyparse() != 0) {
cout << "Can't parse your CNF.\n";
exit (1);
}
cnf_pred.GrowFromParseTree (final, schema (), literal); // constructs CNF predicate
}
void get_sort_order (OrderMaker &sortorder) {
cout << "\n specify sort ordering (when done press ctrl-D):\n\t ";
if (yyparse() != 0) {
cout << "Can't parse your sort CNF.\n";
exit (1);
}
cout << " \n";
Record literal;
CNF sort_pred;
sort_pred.GrowFromParseTree (final, schema (), literal); // constructs CNF predicate
OrderMaker dummy;
sort_pred.GetSortOrders (sortorder, dummy);
}
};
relation *rel;
char *supplier = "supplier";
char *partsupp = "partsupp";
char *part = "part";
char *nation = "nation";
char *customer = "customer";
char *orders = "orders";
char *region = "region";
char *lineitem = "lineitem";
relation *s, *p, *ps, *n, *li, *r, *o, *c;
void setup () {
cout << " \n** IMPORTANT: MAKE SURE THE INFORMATION BELOW IS CORRECT **\n";
cout << " catalog location: \t" << catalog_path << endl;
cout << " tpch files dir: \t" << tpch_dir << endl;
cout << " heap files dir: \t" << dbfile_dir << endl;
cout << " \n\n";
s = new relation (supplier, new Schema (catalog_path, supplier), dbfile_dir);
ps = new relation (partsupp, new Schema (catalog_path, partsupp), dbfile_dir);
p = new relation (part, new Schema (catalog_path, part), dbfile_dir);
n = new relation (nation, new Schema (catalog_path, nation), dbfile_dir);
li = new relation (lineitem, new Schema (catalog_path, lineitem), dbfile_dir);
r = new relation (region, new Schema (catalog_path, region), dbfile_dir);
o = new relation (orders, new Schema (catalog_path, orders), dbfile_dir);
c = new relation (customer, new Schema (catalog_path, customer), dbfile_dir);
}
void cleanup () {
delete s, p, ps, n, li, r, o, c;
}
#endif