-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
76 lines (64 loc) · 2.47 KB
/
main.cpp
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
#include <cstdlib>
#include "dbtproj.h"
#include <cstring>
#include <cstdio>
#include <time.h>
using namespace std;
int main(int argc, char** argv) {
int nmem_blocks = atoi(argv[2]);
clock_t start, stop;
double t = 0.0;
unsigned int nsorted_segs=0, npasses=0, nios=0,nres=0,nunique=0;
block_t *buffer = new block_t[nmem_blocks];
int field = atoi(argv[3]);
//call Mergesort
start = clock();
cout<<"Running Mergesort...\n";
MergeSort(argv[1], field, buffer, nmem_blocks,"MergesortOutput.bin", &nsorted_segs, &npasses, &nios);
stop = clock();
t = (double) (stop-start)/CLOCKS_PER_SEC;
cout<<"Mergesort run:";
cout<<"\nNumber of sorted segments: "<<nsorted_segs;
cout<<"\nNumber of passes: "<<npasses;
cout<<"\nNumber of I/Os: "<<nios;
cout<<"\nRuntime: "<<t<<"\n\n";
//call EliminateDuplicates
nios = 0;
start = clock();
cout<<"Running Eliminate Duplicates...\n";
EliminateDuplicates(argv[1], field, buffer, nmem_blocks, "EliminateOutput.bin", &nunique, &nios);
stop = clock();
t = (double) (stop-start)/CLOCKS_PER_SEC;
cout<<"Eliminate Duplicates run:";
cout<<"\nNumber of unique records: "<<nunique;
cout<<"\nNumber of I/Os: "<<nios;
cout<<"\nRuntime: "<<t<<"\n\n";
if(argv[4] != NULL)
{
//call Mergejoin if there is a second file
nios = 0;
start = clock();
cout<<"Running Mergejoin...\n";
MergeJoin(argv[1], argv[4], field, buffer, nmem_blocks, "MergeJoinOutput.bin", &nres, &nios);
stop = clock();
t = (double) (stop-start)/CLOCKS_PER_SEC;
cout<<"MergeJoin run:";
cout<<"\nNumber of pairs: "<<nres;
cout<<"\nNumber of I/Os: "<<nios;
cout<<"\nRuntime: "<<t<<"\n\n";
//call Hashjoin if there is a second file
nios = 0;
nres = 0;
start = clock();
cout<<"Running Hashjoin...\n";
HashJoin(argv[1], argv[4], field, buffer, nmem_blocks, "HashJoinOutput.bin", &nres, &nios);
stop = clock();
t = (double) (stop-start)/CLOCKS_PER_SEC;
cout<<"HashJoin run:";
cout<<"\nNumber of pairs: "<<nres;
cout<<"\nNumber of I/Os: "<<nios;
cout<<"\nRuntime: "<<t<<"\n\n";
}
delete[] buffer;
return 0;
}