options_sanity_check.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #pragma once
  6. #include <string>
  7. #include <unordered_map>
  8. #include "rocksdb/rocksdb_namespace.h"
  9. #ifndef ROCKSDB_LITE
  10. namespace ROCKSDB_NAMESPACE {
  11. // This enum defines the RocksDB options sanity level.
  12. enum OptionsSanityCheckLevel : unsigned char {
  13. // Performs no sanity check at all.
  14. kSanityLevelNone = 0x00,
  15. // Performs minimum check to ensure the RocksDB instance can be
  16. // opened without corrupting / mis-interpreting the data.
  17. kSanityLevelLooselyCompatible = 0x01,
  18. // Perform exact match sanity check.
  19. kSanityLevelExactMatch = 0xFF,
  20. };
  21. // The sanity check level for DB options
  22. static const std::unordered_map<std::string, OptionsSanityCheckLevel>
  23. sanity_level_db_options {};
  24. // The sanity check level for column-family options
  25. static const std::unordered_map<std::string, OptionsSanityCheckLevel>
  26. sanity_level_cf_options = {
  27. {"comparator", kSanityLevelLooselyCompatible},
  28. {"table_factory", kSanityLevelLooselyCompatible},
  29. {"merge_operator", kSanityLevelLooselyCompatible}};
  30. // The sanity check level for block-based table options
  31. static const std::unordered_map<std::string, OptionsSanityCheckLevel>
  32. sanity_level_bbt_options {};
  33. OptionsSanityCheckLevel DBOptionSanityCheckLevel(
  34. const std::string& options_name);
  35. OptionsSanityCheckLevel CFOptionSanityCheckLevel(
  36. const std::string& options_name);
  37. OptionsSanityCheckLevel BBTOptionSanityCheckLevel(
  38. const std::string& options_name);
  39. } // namespace ROCKSDB_NAMESPACE
  40. #endif // !ROCKSDB_LITE