db_stress_compression_manager.cc 1.2 KB

12345678910111213141516171819202122232425262728
  1. // Copyright (c) Meta Platforms, Inc. and affiliates.
  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. #include "db_stress_compression_manager.h"
  6. #include "rocksdb/utilities/object_registry.h"
  7. namespace ROCKSDB_NAMESPACE {
  8. void DbStressCustomCompressionManager::Register() {
  9. // We must register any compression managers with a custom
  10. // CompatibilityName() so that if it was used in a past invocation but not
  11. // the current invocation, we can still read the SST files requiring it.
  12. static std::once_flag loaded;
  13. std::call_once(loaded, [&]() {
  14. TEST_AllowUnsupportedFormatVersion() = true;
  15. auto& library = *ObjectLibrary::Default();
  16. library.AddFactory<CompressionManager>(
  17. DbStressCustomCompressionManager().CompatibilityName(),
  18. [](const std::string& /*uri*/,
  19. std::unique_ptr<CompressionManager>* guard,
  20. std::string* /*errmsg*/) {
  21. *guard = std::make_unique<DbStressCustomCompressionManager>();
  22. return guard->get();
  23. });
  24. });
  25. }
  26. } // namespace ROCKSDB_NAMESPACE