]>
Commit | Line | Data |
---|---|---|
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 <map> | |
9 | #include <stdexcept> | |
10 | #include <string> | |
11 | #include <vector> | |
12 | ||
1e59de90 | 13 | #include "rocksdb/advanced_options.h" |
7c673cae FG |
14 | #include "rocksdb/options.h" |
15 | #include "rocksdb/status.h" | |
16 | #include "rocksdb/table.h" | |
17 | ||
f67539c2 | 18 | namespace ROCKSDB_NAMESPACE { |
20effc67 TL |
19 | struct ColumnFamilyOptions; |
20 | struct ConfigOptions; | |
21 | struct DBOptions; | |
1e59de90 | 22 | struct ImmutableCFOptions; |
20effc67 TL |
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 | ||
1e59de90 TL |
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 | ||
20effc67 TL |
41 | // Checks that the combination of DBOptions and ColumnFamilyOptions are valid |
42 | Status ValidateOptions(const DBOptions& db_opts, | |
43 | const ColumnFamilyOptions& cf_opts); | |
7c673cae FG |
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 | ||
1e59de90 TL |
52 | void UpdateColumnFamilyOptions(const ImmutableCFOptions& ioptions, |
53 | ColumnFamilyOptions* cf_opts); | |
54 | void UpdateColumnFamilyOptions(const MutableCFOptions& moptions, | |
55 | ColumnFamilyOptions* cf_opts); | |
56 | ||
7c673cae | 57 | #ifndef ROCKSDB_LITE |
20effc67 TL |
58 | std::unique_ptr<Configurable> DBOptionsAsConfigurable( |
59 | const MutableDBOptions& opts); | |
1e59de90 TL |
60 | std::unique_ptr<Configurable> DBOptionsAsConfigurable( |
61 | const DBOptions& opts, | |
62 | const std::unordered_map<std::string, std::string>* opt_map = nullptr); | |
20effc67 TL |
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 | ||
11fdf7f2 TL |
69 | extern Status StringToMap( |
70 | const std::string& opts_str, | |
71 | std::unordered_map<std::string, std::string>* opts_map); | |
11fdf7f2 | 72 | #endif // !ROCKSDB_LITE |
7c673cae | 73 | |
11fdf7f2 | 74 | struct OptionsHelper { |
20effc67 TL |
75 | static const std::string kCFOptionsName /*= "ColumnFamilyOptions"*/; |
76 | static const std::string kDBOptionsName /*= "DBOptions" */; | |
11fdf7f2 TL |
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; | |
1e59de90 | 81 | static std::map<Temperature, std::string> temperature_to_string; |
11fdf7f2 TL |
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; | |
1e59de90 TL |
85 | static std::unordered_map<std::string, PrepopulateBlobCache> |
86 | prepopulate_blob_cache_string_map; | |
11fdf7f2 | 87 | #ifndef ROCKSDB_LITE |
11fdf7f2 TL |
88 | static std::unordered_map<std::string, CompactionStopStyle> |
89 | compaction_stop_style_string_map; | |
11fdf7f2 TL |
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; | |
1e59de90 | 95 | static std::unordered_map<std::string, Temperature> temperature_string_map; |
11fdf7f2 TL |
96 | #endif // !ROCKSDB_LITE |
97 | }; | |
7c673cae | 98 | |
11fdf7f2 TL |
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; | |
1e59de90 | 105 | static auto& temperature_to_string = OptionsHelper::temperature_to_string; |
11fdf7f2 TL |
106 | static auto& checksum_type_string_map = OptionsHelper::checksum_type_string_map; |
107 | #ifndef ROCKSDB_LITE | |
11fdf7f2 TL |
108 | static auto& compaction_stop_style_string_map = |
109 | OptionsHelper::compaction_stop_style_string_map; | |
11fdf7f2 TL |
110 | static auto& compression_type_string_map = |
111 | OptionsHelper::compression_type_string_map; | |
11fdf7f2 TL |
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; | |
1e59de90 TL |
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; | |
7c673cae FG |
120 | #endif // !ROCKSDB_LITE |
121 | ||
f67539c2 | 122 | } // namespace ROCKSDB_NAMESPACE |