-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecutor.cc
98 lines (77 loc) · 1.96 KB
/
executor.cc
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <cmath>
#include <sys/time.h>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include "parameter.h"
#include "executor.h"
using namespace std;
using namespace bufmanager;
Buffer *Buffer::buffer_instance;
long Buffer::max_buffer_size = 0;
int Buffer::buffer_hit = 0;
int Buffer::buffer_miss = 0;
int Buffer::read_io = 0;
int Buffer::write_io = 0;
Buffer::Buffer(Simulation_Environment *_env)
{
// initialize accordingly
}
Buffer *Buffer::getBufferInstance(Simulation_Environment *_env)
{
if (buffer_instance == 0)
buffer_instance = new Buffer(_env);
return buffer_instance;
}
int WorkloadExecutor::search(Buffer* buffer_instance, int pageId)
{
return -1;
// Implement Search in the Bufferpool
}
int WorkloadExecutor::read(Buffer* buffer_instance, int pageId, int offset, int algorithm)
{
// Implement Read in the Bufferpool
return -1;
}
int WorkloadExecutor::write(Buffer* buffer_instance, int pageId, int offset, const string new_entry, int algorithm)
{
// Implement Write in the Bufferpool
return 1;
}
int WorkloadExecutor::unpin(Buffer* buffer_instance, int pageId)
{
// This is optional
return -1;
}
int Buffer::LRU()
{
int index = 0;
// Implement LRU
return index;
}
int Buffer::LRUWSR()
{
// Implement LRUWSR
return -1;
}
int Buffer::printBuffer()
{
return -1;
}
int Buffer::printStats()
{
Simulation_Environment* _env = Simulation_Environment::getInstance();
cout << "******************************************************" << endl;
cout << "Printing Stats..." << endl;
cout << "Number of operations: " << _env->num_operations << endl;
cout << "Buffer Hit: " << buffer_hit << endl;
cout << "Buffer Miss: " << buffer_miss << endl;
cout << "Read IO: " << read_io << endl;
cout << "Write IO: " << write_io << endl;
cout << "Global Clock: " << endl;
cout << "******************************************************" << endl;
return 0;
}