]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/options/options_helper.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / options / options_helper.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 <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 18namespace ROCKSDB_NAMESPACE {
20effc67
TL
19struct ColumnFamilyOptions;
20struct ConfigOptions;
21struct DBOptions;
1e59de90 22struct ImmutableCFOptions;
20effc67
TL
23struct ImmutableDBOptions;
24struct MutableDBOptions;
25struct MutableCFOptions;
26struct Options;
27
28std::vector<CompressionType> GetSupportedCompressions();
29
30std::vector<CompressionType> GetSupportedDictCompressions();
31
1e59de90
TL
32std::vector<ChecksumType> GetSupportedChecksums();
33
34inline 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
42Status ValidateOptions(const DBOptions& db_opts,
43 const ColumnFamilyOptions& cf_opts);
7c673cae
FG
44
45DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
46 const MutableDBOptions& mutable_db_options);
47
48ColumnFamilyOptions BuildColumnFamilyOptions(
49 const ColumnFamilyOptions& ioptions,
50 const MutableCFOptions& mutable_cf_options);
51
1e59de90
TL
52void UpdateColumnFamilyOptions(const ImmutableCFOptions& ioptions,
53 ColumnFamilyOptions* cf_opts);
54void UpdateColumnFamilyOptions(const MutableCFOptions& moptions,
55 ColumnFamilyOptions* cf_opts);
56
7c673cae 57#ifndef ROCKSDB_LITE
20effc67
TL
58std::unique_ptr<Configurable> DBOptionsAsConfigurable(
59 const MutableDBOptions& opts);
1e59de90
TL
60std::unique_ptr<Configurable> DBOptionsAsConfigurable(
61 const DBOptions& opts,
62 const std::unordered_map<std::string, std::string>* opt_map = nullptr);
20effc67
TL
63std::unique_ptr<Configurable> CFOptionsAsConfigurable(
64 const MutableCFOptions& opts);
65std::unique_ptr<Configurable> CFOptionsAsConfigurable(
66 const ColumnFamilyOptions& opts,
67 const std::unordered_map<std::string, std::string>* opt_map = nullptr);
68
11fdf7f2
TL
69extern 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 74struct 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
100static auto& compaction_style_to_string =
101 OptionsHelper::compaction_style_to_string;
102static auto& compaction_pri_to_string = OptionsHelper::compaction_pri_to_string;
103static auto& compaction_stop_style_to_string =
104 OptionsHelper::compaction_stop_style_to_string;
1e59de90 105static auto& temperature_to_string = OptionsHelper::temperature_to_string;
11fdf7f2
TL
106static auto& checksum_type_string_map = OptionsHelper::checksum_type_string_map;
107#ifndef ROCKSDB_LITE
11fdf7f2
TL
108static auto& compaction_stop_style_string_map =
109 OptionsHelper::compaction_stop_style_string_map;
11fdf7f2
TL
110static auto& compression_type_string_map =
111 OptionsHelper::compression_type_string_map;
11fdf7f2
TL
112static auto& encoding_type_string_map = OptionsHelper::encoding_type_string_map;
113static auto& compaction_style_string_map =
114 OptionsHelper::compaction_style_string_map;
115static auto& compaction_pri_string_map =
116 OptionsHelper::compaction_pri_string_map;
1e59de90
TL
117static auto& temperature_string_map = OptionsHelper::temperature_string_map;
118static 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