-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExternalRun.h
36 lines (33 loc) · 981 Bytes
/
ExternalRun.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
#pragma once
#include "Buffer.h"
#include "params.h"
#include "Metrics.h"
#include <fstream>
#include <string>
using std::string;
using std::ifstream;
class ExternalRun
{
public:
static u_int64_t READ_AHEAD_SIZE;
static double READ_AHEAD_THRESHOLD;
u_int8_t storage;
ExternalRun (const string &runFileName, RowSize recordSize);
~ExternalRun ();
byte * next(); // nullptr if the run is empty
byte * peek(); // nullptr if the run is empty
private:
Buffer * _currentPage;
Buffer * _readAheadPage;
string const _runFileName;
ifstream _runFile;
u_int32_t _pageSize; // max. 500 KB = 2^19, changes when switching between SSD and HDD
RowSize const _recordSize;
u_int64_t _produced;
u_int64_t switchPoint;
u_int8_t nextStorage;
u_int32_t _fillPage(Buffer * page);
Buffer * getBuffer();
bool refillCurrentPage(); // Either by filling the current page or switching to the read-ahead page
void readAhead();
};