1. get an option class from an .
  2. get it from an option string by calling
  3. get it from a string map

To get an option from a string, call helper function or GetDBOptionsFromString() with a string containing the information. There is also a special GetBlockBasedTableOptionsFromString() and GetPlainTableOptionsFromString() to get table specific option.

An example of an option string will like this:

Similarly, users can get option classes from a string map, by calling helper function GetColumnFamilyOptionsFromMap(), GetDBOptionsFromMap(), GetBlockBasedTableOptionsFromMap() or GetPlainTableOptionsFromMap(). The string to string map is passed in, which maps from the option name and the option value, as a plain text string. An example of string map for an option is like this:

  1. std::unordered_map<std::string, std::string> cf_options_map = {
  2. {"write_buffer_size", "1"},
  3. {"max_write_buffer_number", "2"},
  4. {"min_write_buffer_number_to_merge", "3"},
  5. {"max_write_buffer_number_to_maintain", "99"},
  6. {"compression", "kSnappyCompression"},
  7. {"compression_per_level",
  8. "kNoCompression:"
  9. "kSnappyCompression:"
  10. "kZlibCompression:"
  11. "kBZip2Compression:"
  12. "kLZ4Compression:"
  13. "kLZ4HCCompression:"
  14. "kXpressCompression:"
  15. "kZSTDNotFinalCompression"},
  16. {"bottommost_compression", "kLZ4Compression"},
  17. {"compression_opts", "4:5:6:7"},
  18. {"level0_file_num_compaction_trigger", "8"},
  19. {"level0_slowdown_writes_trigger", "9"},
  20. {"level0_stop_writes_trigger", "10"},
  21. {"target_file_size_base", "12"},
  22. {"target_file_size_multiplier", "13"},
  23. {"max_bytes_for_level_base", "14"},
  24. {"level_compaction_dynamic_level_bytes", "true"},
  25. {"max_bytes_for_level_multiplier", "15.0"},
  26. {"max_bytes_for_level_multiplier_additional", "16:17:18"},
  27. {"max_compaction_bytes", "21"},
  28. {"soft_rate_limit", "1.1"},
  29. {"hard_rate_limit", "2.1"},
  30. {"hard_pending_compaction_bytes_limit", "211"},
  31. {"arena_block_size", "22"},
  32. {"disable_auto_compactions", "true"},
  33. {"verify_checksums_in_compaction", "false"},
  34. {"compaction_options_fifo", "23"},
  35. {"max_sequential_skip_in_iterations", "24"},
  36. {"inplace_update_support", "true"},
  37. {"report_bg_io_stats", "true"},
  38. {"compaction_measure_io_stats", "false"},
  39. {"inplace_update_num_locks", "25"},
  40. {"memtable_prefix_bloom_size_ratio", "0.26"},
  41. {"memtable_huge_page_size", "28"},
  42. {"bloom_locality", "29"},
  43. {"max_successive_merges", "30"},
  44. {"prefix_extractor", "fixed:31"},
  45. {"optimize_filters_for_hits", "true"},
  46. };

To find the list of options supported, check the section below.

Note, although most of the options in the option class are supported in the option string, there are exceptions. You can find the list of supported options in variable db_options_type_info, cf_options_type_info and block_based_table_type_info in the source file of the source code of your release.

If the option is a callback class, e.g. comparators, compaction filter, and merge operators, you will usually need to pass the pointer of the callback class as the value, which will be casted in to an object.

  • Prefix extractor (option name prefix_extractor), whose value can be passed as rocksdb.FixedPrefix.<prefix_length> or rocksdb.CappedPrefix.<prefix_length>.
  • Filter policy (option name filter_policy), whose value can be passed as bloomfilter:<bits_per_key>:<use_block_based>
  • Table factory (option name table_factory). The values will be either BlockBasedTable or PlainTable. Other than that, two special option string names are used to provide the options, block_based_table_factory or plain_table_factory. The value of the options will be the option string of BlockBasedTableOptions or PlainTableOptions.
  • Memtable Factory (option name memtable_factory). It can take value of skip_list, prefix_hash, hash_linkedlist, vector or .