10
10
#include < vector>
11
11
12
12
#include " rocksdb/db.h"
13
- #include " rocksdb/options .h"
13
+ #include " rocksdb/status .h"
14
14
#include " rocksdb/table.h"
15
15
16
16
namespace ROCKSDB_NAMESPACE {
17
+ class Env ;
18
+ struct ColumnFamilyOptions ;
19
+ struct DBOptions ;
20
+ struct Options ;
21
+
22
+ // ConfigOptions containing the parameters/controls for
23
+ // comparing objects and converting to/from strings.
24
+ // These settings control how the methods
25
+ // treat errors (e.g. ignore_unknown_objects), the format
26
+ // of the serialization (e.g. delimiter), and how to compare
27
+ // options (sanity_level).
28
+ struct ConfigOptions {
29
+ // This enum defines the RocksDB options sanity level.
30
+ enum SanityLevel : unsigned char {
31
+ kSanityLevelNone = 0x01 , // Performs no sanity check at all.
32
+ // Performs minimum check to ensure the RocksDB instance can be
33
+ // opened without corrupting / mis-interpreting the data.
34
+ kSanityLevelLooselyCompatible = 0x02 ,
35
+ // Perform exact match sanity check.
36
+ kSanityLevelExactMatch = 0xFF ,
37
+ };
38
+
39
+ enum Depth {
40
+ kDepthDefault , // Traverse nested options that are not flagged as "shallow"
41
+ kDepthShallow , // Do not traverse into any nested options
42
+ kDepthDetailed , // Traverse nested options, overriding the options shallow
43
+ // setting
44
+ };
45
+
46
+ // When true, any unused options will be ignored and OK will be returned
47
+ bool ignore_unknown_options = false ;
48
+
49
+ // If the strings are escaped (old-style?)
50
+ bool input_strings_escaped = true ;
51
+
52
+ // The separator between options when converting to a string
53
+ std::string delimiter = " ;" ;
54
+
55
+ // Controls how to traverse options during print/match stages
56
+ Depth depth = Depth::kDepthDefault ;
57
+
58
+ // Controls how options are serialized
59
+ // Controls how pedantic the comparison must be for equivalency
60
+ SanityLevel sanity_level = SanityLevel::kSanityLevelExactMatch ;
61
+ // `file_readahead_size` is used for readahead for the option file.
62
+ size_t file_readahead_size = 512 * 1024 ;
63
+
64
+ // The environment to use for this option
65
+ Env* env = Env::Default();
66
+
67
+ bool IsShallow () const { return depth == Depth::kDepthShallow ; }
68
+ bool IsDetailed () const { return depth == Depth::kDepthDetailed ; }
69
+
70
+ bool IsCheckDisabled () const {
71
+ return sanity_level == SanityLevel::kSanityLevelNone ;
72
+ }
73
+
74
+ bool IsCheckEnabled (SanityLevel level) const {
75
+ return (level > SanityLevel::kSanityLevelNone && level <= sanity_level);
76
+ }
77
+ };
17
78
18
79
#ifndef ROCKSDB_LITE
80
+
19
81
// The following set of functions provide a way to construct RocksDB Options
20
82
// from a string or a string-to-string map. Here're the general rule of
21
83
// setting option values from strings by type. Some RocksDB types are also
@@ -134,13 +196,6 @@ namespace ROCKSDB_NAMESPACE {
134
196
// [Example]:
135
197
// * {"memtable", "vector:1024"} is equivalent to setting memtable
136
198
// to VectorRepFactory(1024).
137
- // - HashCuckooRepFactory:
138
- // Pass "cuckoo:<write_buffer_size>" to use HashCuckooRepFactory with the
139
- // specified write buffer size, or simply "cuckoo" to use the default
140
- // HashCuckooRepFactory.
141
- // [Example]:
142
- // * {"memtable", "cuckoo:1024"} is equivalent to setting memtable
143
- // to NewHashCuckooRepFactory(1024).
144
199
//
145
200
// * compression_opts:
146
201
// Use "compression_opts" to config compression_opts. The value format
@@ -153,6 +208,12 @@ namespace ROCKSDB_NAMESPACE {
153
208
// cf_opt.compression_opts.strategy = 6;
154
209
// cf_opt.compression_opts.max_dict_bytes = 7;
155
210
//
211
+ // The GetColumnFamilyOptionsFromMap(ConfigOptions, ...) should be used; the
212
+ // alternative signature may be deprecated in a future release. The equivalent
213
+ // functionality can be achieved by setting the corresponding options in
214
+ // the ConfigOptions parameter.
215
+ //
216
+ // @param config_options controls how the map is processed.
156
217
// @param base_options the default options of the output "new_options".
157
218
// @param opts_map an option name to value map for specifying how "new_options"
158
219
// should be set.
@@ -165,6 +226,11 @@ namespace ROCKSDB_NAMESPACE {
165
226
// instead of resulting in an unknown-option error.
166
227
// @return Status::OK() on success. Otherwise, a non-ok status indicating
167
228
// error will be returned, and "new_options" will be set to "base_options".
229
+ Status GetColumnFamilyOptionsFromMap (
230
+ const ConfigOptions& config_options,
231
+ const ColumnFamilyOptions& base_options,
232
+ const std::unordered_map<std::string, std::string>& opts_map,
233
+ ColumnFamilyOptions* new_options);
168
234
Status GetColumnFamilyOptionsFromMap (
169
235
const ColumnFamilyOptions& base_options,
170
236
const std::unordered_map<std::string, std::string>& opts_map,
@@ -184,6 +250,12 @@ Status GetColumnFamilyOptionsFromMap(
184
250
// - Passing {"rate_limiter_bytes_per_sec", "1024"} is equivalent to
185
251
// passing NewGenericRateLimiter(1024) to rate_limiter_bytes_per_sec.
186
252
//
253
+ // The GetDBOptionsFromMap(ConfigOptions, ...) should be used; the
254
+ // alternative signature may be deprecated in a future release. The equivalent
255
+ // functionality can be achieved by setting the corresponding options in
256
+ // the ConfigOptions parameter.
257
+ //
258
+ // @param config_options controls how the map is processed.
187
259
// @param base_options the default options of the output "new_options".
188
260
// @param opts_map an option name to value map for specifying how "new_options"
189
261
// should be set.
@@ -196,6 +268,10 @@ Status GetColumnFamilyOptionsFromMap(
196
268
// instead of resulting in an unknown-option error.
197
269
// @return Status::OK() on success. Otherwise, a non-ok status indicating
198
270
// error will be returned, and "new_options" will be set to "base_options".
271
+ Status GetDBOptionsFromMap (
272
+ const ConfigOptions& cfg_options, const DBOptions& base_options,
273
+ const std::unordered_map<std::string, std::string>& opts_map,
274
+ DBOptions* new_options);
199
275
Status GetDBOptionsFromMap (
200
276
const DBOptions& base_options,
201
277
const std::unordered_map<std::string, std::string>& opts_map,
@@ -227,6 +303,12 @@ Status GetDBOptionsFromMap(
227
303
// - Passing {"block_cache", "1M"} in GetBlockBasedTableOptionsFromMap is
228
304
// equivalent to setting block_cache using NewLRUCache(1024 * 1024).
229
305
//
306
+ // The GetBlockBasedTableOptionsFromMap(ConfigOptions, ...) should be used;
307
+ // the alternative signature may be deprecated in a future release. The
308
+ // equivalent functionality can be achieved by setting the corresponding
309
+ // options in the ConfigOptions parameter.
310
+ //
311
+ // @param config_options controls how the map is processed.
230
312
// @param table_options the default options of the output "new_table_options".
231
313
// @param opts_map an option name to value map for specifying how
232
314
// "new_table_options" should be set.
@@ -240,6 +322,11 @@ Status GetDBOptionsFromMap(
240
322
// @return Status::OK() on success. Otherwise, a non-ok status indicating
241
323
// error will be returned, and "new_table_options" will be set to
242
324
// "table_options".
325
+ Status GetBlockBasedTableOptionsFromMap (
326
+ const ConfigOptions& config_options,
327
+ const BlockBasedTableOptions& table_options,
328
+ const std::unordered_map<std::string, std::string>& opts_map,
329
+ BlockBasedTableOptions* new_table_options);
243
330
Status GetBlockBasedTableOptionsFromMap (
244
331
const BlockBasedTableOptions& table_options,
245
332
const std::unordered_map<std::string, std::string>& opts_map,
@@ -250,6 +337,12 @@ Status GetBlockBasedTableOptionsFromMap(
250
337
// map "opts_map" of option name to option value to construct the new
251
338
// PlainTableOptions "new_table_options".
252
339
//
340
+ // The GetPlainTableOptionsFromMap(ConfigOptions, ...) should be used; the
341
+ // alternative signature may be deprecated in a future release. The equivalent
342
+ // functionality can be achieved by setting the corresponding options in
343
+ // the ConfigOptions parameter.
344
+ //
345
+ // @param config_options controls how the map is processed.
253
346
// @param table_options the default options of the output "new_table_options".
254
347
// @param opts_map an option name to value map for specifying how
255
348
// "new_table_options" should be set.
@@ -263,36 +356,61 @@ Status GetBlockBasedTableOptionsFromMap(
263
356
// @return Status::OK() on success. Otherwise, a non-ok status indicating
264
357
// error will be returned, and "new_table_options" will be set to
265
358
// "table_options".
359
+ Status GetPlainTableOptionsFromMap (
360
+ const ConfigOptions& config_options, const PlainTableOptions& table_options,
361
+ const std::unordered_map<std::string, std::string>& opts_map,
362
+ PlainTableOptions* new_table_options);
266
363
Status GetPlainTableOptionsFromMap (
267
364
const PlainTableOptions& table_options,
268
365
const std::unordered_map<std::string, std::string>& opts_map,
269
366
PlainTableOptions* new_table_options, bool input_strings_escaped = false ,
270
367
bool ignore_unknown_options = false );
271
368
272
- // Take a string representation of option names and values, apply them into the
369
+ // Take a string representation of option names and values, apply them into the
273
370
// base_options, and return the new options as a result. The string has the
274
371
// following format:
275
372
// "write_buffer_size=1024;max_write_buffer_number=2"
276
373
// Nested options config is also possible. For example, you can define
277
374
// BlockBasedTableOptions as part of the string for block-based table factory:
278
375
// "write_buffer_size=1024;block_based_table_factory={block_size=4k};"
279
376
// "max_write_buffer_num=2"
377
+ //
378
+ //
379
+ // The GetColumnFamilyOptionsFromString(ConfigOptions, ...) should be used; the
380
+ // alternative signature may be deprecated in a future release. The equivalent
381
+ // functionality can be achieved by setting the corresponding options in
382
+ // the ConfigOptions parameter.
383
+ Status GetColumnFamilyOptionsFromString (const ConfigOptions& config_options,
384
+ const ColumnFamilyOptions& base_options,
385
+ const std::string& opts_str,
386
+ ColumnFamilyOptions* new_options);
280
387
Status GetColumnFamilyOptionsFromString (const ColumnFamilyOptions& base_options,
281
388
const std::string& opts_str,
282
389
ColumnFamilyOptions* new_options);
283
390
391
+ Status GetDBOptionsFromString (const ConfigOptions& config_options,
392
+ const DBOptions& base_options,
393
+ const std::string& opts_str,
394
+ DBOptions* new_options);
395
+
284
396
Status GetDBOptionsFromString (const DBOptions& base_options,
285
397
const std::string& opts_str,
286
398
DBOptions* new_options);
287
399
400
+ Status GetStringFromDBOptions (const ConfigOptions& config_options,
401
+ const DBOptions& db_options,
402
+ std::string* opts_str);
403
+
288
404
Status GetStringFromDBOptions (std::string* opts_str,
289
405
const DBOptions& db_options,
290
406
const std::string& delimiter = " ; " );
291
407
408
+ Status GetStringFromColumnFamilyOptions (const ConfigOptions& config_options,
409
+ const ColumnFamilyOptions& cf_options,
410
+ std::string* opts_str);
292
411
Status GetStringFromColumnFamilyOptions (std::string* opts_str,
293
412
const ColumnFamilyOptions& cf_options,
294
413
const std::string& delimiter = " ; " );
295
-
296
414
Status GetStringFromCompressionType (std::string* compression_str,
297
415
CompressionType compression_type);
298
416
@@ -301,17 +419,28 @@ std::vector<CompressionType> GetSupportedCompressions();
301
419
Status GetBlockBasedTableOptionsFromString (
302
420
const BlockBasedTableOptions& table_options, const std::string& opts_str,
303
421
BlockBasedTableOptions* new_table_options);
422
+ Status GetBlockBasedTableOptionsFromString (
423
+ const ConfigOptions& config_options,
424
+ const BlockBasedTableOptions& table_options, const std::string& opts_str,
425
+ BlockBasedTableOptions* new_table_options);
304
426
305
427
Status GetPlainTableOptionsFromString (const PlainTableOptions& table_options,
306
428
const std::string& opts_str,
307
429
PlainTableOptions* new_table_options);
430
+ Status GetPlainTableOptionsFromString (const ConfigOptions& config_options,
431
+ const PlainTableOptions& table_options,
432
+ const std::string& opts_str,
433
+ PlainTableOptions* new_table_options);
308
434
309
435
Status GetMemTableRepFactoryFromString (
310
436
const std::string& opts_str,
311
437
std::unique_ptr<MemTableRepFactory>* new_mem_factory);
312
438
313
439
Status GetOptionsFromString (const Options& base_options,
314
440
const std::string& opts_str, Options* new_options);
441
+ Status GetOptionsFromString (const ConfigOptions& config_options,
442
+ const Options& base_options,
443
+ const std::string& opts_str, Options* new_options);
315
444
316
445
Status StringToMap (const std::string& opts_str,
317
446
std::unordered_map<std::string, std::string>* opts_map);
0 commit comments