]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/options/options_helper.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / rocksdb / options / options_helper.h
CommitLineData
7c673cae
FG
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 <map>
9#include <stdexcept>
10#include <string>
11#include <vector>
12
13#include "options/cf_options.h"
14#include "options/db_options.h"
15#include "rocksdb/options.h"
16#include "rocksdb/status.h"
17#include "rocksdb/table.h"
18
19namespace rocksdb {
20
21DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
22 const MutableDBOptions& mutable_db_options);
23
24ColumnFamilyOptions BuildColumnFamilyOptions(
25 const ColumnFamilyOptions& ioptions,
26 const MutableCFOptions& mutable_cf_options);
27
28static std::map<CompactionStyle, std::string> compaction_style_to_string = {
29 {kCompactionStyleLevel, "kCompactionStyleLevel"},
30 {kCompactionStyleUniversal, "kCompactionStyleUniversal"},
31 {kCompactionStyleFIFO, "kCompactionStyleFIFO"},
32 {kCompactionStyleNone, "kCompactionStyleNone"}};
33
34static std::map<CompactionPri, std::string> compaction_pri_to_string = {
35 {kByCompensatedSize, "kByCompensatedSize"},
36 {kOldestLargestSeqFirst, "kOldestLargestSeqFirst"},
37 {kOldestSmallestSeqFirst, "kOldestSmallestSeqFirst"},
38 {kMinOverlappingRatio, "kMinOverlappingRatio"}};
39
40#ifndef ROCKSDB_LITE
41
42Status GetMutableOptionsFromStrings(
43 const MutableCFOptions& base_options,
44 const std::unordered_map<std::string, std::string>& options_map,
45 MutableCFOptions* new_options);
46
47Status GetMutableDBOptionsFromStrings(
48 const MutableDBOptions& base_options,
49 const std::unordered_map<std::string, std::string>& options_map,
50 MutableDBOptions* new_options);
51
52Status GetTableFactoryFromMap(
53 const std::string& factory_name,
54 const std::unordered_map<std::string, std::string>& opt_map,
55 std::shared_ptr<TableFactory>* table_factory);
56
57Status GetStringFromTableFactory(std::string* opts_str, const TableFactory* tf,
58 const std::string& delimiter = "; ");
59
60enum class OptionType {
61 kBoolean,
62 kInt,
63 kVectorInt,
64 kUInt,
65 kUInt32T,
66 kUInt64T,
67 kSizeT,
68 kString,
69 kDouble,
70 kCompactionStyle,
71 kCompactionPri,
72 kSliceTransform,
73 kCompressionType,
74 kVectorCompressionType,
75 kTableFactory,
76 kComparator,
77 kCompactionFilter,
78 kCompactionFilterFactory,
79 kMergeOperator,
80 kMemTableRepFactory,
81 kBlockBasedTableIndexType,
82 kFilterPolicy,
83 kFlushBlockPolicyFactory,
84 kChecksumType,
85 kEncodingType,
86 kWALRecoveryMode,
87 kAccessHint,
88 kInfoLogLevel,
89 kUnknown
90};
91
92enum class OptionVerificationType {
93 kNormal,
94 kByName, // The option is pointer typed so we can only verify
95 // based on it's name.
96 kByNameAllowNull, // Same as kByName, but it also allows the case
97 // where one of them is a nullptr.
98 kDeprecated // The option is no longer used in rocksdb. The RocksDB
99 // OptionsParser will still accept this option if it
100 // happen to exists in some Options file. However, the
101 // parser will not include it in serialization and
102 // verification processes.
103};
104
105// A struct for storing constant option information such as option name,
106// option type, and offset.
107struct OptionTypeInfo {
108 int offset;
109 OptionType type;
110 OptionVerificationType verification;
111 bool is_mutable;
112 int mutable_offset;
113};
114
115// A helper function that converts "opt_address" to a std::string
116// based on the specified OptionType.
117bool SerializeSingleOptionHelper(const char* opt_address,
118 const OptionType opt_type, std::string* value);
119
120// In addition to its public version defined in rocksdb/convenience.h,
121// this further takes an optional output vector "unsupported_options_names",
122// which stores the name of all the unsupported options specified in "opts_map".
123Status GetDBOptionsFromMapInternal(
124 const DBOptions& base_options,
125 const std::unordered_map<std::string, std::string>& opts_map,
126 DBOptions* new_options, bool input_strings_escaped,
127 std::vector<std::string>* unsupported_options_names = nullptr);
128
129// In addition to its public version defined in rocksdb/convenience.h,
130// this further takes an optional output vector "unsupported_options_names",
131// which stores the name of all the unsupported options specified in "opts_map".
132Status GetColumnFamilyOptionsFromMapInternal(
133 const ColumnFamilyOptions& base_options,
134 const std::unordered_map<std::string, std::string>& opts_map,
135 ColumnFamilyOptions* new_options, bool input_strings_escaped,
136 std::vector<std::string>* unsupported_options_names = nullptr);
137
138static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
139 /*
140 // not yet supported
141 Env* env;
142 std::shared_ptr<Cache> row_cache;
143 std::shared_ptr<DeleteScheduler> delete_scheduler;
144 std::shared_ptr<Logger> info_log;
145 std::shared_ptr<RateLimiter> rate_limiter;
146 std::shared_ptr<Statistics> statistics;
147 std::vector<DbPath> db_paths;
148 std::vector<std::shared_ptr<EventListener>> listeners;
149 */
150 {"advise_random_on_open",
151 {offsetof(struct DBOptions, advise_random_on_open), OptionType::kBoolean,
152 OptionVerificationType::kNormal, false, 0}},
153 {"allow_mmap_reads",
154 {offsetof(struct DBOptions, allow_mmap_reads), OptionType::kBoolean,
155 OptionVerificationType::kNormal, false, 0}},
156 {"allow_fallocate",
157 {offsetof(struct DBOptions, allow_fallocate), OptionType::kBoolean,
158 OptionVerificationType::kNormal, false, 0}},
159 {"allow_mmap_writes",
160 {offsetof(struct DBOptions, allow_mmap_writes), OptionType::kBoolean,
161 OptionVerificationType::kNormal, false, 0}},
162 {"use_direct_reads",
163 {offsetof(struct DBOptions, use_direct_reads), OptionType::kBoolean,
164 OptionVerificationType::kNormal, false, 0}},
165 {"use_direct_writes",
166 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, false, 0}},
167 {"use_direct_io_for_flush_and_compaction",
168 {offsetof(struct DBOptions, use_direct_io_for_flush_and_compaction),
169 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
170 {"allow_2pc",
171 {offsetof(struct DBOptions, allow_2pc), OptionType::kBoolean,
172 OptionVerificationType::kNormal, false, 0}},
173 {"allow_os_buffer",
174 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, true, 0}},
175 {"create_if_missing",
176 {offsetof(struct DBOptions, create_if_missing), OptionType::kBoolean,
177 OptionVerificationType::kNormal, false, 0}},
178 {"create_missing_column_families",
179 {offsetof(struct DBOptions, create_missing_column_families),
180 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
181 {"disableDataSync",
182 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, false, 0}},
183 {"disable_data_sync", // for compatibility
184 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, false, 0}},
185 {"enable_thread_tracking",
186 {offsetof(struct DBOptions, enable_thread_tracking), OptionType::kBoolean,
187 OptionVerificationType::kNormal, false, 0}},
188 {"error_if_exists",
189 {offsetof(struct DBOptions, error_if_exists), OptionType::kBoolean,
190 OptionVerificationType::kNormal, false, 0}},
191 {"is_fd_close_on_exec",
192 {offsetof(struct DBOptions, is_fd_close_on_exec), OptionType::kBoolean,
193 OptionVerificationType::kNormal, false, 0}},
194 {"paranoid_checks",
195 {offsetof(struct DBOptions, paranoid_checks), OptionType::kBoolean,
196 OptionVerificationType::kNormal, false, 0}},
197 {"skip_log_error_on_recovery",
198 {offsetof(struct DBOptions, skip_log_error_on_recovery),
199 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
200 {"skip_stats_update_on_db_open",
201 {offsetof(struct DBOptions, skip_stats_update_on_db_open),
202 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
203 {"new_table_reader_for_compaction_inputs",
204 {offsetof(struct DBOptions, new_table_reader_for_compaction_inputs),
205 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
206 {"compaction_readahead_size",
207 {offsetof(struct DBOptions, compaction_readahead_size), OptionType::kSizeT,
208 OptionVerificationType::kNormal, false, 0}},
209 {"random_access_max_buffer_size",
210 {offsetof(struct DBOptions, random_access_max_buffer_size),
211 OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}},
212 {"writable_file_max_buffer_size",
213 {offsetof(struct DBOptions, writable_file_max_buffer_size),
214 OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}},
215 {"use_adaptive_mutex",
216 {offsetof(struct DBOptions, use_adaptive_mutex), OptionType::kBoolean,
217 OptionVerificationType::kNormal, false, 0}},
218 {"use_fsync",
219 {offsetof(struct DBOptions, use_fsync), OptionType::kBoolean,
220 OptionVerificationType::kNormal, false, 0}},
221 {"max_background_compactions",
222 {offsetof(struct DBOptions, max_background_compactions), OptionType::kInt,
223 OptionVerificationType::kNormal, true,
224 offsetof(struct MutableDBOptions, max_background_compactions)}},
225 {"base_background_compactions",
226 {offsetof(struct DBOptions, base_background_compactions), OptionType::kInt,
227 OptionVerificationType::kNormal, true,
228 offsetof(struct MutableDBOptions, base_background_compactions)}},
229 {"max_background_flushes",
230 {offsetof(struct DBOptions, max_background_flushes), OptionType::kInt,
231 OptionVerificationType::kNormal, false, 0}},
232 {"max_file_opening_threads",
233 {offsetof(struct DBOptions, max_file_opening_threads), OptionType::kInt,
234 OptionVerificationType::kNormal, false, 0}},
235 {"max_open_files",
236 {offsetof(struct DBOptions, max_open_files), OptionType::kInt,
237 OptionVerificationType::kNormal, false, 0}},
238 {"table_cache_numshardbits",
239 {offsetof(struct DBOptions, table_cache_numshardbits), OptionType::kInt,
240 OptionVerificationType::kNormal, false, 0}},
241 {"db_write_buffer_size",
242 {offsetof(struct DBOptions, db_write_buffer_size), OptionType::kSizeT,
243 OptionVerificationType::kNormal, false, 0}},
244 {"keep_log_file_num",
245 {offsetof(struct DBOptions, keep_log_file_num), OptionType::kSizeT,
246 OptionVerificationType::kNormal, false, 0}},
247 {"recycle_log_file_num",
248 {offsetof(struct DBOptions, recycle_log_file_num), OptionType::kSizeT,
249 OptionVerificationType::kNormal, false, 0}},
250 {"log_file_time_to_roll",
251 {offsetof(struct DBOptions, log_file_time_to_roll), OptionType::kSizeT,
252 OptionVerificationType::kNormal, false, 0}},
253 {"manifest_preallocation_size",
254 {offsetof(struct DBOptions, manifest_preallocation_size),
255 OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}},
256 {"max_log_file_size",
257 {offsetof(struct DBOptions, max_log_file_size), OptionType::kSizeT,
258 OptionVerificationType::kNormal, false, 0}},
259 {"db_log_dir",
260 {offsetof(struct DBOptions, db_log_dir), OptionType::kString,
261 OptionVerificationType::kNormal, false, 0}},
262 {"wal_dir",
263 {offsetof(struct DBOptions, wal_dir), OptionType::kString,
264 OptionVerificationType::kNormal, false, 0}},
265 {"max_subcompactions",
266 {offsetof(struct DBOptions, max_subcompactions), OptionType::kUInt32T,
267 OptionVerificationType::kNormal, false, 0}},
268 {"WAL_size_limit_MB",
269 {offsetof(struct DBOptions, WAL_size_limit_MB), OptionType::kUInt64T,
270 OptionVerificationType::kNormal, false, 0}},
271 {"WAL_ttl_seconds",
272 {offsetof(struct DBOptions, WAL_ttl_seconds), OptionType::kUInt64T,
273 OptionVerificationType::kNormal, false, 0}},
274 {"bytes_per_sync",
275 {offsetof(struct DBOptions, bytes_per_sync), OptionType::kUInt64T,
276 OptionVerificationType::kNormal, false, 0}},
277 {"delayed_write_rate",
278 {offsetof(struct DBOptions, delayed_write_rate), OptionType::kUInt64T,
279 OptionVerificationType::kNormal, true,
280 offsetof(struct MutableDBOptions, delayed_write_rate)}},
281 {"delete_obsolete_files_period_micros",
282 {offsetof(struct DBOptions, delete_obsolete_files_period_micros),
283 OptionType::kUInt64T, OptionVerificationType::kNormal, true,
284 offsetof(struct MutableDBOptions, delete_obsolete_files_period_micros)}},
285 {"max_manifest_file_size",
286 {offsetof(struct DBOptions, max_manifest_file_size), OptionType::kUInt64T,
287 OptionVerificationType::kNormal, false, 0}},
288 {"max_total_wal_size",
289 {offsetof(struct DBOptions, max_total_wal_size), OptionType::kUInt64T,
290 OptionVerificationType::kNormal, true,
291 offsetof(struct MutableDBOptions, max_total_wal_size)}},
292 {"wal_bytes_per_sync",
293 {offsetof(struct DBOptions, wal_bytes_per_sync), OptionType::kUInt64T,
294 OptionVerificationType::kNormal, false, 0}},
295 {"stats_dump_period_sec",
296 {offsetof(struct DBOptions, stats_dump_period_sec), OptionType::kUInt,
297 OptionVerificationType::kNormal, true,
298 offsetof(struct MutableDBOptions, stats_dump_period_sec)}},
299 {"fail_if_options_file_error",
300 {offsetof(struct DBOptions, fail_if_options_file_error),
301 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
302 {"allow_concurrent_memtable_write",
303 {offsetof(struct DBOptions, allow_concurrent_memtable_write),
304 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
305 {"wal_recovery_mode",
306 {offsetof(struct DBOptions, wal_recovery_mode),
307 OptionType::kWALRecoveryMode, OptionVerificationType::kNormal, false, 0}},
308 {"enable_write_thread_adaptive_yield",
309 {offsetof(struct DBOptions, enable_write_thread_adaptive_yield),
310 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
311 {"write_thread_slow_yield_usec",
312 {offsetof(struct DBOptions, write_thread_slow_yield_usec),
313 OptionType::kUInt64T, OptionVerificationType::kNormal, false, 0}},
314 {"write_thread_max_yield_usec",
315 {offsetof(struct DBOptions, write_thread_max_yield_usec),
316 OptionType::kUInt64T, OptionVerificationType::kNormal, false, 0}},
317 {"access_hint_on_compaction_start",
318 {offsetof(struct DBOptions, access_hint_on_compaction_start),
319 OptionType::kAccessHint, OptionVerificationType::kNormal, false, 0}},
320 {"info_log_level",
321 {offsetof(struct DBOptions, info_log_level), OptionType::kInfoLogLevel,
322 OptionVerificationType::kNormal, false, 0}},
323 {"dump_malloc_stats",
324 {offsetof(struct DBOptions, dump_malloc_stats), OptionType::kBoolean,
325 OptionVerificationType::kNormal, false, 0}},
326 {"avoid_flush_during_recovery",
327 {offsetof(struct DBOptions, avoid_flush_during_recovery),
328 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
329 {"avoid_flush_during_shutdown",
330 {offsetof(struct DBOptions, avoid_flush_during_shutdown),
331 OptionType::kBoolean, OptionVerificationType::kNormal, true,
332 offsetof(struct MutableDBOptions, avoid_flush_during_shutdown)}}};
333
334// offset_of is used to get the offset of a class data member
335// ex: offset_of(&ColumnFamilyOptions::num_levels)
336// This call will return the offset of num_levels in ColumnFamilyOptions class
337//
338// This is the same as offsetof() but allow us to work with non standard-layout
339// classes and structures
340// refs:
341// http://en.cppreference.com/w/cpp/concept/StandardLayoutType
342// https://gist.github.com/graphitemaster/494f21190bb2c63c5516
343template <typename T1, typename T2>
344inline int offset_of(T1 T2::*member) {
345 static T2 obj;
346 return int(size_t(&(obj.*member)) - size_t(&obj));
347}
348
349static std::unordered_map<std::string, OptionTypeInfo> cf_options_type_info = {
350 /* not yet supported
351 CompactionOptionsFIFO compaction_options_fifo;
352 CompactionOptionsUniversal compaction_options_universal;
353 CompressionOptions compression_opts;
354 TablePropertiesCollectorFactories table_properties_collector_factories;
355 typedef std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>
356 TablePropertiesCollectorFactories;
357 UpdateStatus (*inplace_callback)(char* existing_value,
358 uint34_t* existing_value_size,
359 Slice delta_value,
360 std::string* merged_value);
361 */
362 {"report_bg_io_stats",
363 {offset_of(&ColumnFamilyOptions::report_bg_io_stats), OptionType::kBoolean,
364 OptionVerificationType::kNormal, true,
365 offsetof(struct MutableCFOptions, report_bg_io_stats)}},
366 {"compaction_measure_io_stats",
367 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, false, 0}},
368 {"disable_auto_compactions",
369 {offset_of(&ColumnFamilyOptions::disable_auto_compactions),
370 OptionType::kBoolean, OptionVerificationType::kNormal, true,
371 offsetof(struct MutableCFOptions, disable_auto_compactions)}},
372 {"filter_deletes",
373 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, true, 0}},
374 {"inplace_update_support",
375 {offset_of(&ColumnFamilyOptions::inplace_update_support),
376 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
377 {"level_compaction_dynamic_level_bytes",
378 {offset_of(&ColumnFamilyOptions::level_compaction_dynamic_level_bytes),
379 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
380 {"optimize_filters_for_hits",
381 {offset_of(&ColumnFamilyOptions::optimize_filters_for_hits),
382 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
383 {"paranoid_file_checks",
384 {offset_of(&ColumnFamilyOptions::paranoid_file_checks),
385 OptionType::kBoolean, OptionVerificationType::kNormal, true,
386 offsetof(struct MutableCFOptions, paranoid_file_checks)}},
387 {"force_consistency_checks",
388 {offset_of(&ColumnFamilyOptions::force_consistency_checks),
389 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
390 {"purge_redundant_kvs_while_flush",
391 {offset_of(&ColumnFamilyOptions::purge_redundant_kvs_while_flush),
392 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
393 {"verify_checksums_in_compaction",
394 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, true, 0}},
395 {"soft_pending_compaction_bytes_limit",
396 {offset_of(&ColumnFamilyOptions::soft_pending_compaction_bytes_limit),
397 OptionType::kUInt64T, OptionVerificationType::kNormal, true,
398 offsetof(struct MutableCFOptions, soft_pending_compaction_bytes_limit)}},
399 {"hard_pending_compaction_bytes_limit",
400 {offset_of(&ColumnFamilyOptions::hard_pending_compaction_bytes_limit),
401 OptionType::kUInt64T, OptionVerificationType::kNormal, true,
402 offsetof(struct MutableCFOptions, hard_pending_compaction_bytes_limit)}},
403 {"hard_rate_limit",
404 {0, OptionType::kDouble, OptionVerificationType::kDeprecated, true, 0}},
405 {"soft_rate_limit",
406 {0, OptionType::kDouble, OptionVerificationType::kDeprecated, true, 0}},
407 {"max_compaction_bytes",
408 {offset_of(&ColumnFamilyOptions::max_compaction_bytes),
409 OptionType::kUInt64T, OptionVerificationType::kNormal, true,
410 offsetof(struct MutableCFOptions, max_compaction_bytes)}},
411 {"expanded_compaction_factor",
412 {0, OptionType::kInt, OptionVerificationType::kDeprecated, true, 0}},
413 {"level0_file_num_compaction_trigger",
414 {offset_of(&ColumnFamilyOptions::level0_file_num_compaction_trigger),
415 OptionType::kInt, OptionVerificationType::kNormal, true,
416 offsetof(struct MutableCFOptions, level0_file_num_compaction_trigger)}},
417 {"level0_slowdown_writes_trigger",
418 {offset_of(&ColumnFamilyOptions::level0_slowdown_writes_trigger),
419 OptionType::kInt, OptionVerificationType::kNormal, true,
420 offsetof(struct MutableCFOptions, level0_slowdown_writes_trigger)}},
421 {"level0_stop_writes_trigger",
422 {offset_of(&ColumnFamilyOptions::level0_stop_writes_trigger),
423 OptionType::kInt, OptionVerificationType::kNormal, true,
424 offsetof(struct MutableCFOptions, level0_stop_writes_trigger)}},
425 {"max_grandparent_overlap_factor",
426 {0, OptionType::kInt, OptionVerificationType::kDeprecated, true, 0}},
427 {"max_mem_compaction_level",
428 {0, OptionType::kInt, OptionVerificationType::kDeprecated, false, 0}},
429 {"max_write_buffer_number",
430 {offset_of(&ColumnFamilyOptions::max_write_buffer_number),
431 OptionType::kInt, OptionVerificationType::kNormal, true,
432 offsetof(struct MutableCFOptions, max_write_buffer_number)}},
433 {"max_write_buffer_number_to_maintain",
434 {offset_of(&ColumnFamilyOptions::max_write_buffer_number_to_maintain),
435 OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
436 {"min_write_buffer_number_to_merge",
437 {offset_of(&ColumnFamilyOptions::min_write_buffer_number_to_merge),
438 OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
439 {"num_levels",
440 {offset_of(&ColumnFamilyOptions::num_levels), OptionType::kInt,
441 OptionVerificationType::kNormal, false, 0}},
442 {"source_compaction_factor",
443 {0, OptionType::kInt, OptionVerificationType::kDeprecated, true, 0}},
444 {"target_file_size_multiplier",
445 {offset_of(&ColumnFamilyOptions::target_file_size_multiplier),
446 OptionType::kInt, OptionVerificationType::kNormal, true,
447 offsetof(struct MutableCFOptions, target_file_size_multiplier)}},
448 {"arena_block_size",
449 {offset_of(&ColumnFamilyOptions::arena_block_size), OptionType::kSizeT,
450 OptionVerificationType::kNormal, true,
451 offsetof(struct MutableCFOptions, arena_block_size)}},
452 {"inplace_update_num_locks",
453 {offset_of(&ColumnFamilyOptions::inplace_update_num_locks),
454 OptionType::kSizeT, OptionVerificationType::kNormal, true,
455 offsetof(struct MutableCFOptions, inplace_update_num_locks)}},
456 {"max_successive_merges",
457 {offset_of(&ColumnFamilyOptions::max_successive_merges),
458 OptionType::kSizeT, OptionVerificationType::kNormal, true,
459 offsetof(struct MutableCFOptions, max_successive_merges)}},
460 {"memtable_huge_page_size",
461 {offset_of(&ColumnFamilyOptions::memtable_huge_page_size),
462 OptionType::kSizeT, OptionVerificationType::kNormal, true,
463 offsetof(struct MutableCFOptions, memtable_huge_page_size)}},
464 {"memtable_prefix_bloom_huge_page_tlb_size",
465 {0, OptionType::kSizeT, OptionVerificationType::kDeprecated, true, 0}},
466 {"write_buffer_size",
467 {offset_of(&ColumnFamilyOptions::write_buffer_size), OptionType::kSizeT,
468 OptionVerificationType::kNormal, true,
469 offsetof(struct MutableCFOptions, write_buffer_size)}},
470 {"bloom_locality",
471 {offset_of(&ColumnFamilyOptions::bloom_locality), OptionType::kUInt32T,
472 OptionVerificationType::kNormal, false, 0}},
473 {"memtable_prefix_bloom_bits",
474 {0, OptionType::kUInt32T, OptionVerificationType::kDeprecated, true, 0}},
475 {"memtable_prefix_bloom_size_ratio",
476 {offset_of(&ColumnFamilyOptions::memtable_prefix_bloom_size_ratio),
477 OptionType::kDouble, OptionVerificationType::kNormal, true,
478 offsetof(struct MutableCFOptions, memtable_prefix_bloom_size_ratio)}},
479 {"memtable_prefix_bloom_probes",
480 {0, OptionType::kUInt32T, OptionVerificationType::kDeprecated, true, 0}},
481 {"min_partial_merge_operands",
482 {0, OptionType::kUInt32T, OptionVerificationType::kDeprecated, true, 0}},
483 {"max_bytes_for_level_base",
484 {offset_of(&ColumnFamilyOptions::max_bytes_for_level_base),
485 OptionType::kUInt64T, OptionVerificationType::kNormal, true,
486 offsetof(struct MutableCFOptions, max_bytes_for_level_base)}},
487 {"max_bytes_for_level_multiplier",
488 {offset_of(&ColumnFamilyOptions::max_bytes_for_level_multiplier),
489 OptionType::kDouble, OptionVerificationType::kNormal, true,
490 offsetof(struct MutableCFOptions, max_bytes_for_level_multiplier)}},
491 {"max_bytes_for_level_multiplier_additional",
492 {offset_of(
493 &ColumnFamilyOptions::max_bytes_for_level_multiplier_additional),
494 OptionType::kVectorInt, OptionVerificationType::kNormal, true,
495 offsetof(struct MutableCFOptions,
496 max_bytes_for_level_multiplier_additional)}},
497 {"max_sequential_skip_in_iterations",
498 {offset_of(&ColumnFamilyOptions::max_sequential_skip_in_iterations),
499 OptionType::kUInt64T, OptionVerificationType::kNormal, true,
500 offsetof(struct MutableCFOptions, max_sequential_skip_in_iterations)}},
501 {"target_file_size_base",
502 {offset_of(&ColumnFamilyOptions::target_file_size_base),
503 OptionType::kUInt64T, OptionVerificationType::kNormal, true,
504 offsetof(struct MutableCFOptions, target_file_size_base)}},
505 {"rate_limit_delay_max_milliseconds",
506 {0, OptionType::kUInt, OptionVerificationType::kDeprecated, false, 0}},
507 {"compression",
508 {offset_of(&ColumnFamilyOptions::compression),
509 OptionType::kCompressionType, OptionVerificationType::kNormal, true,
510 offsetof(struct MutableCFOptions, compression)}},
511 {"compression_per_level",
512 {offset_of(&ColumnFamilyOptions::compression_per_level),
513 OptionType::kVectorCompressionType, OptionVerificationType::kNormal,
514 false, 0}},
515 {"bottommost_compression",
516 {offset_of(&ColumnFamilyOptions::bottommost_compression),
517 OptionType::kCompressionType, OptionVerificationType::kNormal, false, 0}},
518 {"comparator",
519 {offset_of(&ColumnFamilyOptions::comparator), OptionType::kComparator,
520 OptionVerificationType::kByName, false, 0}},
521 {"prefix_extractor",
522 {offset_of(&ColumnFamilyOptions::prefix_extractor),
523 OptionType::kSliceTransform, OptionVerificationType::kByNameAllowNull,
524 false, 0}},
525 {"memtable_insert_with_hint_prefix_extractor",
526 {offset_of(
527 &ColumnFamilyOptions::memtable_insert_with_hint_prefix_extractor),
528 OptionType::kSliceTransform, OptionVerificationType::kByNameAllowNull,
529 false, 0}},
530 {"memtable_factory",
531 {offset_of(&ColumnFamilyOptions::memtable_factory),
532 OptionType::kMemTableRepFactory, OptionVerificationType::kByName, false,
533 0}},
534 {"table_factory",
535 {offset_of(&ColumnFamilyOptions::table_factory), OptionType::kTableFactory,
536 OptionVerificationType::kByName, false, 0}},
537 {"compaction_filter",
538 {offset_of(&ColumnFamilyOptions::compaction_filter),
539 OptionType::kCompactionFilter, OptionVerificationType::kByName, false,
540 0}},
541 {"compaction_filter_factory",
542 {offset_of(&ColumnFamilyOptions::compaction_filter_factory),
543 OptionType::kCompactionFilterFactory, OptionVerificationType::kByName,
544 false, 0}},
545 {"merge_operator",
546 {offset_of(&ColumnFamilyOptions::merge_operator),
547 OptionType::kMergeOperator, OptionVerificationType::kByName, false, 0}},
548 {"compaction_style",
549 {offset_of(&ColumnFamilyOptions::compaction_style),
550 OptionType::kCompactionStyle, OptionVerificationType::kNormal, false, 0}},
551 {"compaction_pri",
552 {offset_of(&ColumnFamilyOptions::compaction_pri),
553 OptionType::kCompactionPri, OptionVerificationType::kNormal, false, 0}}};
554
555static std::unordered_map<std::string, OptionTypeInfo>
556 block_based_table_type_info = {
557 /* currently not supported
558 std::shared_ptr<Cache> block_cache = nullptr;
559 std::shared_ptr<Cache> block_cache_compressed = nullptr;
560 */
561 {"flush_block_policy_factory",
562 {offsetof(struct BlockBasedTableOptions, flush_block_policy_factory),
563 OptionType::kFlushBlockPolicyFactory, OptionVerificationType::kByName,
564 false, 0}},
565 {"cache_index_and_filter_blocks",
566 {offsetof(struct BlockBasedTableOptions,
567 cache_index_and_filter_blocks),
568 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
569 {"cache_index_and_filter_blocks_with_high_priority",
570 {offsetof(struct BlockBasedTableOptions,
571 cache_index_and_filter_blocks_with_high_priority),
572 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
573 {"pin_l0_filter_and_index_blocks_in_cache",
574 {offsetof(struct BlockBasedTableOptions,
575 pin_l0_filter_and_index_blocks_in_cache),
576 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
577 {"index_type",
578 {offsetof(struct BlockBasedTableOptions, index_type),
579 OptionType::kBlockBasedTableIndexType,
580 OptionVerificationType::kNormal, false, 0}},
581 {"hash_index_allow_collision",
582 {offsetof(struct BlockBasedTableOptions, hash_index_allow_collision),
583 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
584 {"checksum",
585 {offsetof(struct BlockBasedTableOptions, checksum),
586 OptionType::kChecksumType, OptionVerificationType::kNormal, false,
587 0}},
588 {"no_block_cache",
589 {offsetof(struct BlockBasedTableOptions, no_block_cache),
590 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
591 {"block_size",
592 {offsetof(struct BlockBasedTableOptions, block_size),
593 OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}},
594 {"block_size_deviation",
595 {offsetof(struct BlockBasedTableOptions, block_size_deviation),
596 OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
597 {"block_restart_interval",
598 {offsetof(struct BlockBasedTableOptions, block_restart_interval),
599 OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
600 {"index_block_restart_interval",
601 {offsetof(struct BlockBasedTableOptions, index_block_restart_interval),
602 OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
603 {"index_per_partition",
604 {0, OptionType::kUInt64T, OptionVerificationType::kDeprecated, false,
605 0}},
606 {"metadata_block_size",
607 {offsetof(struct BlockBasedTableOptions, metadata_block_size),
608 OptionType::kUInt64T, OptionVerificationType::kNormal, false, 0}},
609 {"partition_filters",
610 {offsetof(struct BlockBasedTableOptions, partition_filters),
611 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
612 {"filter_policy",
613 {offsetof(struct BlockBasedTableOptions, filter_policy),
614 OptionType::kFilterPolicy, OptionVerificationType::kByName, false,
615 0}},
616 {"whole_key_filtering",
617 {offsetof(struct BlockBasedTableOptions, whole_key_filtering),
618 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
619 {"skip_table_builder_flush",
620 {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, false,
621 0}},
622 {"format_version",
623 {offsetof(struct BlockBasedTableOptions, format_version),
624 OptionType::kUInt32T, OptionVerificationType::kNormal, false, 0}},
625 {"verify_compression",
626 {offsetof(struct BlockBasedTableOptions, verify_compression),
627 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
628 {"read_amp_bytes_per_bit",
629 {offsetof(struct BlockBasedTableOptions, read_amp_bytes_per_bit),
630 OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}}};
631
632static std::unordered_map<std::string, OptionTypeInfo> plain_table_type_info = {
633 {"user_key_len",
634 {offsetof(struct PlainTableOptions, user_key_len), OptionType::kUInt32T,
635 OptionVerificationType::kNormal, false, 0}},
636 {"bloom_bits_per_key",
637 {offsetof(struct PlainTableOptions, bloom_bits_per_key), OptionType::kInt,
638 OptionVerificationType::kNormal, false, 0}},
639 {"hash_table_ratio",
640 {offsetof(struct PlainTableOptions, hash_table_ratio), OptionType::kDouble,
641 OptionVerificationType::kNormal, false, 0}},
642 {"index_sparseness",
643 {offsetof(struct PlainTableOptions, index_sparseness), OptionType::kSizeT,
644 OptionVerificationType::kNormal, false, 0}},
645 {"huge_page_tlb_size",
646 {offsetof(struct PlainTableOptions, huge_page_tlb_size),
647 OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}},
648 {"encoding_type",
649 {offsetof(struct PlainTableOptions, encoding_type),
650 OptionType::kEncodingType, OptionVerificationType::kByName, false, 0}},
651 {"full_scan_mode",
652 {offsetof(struct PlainTableOptions, full_scan_mode), OptionType::kBoolean,
653 OptionVerificationType::kNormal, false, 0}},
654 {"store_index_in_file",
655 {offsetof(struct PlainTableOptions, store_index_in_file),
656 OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}}};
657
658static std::unordered_map<std::string, CompressionType>
659 compression_type_string_map = {
660 {"kNoCompression", kNoCompression},
661 {"kSnappyCompression", kSnappyCompression},
662 {"kZlibCompression", kZlibCompression},
663 {"kBZip2Compression", kBZip2Compression},
664 {"kLZ4Compression", kLZ4Compression},
665 {"kLZ4HCCompression", kLZ4HCCompression},
666 {"kXpressCompression", kXpressCompression},
667 {"kZSTD", kZSTD},
668 {"kZSTDNotFinalCompression", kZSTDNotFinalCompression},
669 {"kDisableCompressionOption", kDisableCompressionOption}};
670
671static std::unordered_map<std::string, BlockBasedTableOptions::IndexType>
672 block_base_table_index_type_string_map = {
673 {"kBinarySearch", BlockBasedTableOptions::IndexType::kBinarySearch},
674 {"kHashSearch", BlockBasedTableOptions::IndexType::kHashSearch},
675 {"kTwoLevelIndexSearch",
676 BlockBasedTableOptions::IndexType::kTwoLevelIndexSearch}};
677
678static std::unordered_map<std::string, EncodingType> encoding_type_string_map =
679 {{"kPlain", kPlain}, {"kPrefix", kPrefix}};
680
681static std::unordered_map<std::string, ChecksumType> checksum_type_string_map =
682 {{"kNoChecksum", kNoChecksum}, {"kCRC32c", kCRC32c}, {"kxxHash", kxxHash}};
683
684static std::unordered_map<std::string, CompactionStyle>
685 compaction_style_string_map = {
686 {"kCompactionStyleLevel", kCompactionStyleLevel},
687 {"kCompactionStyleUniversal", kCompactionStyleUniversal},
688 {"kCompactionStyleFIFO", kCompactionStyleFIFO},
689 {"kCompactionStyleNone", kCompactionStyleNone}};
690
691static std::unordered_map<std::string, CompactionPri>
692 compaction_pri_string_map = {
693 {"kByCompensatedSize", kByCompensatedSize},
694 {"kOldestLargestSeqFirst", kOldestLargestSeqFirst},
695 {"kOldestSmallestSeqFirst", kOldestSmallestSeqFirst},
696 {"kMinOverlappingRatio", kMinOverlappingRatio}};
697
698static std::unordered_map<std::string,
699 WALRecoveryMode> wal_recovery_mode_string_map = {
700 {"kTolerateCorruptedTailRecords",
701 WALRecoveryMode::kTolerateCorruptedTailRecords},
702 {"kAbsoluteConsistency", WALRecoveryMode::kAbsoluteConsistency},
703 {"kPointInTimeRecovery", WALRecoveryMode::kPointInTimeRecovery},
704 {"kSkipAnyCorruptedRecords", WALRecoveryMode::kSkipAnyCorruptedRecords}};
705
706static std::unordered_map<std::string, DBOptions::AccessHint>
707 access_hint_string_map = {{"NONE", DBOptions::AccessHint::NONE},
708 {"NORMAL", DBOptions::AccessHint::NORMAL},
709 {"SEQUENTIAL", DBOptions::AccessHint::SEQUENTIAL},
710 {"WILLNEED", DBOptions::AccessHint::WILLNEED}};
711
712static std::unordered_map<std::string, InfoLogLevel> info_log_level_string_map =
713 {{"DEBUG_LEVEL", InfoLogLevel::DEBUG_LEVEL},
714 {"INFO_LEVEL", InfoLogLevel::INFO_LEVEL},
715 {"WARN_LEVEL", InfoLogLevel::WARN_LEVEL},
716 {"ERROR_LEVEL", InfoLogLevel::ERROR_LEVEL},
717 {"FATAL_LEVEL", InfoLogLevel::FATAL_LEVEL},
718 {"HEADER_LEVEL", InfoLogLevel::HEADER_LEVEL}};
719
720#endif // !ROCKSDB_LITE
721
722} // namespace rocksdb