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