]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/include/rocksdb/universal_compaction.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / include / rocksdb / universal_compaction.h
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
7c673cae 5
11fdf7f2 6#pragma once
7c673cae
FG
7
8#include <stdint.h>
9#include <climits>
10#include <vector>
11
12namespace rocksdb {
13
14//
15// Algorithm used to make a compaction request stop picking new files
16// into a single compaction run
17//
18enum CompactionStopStyle {
19 kCompactionStopStyleSimilarSize, // pick files of similar size
20 kCompactionStopStyleTotalSize // total size of picked files > next file
21};
22
23class CompactionOptionsUniversal {
24 public:
25
11fdf7f2 26 // Percentage flexibility while comparing file size. If the candidate file(s)
7c673cae
FG
27 // size is 1% smaller than the next file's size, then include next file into
28 // this candidate set. // Default: 1
29 unsigned int size_ratio;
30
31 // The minimum number of files in a single compaction run. Default: 2
32 unsigned int min_merge_width;
33
34 // The maximum number of files in a single compaction run. Default: UINT_MAX
35 unsigned int max_merge_width;
36
37 // The size amplification is defined as the amount (in percentage) of
38 // additional storage needed to store a single byte of data in the database.
39 // For example, a size amplification of 2% means that a database that
40 // contains 100 bytes of user-data may occupy upto 102 bytes of
41 // physical storage. By this definition, a fully compacted database has
42 // a size amplification of 0%. Rocksdb uses the following heuristic
43 // to calculate size amplification: it assumes that all files excluding
44 // the earliest file contribute to the size amplification.
45 // Default: 200, which means that a 100 byte database could require upto
46 // 300 bytes of storage.
47 unsigned int max_size_amplification_percent;
48
49 // If this option is set to be -1 (the default value), all the output files
50 // will follow compression type specified.
51 //
52 // If this option is not negative, we will try to make sure compressed
53 // size is just above this value. In normal cases, at least this percentage
54 // of data will be compressed.
55 // When we are compacting to a new file, here is the criteria whether
56 // it needs to be compressed: assuming here are the list of files sorted
57 // by generation time:
58 // A1...An B1...Bm C1...Ct
59 // where A1 is the newest and Ct is the oldest, and we are going to compact
60 // B1...Bm, we calculate the total size of all the files as total_size, as
61 // well as the total size of C1...Ct as total_C, the compaction output file
62 // will be compressed iff
63 // total_C / total_size < this percentage
64 // Default: -1
65 int compression_size_percent;
66
67 // The algorithm used to stop picking files into a single compaction run
68 // Default: kCompactionStopStyleTotalSize
69 CompactionStopStyle stop_style;
70
71 // Option to optimize the universal multi level compaction by enabling
72 // trivial move for non overlapping files.
73 // Default: false
74 bool allow_trivial_move;
75
76 // Default set of parameters
77 CompactionOptionsUniversal()
78 : size_ratio(1),
79 min_merge_width(2),
80 max_merge_width(UINT_MAX),
81 max_size_amplification_percent(200),
82 compression_size_percent(-1),
83 stop_style(kCompactionStopStyleTotalSize),
84 allow_trivial_move(false) {}
85};
86
87} // namespace rocksdb