compaction_picker_universal.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  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. //
  6. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  7. // Use of this source code is governed by a BSD-style license that can be
  8. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  9. #pragma once
  10. #include "db/compaction/compaction_picker.h"
  11. #include "db/snapshot_checker.h"
  12. namespace ROCKSDB_NAMESPACE {
  13. class UniversalCompactionPicker : public CompactionPicker {
  14. public:
  15. UniversalCompactionPicker(const ImmutableOptions& ioptions,
  16. const InternalKeyComparator* icmp)
  17. : CompactionPicker(ioptions, icmp) {}
  18. // If `require_max_output_level` is true, only pick compaction
  19. // with max output level or return nullptr if no such compaction exists.
  20. Compaction* PickCompaction(
  21. const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
  22. const MutableDBOptions& mutable_db_options,
  23. const std::vector<SequenceNumber>& existing_snapshots,
  24. const SnapshotChecker* snapshot_checker, VersionStorageInfo* vstorage,
  25. LogBuffer* log_buffer, bool require_max_output_level = false) override;
  26. int MaxOutputLevel() const override { return NumberLevels() - 1; }
  27. bool NeedsCompaction(const VersionStorageInfo* vstorage) const override;
  28. };
  29. } // namespace ROCKSDB_NAMESPACE