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