-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortedDBFile.h
More file actions
72 lines (52 loc) · 1.66 KB
/
Copy pathSortedDBFile.h
File metadata and controls
72 lines (52 loc) · 1.66 KB
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
#ifndef DATABASE_IMPLEMENTATION_SORTEDDBFILE_H
#define DATABASE_IMPLEMENTATION_SORTEDDBFILE_H
#include "GenericDBFile.h"
#include "DBFile.h"
#include "BigQ.h"
#include "Pipe.h"
class SortedDBFile : public GenericDBFile {
private:
/**
* Used to sort records added into the DBFile
*/
BigQ *bigQ;
/**
* Insert records into in, whenever a new record is added
*/
Pipe *in;
/**
* Fetches sorted records through out
*/
Pipe *out;
/**
* No need to initialize query again, as we consider same CNF will be passed in consecutive GetNext calls
*/
bool queryInitialized = false;
/**
* We construct query from CNF and SortOrder of file which is used for binary search b/w pages
*/
OrderMaker *query;
/**
* The information related to OrderMaker and run length passed in Create method
*/
SortInfo *sortInfo;
void WriteMetadata(const char *fpath, fType file_type, void *startup) override;
void ReadMetadata(const char *fpath) override;
void FlushPage() override;
/**
* Appends record into the page
*/
static void AppendRecord(File &tempFile, Page &tempPage, Record &addme, off_t &writePage);
/**
* Perform binary search upon query to find the page to start reading
*/
int PerformBinarySearch(CNF &cnf, Record &literal);
public:
SortedDBFile();
~SortedDBFile() override;
int Create(const char *fpath, fType file_type, void *startup) override;
void MoveFirst() override;
void Add(Record &addme) override;
int GetNext(Record &fetchme, CNF &cnf, Record &literal) override;
};
#endif //DATABASE_IMPLEMENTATION_SORTEDDBFILE_H