-
Notifications
You must be signed in to change notification settings - Fork 0
/
BigQ.h
executable file
·78 lines (64 loc) · 1.53 KB
/
BigQ.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
#ifndef BIGQ_H
#define BIGQ_H
#include <pthread.h>
#include <iostream>
#include "Pipe.h"
#include "File.h"
#include "Record.h"
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
using namespace std;
//*********************
static int filenameCount = 0;
class RecordComparison {
public:
OrderMaker *order;
Record record;
int PageNumber;
RecordComparison() {
}
RecordComparison(OrderMaker *ord) {
order = ord;
}
bool operator ()(RecordComparison *left, RecordComparison *right) const {
ComparisonEngine comp;
if (comp.Compare(&(left->record), &(right->record), order) >= 0) // compare returns 0 is left is less than right
return true;
else
return false;
}
};
class Compare {
private:
OrderMaker *sortorder;
public:
Compare(OrderMaker *sortorder) {
this->sortorder = sortorder;
}
bool operator() (Record *left, Record *right) const {
ComparisonEngine comp;
if (comp.Compare(left, right, (sortorder)) < 0) {
return true;
} else {
return false;
}
}
};
class BigQ {
private:
Pipe *inputPipe;
Pipe *outputPipe;
OrderMaker *sortorder;
int runLength;
char fileName[10];
static void *start(void * arg);
int generateRun(vector<Record*> &recordArray, int lastPageCount);
void mergeSort(int runInfo[], int numRuns);
public:
BigQ(Pipe &in, Pipe &out, OrderMaker &sortorder, int runlen);
~BigQ();
};
#endif