blob: b4f453b058717f399c032c5aa64275279541aae9 (
plain)
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
|
/*
* include/framework/reconstruction/FloodL0Policy.h
*
* Copyright (C) 2023-2024 Douglas B. Rumbaugh <drumbaugh@psu.edu>
* Dong Xie <dongx@psu.edu>
*
* Distributed under the Modified BSD License.
*
*/
#pragma once
#include <cmath>
#include "framework/reconstruction/ReconstructionPolicy.h"
#include "framework/scheduling/Version.h"
#include "util/types.h"
namespace de {
template <ShardInterface ShardType, QueryInterface<ShardType> QueryType>
class FloodL0Policy : public ReconstructionPolicy<ShardType, QueryType> {
typedef std::vector<std::shared_ptr<InternalLevel<ShardType, QueryType>>>
LevelVector;
public:
FloodL0Policy(size_t buffer_size) : m_buffer_size(buffer_size) {}
ReconstructionVector
get_reconstruction_tasks(const Version<ShardType, QueryType> *version) const override {
ReconstructionVector reconstructions;
return reconstructions;
}
ReconstructionVector
get_flush_tasks(const Version<ShardType, QueryType> *version) const override {
ReconstructionVector reconstructions;
return reconstructions;
}
private:
level_index find_reconstruction_target(LevelVector &levels) const {
level_index target_level = invalid_level_idx;
size_t incoming_records = m_buffer_size;
for (level_index i = 0; i < (level_index)levels.size(); i++) {
if (levels[i]->get_record_count() + incoming_records < capacity(i)) {
target_level = i;
break;
}
incoming_records = levels[i]->get_record_count();
}
return target_level;
}
inline size_t capacity(level_index level) const {
return m_buffer_size * pow(m_scale_factor, level + 1);
}
size_t m_scale_factor;
size_t m_buffer_size;
};
} // namespace de
|