-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompactor.h
More file actions
57 lines (44 loc) · 1.45 KB
/
compactor.h
File metadata and controls
57 lines (44 loc) · 1.45 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
//===----------------------------------------------------------------------===//
// Compaction
//
// compactor.h
//
//
//===----------------------------------------------------------------------===//
#pragma once
#include "base.h"
#include "profiler.h"
#include "negative_feedback.hpp"
namespace compaction {
class NaiveCompactor {
public:
explicit NaiveCompactor(vector<AttributeType> &types)
: cached_chunk_(std::make_unique<DataChunk>(types)),
temp_chunk_(std::make_unique<DataChunk>(types)),
name_("0x" + std::to_string(size_t(this))) {}
void Compact(unique_ptr<DataChunk> &chunk);
inline void Flush(unique_ptr<DataChunk> &chunk) { chunk = std::move(cached_chunk_); }
private:
unique_ptr<DataChunk> cached_chunk_;
unique_ptr<DataChunk> temp_chunk_;
const string name_;
};
class DynamicCompactor {
public:
void SetThreshold(size_t threshold) { compact_threshold_ = threshold; }
size_t GetThreshold() const { return compact_threshold_; }
public:
explicit DynamicCompactor(const vector<AttributeType> &types)
: cached_chunk_(std::make_unique<DataChunk>(types)),
name_("[Dynamic Compact] 0x" + std::to_string(size_t(this))) {}
void Compact(unique_ptr<DataChunk> &chunk);
inline void Flush(unique_ptr<DataChunk> &chunk) {
chunk = std::move(cached_chunk_);
}
private:
size_t compact_threshold_;
unique_ptr<DataChunk> cached_chunk_;
const string name_;
Profiler profiler_;
};
}