]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/options/cf_options.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / options / cf_options.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 #pragma once
7
8 #include <string>
9 #include <vector>
10
11 #include "db/dbformat.h"
12 #include "options/db_options.h"
13 #include "rocksdb/options.h"
14 #include "util/compression.h"
15
16 namespace rocksdb {
17
18 // ImmutableCFOptions is a data struct used by RocksDB internal. It contains a
19 // subset of Options that should not be changed during the entire lifetime
20 // of DB. Raw pointers defined in this struct do not have ownership to the data
21 // they point to. Options contains shared_ptr to these data.
22 struct ImmutableCFOptions {
23 ImmutableCFOptions();
24 explicit ImmutableCFOptions(const Options& options);
25
26 ImmutableCFOptions(const ImmutableDBOptions& db_options,
27 const ColumnFamilyOptions& cf_options);
28
29 CompactionStyle compaction_style;
30
31 CompactionPri compaction_pri;
32
33 CompactionOptionsUniversal compaction_options_universal;
34 CompactionOptionsFIFO compaction_options_fifo;
35
36 const SliceTransform* prefix_extractor;
37
38 const Comparator* user_comparator;
39 InternalKeyComparator internal_comparator;
40
41 MergeOperator* merge_operator;
42
43 const CompactionFilter* compaction_filter;
44
45 CompactionFilterFactory* compaction_filter_factory;
46
47 int min_write_buffer_number_to_merge;
48
49 int max_write_buffer_number_to_maintain;
50
51 bool inplace_update_support;
52
53 UpdateStatus (*inplace_callback)(char* existing_value,
54 uint32_t* existing_value_size,
55 Slice delta_value,
56 std::string* merged_value);
57
58 Logger* info_log;
59
60 Statistics* statistics;
61
62 InfoLogLevel info_log_level;
63
64 Env* env;
65
66 // Allow the OS to mmap file for reading sst tables. Default: false
67 bool allow_mmap_reads;
68
69 // Allow the OS to mmap file for writing. Default: false
70 bool allow_mmap_writes;
71
72 std::vector<DbPath> db_paths;
73
74 MemTableRepFactory* memtable_factory;
75
76 TableFactory* table_factory;
77
78 Options::TablePropertiesCollectorFactories
79 table_properties_collector_factories;
80
81 bool advise_random_on_open;
82
83 // This options is required by PlainTableReader. May need to move it
84 // to PlainTalbeOptions just like bloom_bits_per_key
85 uint32_t bloom_locality;
86
87 bool purge_redundant_kvs_while_flush;
88
89 bool use_fsync;
90
91 std::vector<CompressionType> compression_per_level;
92
93 CompressionType bottommost_compression;
94
95 CompressionOptions compression_opts;
96
97 bool level_compaction_dynamic_level_bytes;
98
99 Options::AccessHint access_hint_on_compaction_start;
100
101 bool new_table_reader_for_compaction_inputs;
102
103 size_t compaction_readahead_size;
104
105 int num_levels;
106
107 bool optimize_filters_for_hits;
108
109 bool force_consistency_checks;
110
111 // A vector of EventListeners which call-back functions will be called
112 // when specific RocksDB event happens.
113 std::vector<std::shared_ptr<EventListener>> listeners;
114
115 std::shared_ptr<Cache> row_cache;
116
117 uint32_t max_subcompactions;
118
119 const SliceTransform* memtable_insert_with_hint_prefix_extractor;
120 };
121
122 struct MutableCFOptions {
123 explicit MutableCFOptions(const ColumnFamilyOptions& options)
124 : write_buffer_size(options.write_buffer_size),
125 max_write_buffer_number(options.max_write_buffer_number),
126 arena_block_size(options.arena_block_size),
127 memtable_prefix_bloom_size_ratio(
128 options.memtable_prefix_bloom_size_ratio),
129 memtable_huge_page_size(options.memtable_huge_page_size),
130 max_successive_merges(options.max_successive_merges),
131 inplace_update_num_locks(options.inplace_update_num_locks),
132 disable_auto_compactions(options.disable_auto_compactions),
133 soft_pending_compaction_bytes_limit(
134 options.soft_pending_compaction_bytes_limit),
135 hard_pending_compaction_bytes_limit(
136 options.hard_pending_compaction_bytes_limit),
137 level0_file_num_compaction_trigger(
138 options.level0_file_num_compaction_trigger),
139 level0_slowdown_writes_trigger(options.level0_slowdown_writes_trigger),
140 level0_stop_writes_trigger(options.level0_stop_writes_trigger),
141 max_compaction_bytes(options.max_compaction_bytes),
142 target_file_size_base(options.target_file_size_base),
143 target_file_size_multiplier(options.target_file_size_multiplier),
144 max_bytes_for_level_base(options.max_bytes_for_level_base),
145 max_bytes_for_level_multiplier(options.max_bytes_for_level_multiplier),
146 max_bytes_for_level_multiplier_additional(
147 options.max_bytes_for_level_multiplier_additional),
148 max_sequential_skip_in_iterations(
149 options.max_sequential_skip_in_iterations),
150 paranoid_file_checks(options.paranoid_file_checks),
151 report_bg_io_stats(options.report_bg_io_stats),
152 compression(options.compression) {
153 RefreshDerivedOptions(options.num_levels, options.compaction_style);
154 }
155
156 MutableCFOptions()
157 : write_buffer_size(0),
158 max_write_buffer_number(0),
159 arena_block_size(0),
160 memtable_prefix_bloom_size_ratio(0),
161 memtable_huge_page_size(0),
162 max_successive_merges(0),
163 inplace_update_num_locks(0),
164 disable_auto_compactions(false),
165 soft_pending_compaction_bytes_limit(0),
166 hard_pending_compaction_bytes_limit(0),
167 level0_file_num_compaction_trigger(0),
168 level0_slowdown_writes_trigger(0),
169 level0_stop_writes_trigger(0),
170 max_compaction_bytes(0),
171 target_file_size_base(0),
172 target_file_size_multiplier(0),
173 max_bytes_for_level_base(0),
174 max_bytes_for_level_multiplier(0),
175 max_sequential_skip_in_iterations(0),
176 paranoid_file_checks(false),
177 report_bg_io_stats(false),
178 compression(Snappy_Supported() ? kSnappyCompression : kNoCompression) {}
179
180 // Must be called after any change to MutableCFOptions
181 void RefreshDerivedOptions(int num_levels, CompactionStyle compaction_style);
182
183 void RefreshDerivedOptions(const ImmutableCFOptions& ioptions) {
184 RefreshDerivedOptions(ioptions.num_levels, ioptions.compaction_style);
185 }
186
187 // Get the max file size in a given level.
188 uint64_t MaxFileSizeForLevel(int level) const;
189 int MaxBytesMultiplerAdditional(int level) const {
190 if (level >=
191 static_cast<int>(max_bytes_for_level_multiplier_additional.size())) {
192 return 1;
193 }
194 return max_bytes_for_level_multiplier_additional[level];
195 }
196
197 void Dump(Logger* log) const;
198
199 // Memtable related options
200 size_t write_buffer_size;
201 int max_write_buffer_number;
202 size_t arena_block_size;
203 double memtable_prefix_bloom_size_ratio;
204 size_t memtable_huge_page_size;
205 size_t max_successive_merges;
206 size_t inplace_update_num_locks;
207
208 // Compaction related options
209 bool disable_auto_compactions;
210 uint64_t soft_pending_compaction_bytes_limit;
211 uint64_t hard_pending_compaction_bytes_limit;
212 int level0_file_num_compaction_trigger;
213 int level0_slowdown_writes_trigger;
214 int level0_stop_writes_trigger;
215 uint64_t max_compaction_bytes;
216 uint64_t target_file_size_base;
217 int target_file_size_multiplier;
218 uint64_t max_bytes_for_level_base;
219 double max_bytes_for_level_multiplier;
220 std::vector<int> max_bytes_for_level_multiplier_additional;
221
222 // Misc options
223 uint64_t max_sequential_skip_in_iterations;
224 bool paranoid_file_checks;
225 bool report_bg_io_stats;
226 CompressionType compression;
227
228 // Derived options
229 // Per-level target file size.
230 std::vector<uint64_t> max_file_size;
231 };
232
233 uint64_t MultiplyCheckOverflow(uint64_t op1, double op2);
234
235 } // namespace rocksdb