compaction_picker_fifo.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. namespace ROCKSDB_NAMESPACE {
  12. class FIFOCompactionPicker : public CompactionPicker {
  13. public:
  14. FIFOCompactionPicker(const ImmutableOptions& ioptions,
  15. const InternalKeyComparator* icmp)
  16. : CompactionPicker(ioptions, icmp) {}
  17. Compaction* PickCompaction(
  18. const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
  19. const MutableDBOptions& mutable_db_options,
  20. const std::vector<SequenceNumber>& /* existing_snapshots */,
  21. const SnapshotChecker* /* snapshot_checker */,
  22. VersionStorageInfo* version, LogBuffer* log_buffer,
  23. bool /* require_max_output_level*/ = false) override;
  24. Compaction* PickCompactionForCompactRange(
  25. const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
  26. const MutableDBOptions& mutable_db_options, VersionStorageInfo* vstorage,
  27. int input_level, int output_level,
  28. const CompactRangeOptions& compact_range_options,
  29. const InternalKey* begin, const InternalKey* end,
  30. InternalKey** compaction_end, bool* manual_conflict,
  31. uint64_t max_file_num_to_ignore, const std::string& trim_ts) override;
  32. // The maximum allowed output level. Always returns 0.
  33. int MaxOutputLevel() const override { return 0; }
  34. bool NeedsCompaction(const VersionStorageInfo* vstorage) const override;
  35. private:
  36. Compaction* PickTTLCompaction(const std::string& cf_name,
  37. const MutableCFOptions& mutable_cf_options,
  38. const MutableDBOptions& mutable_db_options,
  39. VersionStorageInfo* version,
  40. LogBuffer* log_buffer);
  41. Compaction* PickSizeCompaction(const std::string& cf_name,
  42. const MutableCFOptions& mutable_cf_options,
  43. const MutableDBOptions& mutable_db_options,
  44. VersionStorageInfo* version,
  45. LogBuffer* log_buffer);
  46. // Will pick one file to compact at a time, starting from the oldest file.
  47. Compaction* PickTemperatureChangeCompaction(
  48. const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
  49. const MutableDBOptions& mutable_db_options, VersionStorageInfo* vstorage,
  50. LogBuffer* log_buffer) const;
  51. };
  52. } // namespace ROCKSDB_NAMESPACE