-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSortedDBFile.h
50 lines (35 loc) · 1.04 KB
/
SortedDBFile.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
#ifndef SORTED_H
#define SORTED_H
#include "GenericDBFile.h"
#include "File.h"
#include "BigQ.h"
#include "HeapDBFile.h"
#include "Pipe.h"
#include <cstring>
struct SortInfo {
OrderMaker *myOrder;
int runLength;
};
class SortedDBFile : public GenericDBFile {
private:
SortInfo* sortInfo;
Pipe* inputPipe;
Pipe* outputPipe;
OrderMaker* queryOrderMaker;
bool useSameQueryOrderMaker;
void MergeCurrentFileAndBigQOutput();
int GetNextForSortedFile(Record &fetchme, CNF &cnf, Record &literal);
int CheckForQuery(Record &fetchme, Record &literal);
bool CheckForCNF(Record &fetchme, CNF &cnf, Record &literal);
off_t BinarySearch(off_t low, off_t high, Record &literal);
public:
// constructor and destructor
explicit SortedDBFile(SortInfo* sortInfo);
~SortedDBFile ();
void SwitchToWriteMode();
void SwitchToReadMode();
void AddToDBFile(Record &addme);
int GetNextFromDBFile(Record &fetchme);
int GetNextFromDBFile(Record &fetchme, CNF &cnf, Record &literal);
};
#endif