/src/rocksdb/options/options_helper.h
Line | Count | Source |
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 | 26.3k | inline bool IsSupportedChecksumType(ChecksumType type) { |
35 | | // Avoid annoying compiler warning-as-error (-Werror=type-limits) |
36 | 26.3k | auto min = kNoChecksum; |
37 | 26.3k | auto max = kXXH3; |
38 | 26.3k | return type >= min && type <= max; |
39 | 26.3k | } |
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 | | std::unique_ptr<Configurable> DBOptionsAsConfigurable( |
58 | | const MutableDBOptions& opts); |
59 | | std::unique_ptr<Configurable> DBOptionsAsConfigurable( |
60 | | const DBOptions& opts, |
61 | | const std::unordered_map<std::string, std::string>* opt_map = nullptr); |
62 | | std::unique_ptr<Configurable> CFOptionsAsConfigurable( |
63 | | const MutableCFOptions& opts); |
64 | | std::unique_ptr<Configurable> CFOptionsAsConfigurable( |
65 | | const ColumnFamilyOptions& opts, |
66 | | const std::unordered_map<std::string, std::string>* opt_map = nullptr); |
67 | | |
68 | | Status StringToMap(const std::string& opts_str, |
69 | | std::unordered_map<std::string, std::string>* opts_map); |
70 | | |
71 | | struct OptionsHelper { |
72 | | static const std::string kCFOptionsName /*= "ColumnFamilyOptions"*/; |
73 | | static const std::string kDBOptionsName /*= "DBOptions" */; |
74 | | static std::map<CompactionStyle, std::string> compaction_style_to_string; |
75 | | static std::map<CompactionPri, std::string> compaction_pri_to_string; |
76 | | static std::map<CompactionStopStyle, std::string> |
77 | | compaction_stop_style_to_string; |
78 | | static std::map<Temperature, std::string> temperature_to_string; |
79 | | static std::unordered_map<std::string, ChecksumType> checksum_type_string_map; |
80 | | static std::unordered_map<std::string, CompressionType> |
81 | | compression_type_string_map; |
82 | | static std::unordered_map<std::string, PrepopulateBlobCache> |
83 | | prepopulate_blob_cache_string_map; |
84 | | static std::unordered_map<std::string, CompactionStopStyle> |
85 | | compaction_stop_style_string_map; |
86 | | static std::unordered_map<std::string, EncodingType> encoding_type_string_map; |
87 | | static std::unordered_map<std::string, CompactionStyle> |
88 | | compaction_style_string_map; |
89 | | static std::unordered_map<std::string, CompactionPri> |
90 | | compaction_pri_string_map; |
91 | | static std::unordered_map<std::string, Temperature> temperature_string_map; |
92 | | }; |
93 | | |
94 | | // Some aliasing |
95 | | static auto& compaction_style_to_string = |
96 | | OptionsHelper::compaction_style_to_string; |
97 | | static auto& compaction_pri_to_string = OptionsHelper::compaction_pri_to_string; |
98 | | static auto& compaction_stop_style_to_string = |
99 | | OptionsHelper::compaction_stop_style_to_string; |
100 | | static auto& temperature_to_string = OptionsHelper::temperature_to_string; |
101 | | static auto& checksum_type_string_map = OptionsHelper::checksum_type_string_map; |
102 | | static auto& compaction_stop_style_string_map = |
103 | | OptionsHelper::compaction_stop_style_string_map; |
104 | | static auto& compression_type_string_map = |
105 | | OptionsHelper::compression_type_string_map; |
106 | | static auto& encoding_type_string_map = OptionsHelper::encoding_type_string_map; |
107 | | static auto& compaction_style_string_map = |
108 | | OptionsHelper::compaction_style_string_map; |
109 | | static auto& compaction_pri_string_map = |
110 | | OptionsHelper::compaction_pri_string_map; |
111 | | static auto& temperature_string_map = OptionsHelper::temperature_string_map; |
112 | | static auto& prepopulate_blob_cache_string_map = |
113 | | OptionsHelper::prepopulate_blob_cache_string_map; |
114 | | |
115 | | } // namespace ROCKSDB_NAMESPACE |