]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/options/options_helper.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / options / options_helper.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
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).
5
6 #pragma once
7
8 #include <map>
9 #include <stdexcept>
10 #include <string>
11 #include <vector>
12
13 #include "rocksdb/advanced_options.h"
14 #include "rocksdb/options.h"
15 #include "rocksdb/status.h"
16 #include "rocksdb/table.h"
17
18 namespace ROCKSDB_NAMESPACE {
19 struct ColumnFamilyOptions;
20 struct ConfigOptions;
21 struct DBOptions;
22 struct ImmutableCFOptions;
23 struct ImmutableDBOptions;
24 struct MutableDBOptions;
25 struct MutableCFOptions;
26 struct Options;
27
28 std::vector<CompressionType> GetSupportedCompressions();
29
30 std::vector<CompressionType> GetSupportedDictCompressions();
31
32 std::vector<ChecksumType> GetSupportedChecksums();
33
34 inline bool IsSupportedChecksumType(ChecksumType type) {
35 // Avoid annoying compiler warning-as-error (-Werror=type-limits)
36 auto min = kNoChecksum;
37 auto max = kXXH3;
38 return type >= min && type <= max;
39 }
40
41 // Checks that the combination of DBOptions and ColumnFamilyOptions are valid
42 Status ValidateOptions(const DBOptions& db_opts,
43 const ColumnFamilyOptions& cf_opts);
44
45 DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
46 const MutableDBOptions& mutable_db_options);
47
48 ColumnFamilyOptions BuildColumnFamilyOptions(
49 const ColumnFamilyOptions& ioptions,
50 const MutableCFOptions& mutable_cf_options);
51
52 void UpdateColumnFamilyOptions(const ImmutableCFOptions& ioptions,
53 ColumnFamilyOptions* cf_opts);
54 void UpdateColumnFamilyOptions(const MutableCFOptions& moptions,
55 ColumnFamilyOptions* cf_opts);
56
57 #ifndef ROCKSDB_LITE
58 std::unique_ptr<Configurable> DBOptionsAsConfigurable(
59 const MutableDBOptions& opts);
60 std::unique_ptr<Configurable> DBOptionsAsConfigurable(
61 const DBOptions& opts,
62 const std::unordered_map<std::string, std::string>* opt_map = nullptr);
63 std::unique_ptr<Configurable> CFOptionsAsConfigurable(
64 const MutableCFOptions& opts);
65 std::unique_ptr<Configurable> CFOptionsAsConfigurable(
66 const ColumnFamilyOptions& opts,
67 const std::unordered_map<std::string, std::string>* opt_map = nullptr);
68
69 extern Status StringToMap(
70 const std::string& opts_str,
71 std::unordered_map<std::string, std::string>* opts_map);
72 #endif // !ROCKSDB_LITE
73
74 struct OptionsHelper {
75 static const std::string kCFOptionsName /*= "ColumnFamilyOptions"*/;
76 static const std::string kDBOptionsName /*= "DBOptions" */;
77 static std::map<CompactionStyle, std::string> compaction_style_to_string;
78 static std::map<CompactionPri, std::string> compaction_pri_to_string;
79 static std::map<CompactionStopStyle, std::string>
80 compaction_stop_style_to_string;
81 static std::map<Temperature, std::string> temperature_to_string;
82 static std::unordered_map<std::string, ChecksumType> checksum_type_string_map;
83 static std::unordered_map<std::string, CompressionType>
84 compression_type_string_map;
85 static std::unordered_map<std::string, PrepopulateBlobCache>
86 prepopulate_blob_cache_string_map;
87 #ifndef ROCKSDB_LITE
88 static std::unordered_map<std::string, CompactionStopStyle>
89 compaction_stop_style_string_map;
90 static std::unordered_map<std::string, EncodingType> encoding_type_string_map;
91 static std::unordered_map<std::string, CompactionStyle>
92 compaction_style_string_map;
93 static std::unordered_map<std::string, CompactionPri>
94 compaction_pri_string_map;
95 static std::unordered_map<std::string, Temperature> temperature_string_map;
96 #endif // !ROCKSDB_LITE
97 };
98
99 // Some aliasing
100 static auto& compaction_style_to_string =
101 OptionsHelper::compaction_style_to_string;
102 static auto& compaction_pri_to_string = OptionsHelper::compaction_pri_to_string;
103 static auto& compaction_stop_style_to_string =
104 OptionsHelper::compaction_stop_style_to_string;
105 static auto& temperature_to_string = OptionsHelper::temperature_to_string;
106 static auto& checksum_type_string_map = OptionsHelper::checksum_type_string_map;
107 #ifndef ROCKSDB_LITE
108 static auto& compaction_stop_style_string_map =
109 OptionsHelper::compaction_stop_style_string_map;
110 static auto& compression_type_string_map =
111 OptionsHelper::compression_type_string_map;
112 static auto& encoding_type_string_map = OptionsHelper::encoding_type_string_map;
113 static auto& compaction_style_string_map =
114 OptionsHelper::compaction_style_string_map;
115 static auto& compaction_pri_string_map =
116 OptionsHelper::compaction_pri_string_map;
117 static auto& temperature_string_map = OptionsHelper::temperature_string_map;
118 static auto& prepopulate_blob_cache_string_map =
119 OptionsHelper::prepopulate_blob_cache_string_map;
120 #endif // !ROCKSDB_LITE
121
122 } // namespace ROCKSDB_NAMESPACE