compaction_picker_fifo.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef ROCKSDB_LITE
  11. #include "db/compaction/compaction_picker.h"
  12. namespace ROCKSDB_NAMESPACE {
  13. class FIFOCompactionPicker : public CompactionPicker {
  14. public:
  15. FIFOCompactionPicker(const ImmutableCFOptions& ioptions,
  16. const InternalKeyComparator* icmp)
  17. : CompactionPicker(ioptions, icmp) {}
  18. virtual Compaction* PickCompaction(
  19. const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
  20. VersionStorageInfo* version, LogBuffer* log_buffer,
  21. SequenceNumber earliest_memtable_seqno = kMaxSequenceNumber) override;
  22. virtual Compaction* CompactRange(
  23. const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
  24. VersionStorageInfo* vstorage, int input_level, int output_level,
  25. const CompactRangeOptions& compact_range_options,
  26. const InternalKey* begin, const InternalKey* end,
  27. InternalKey** compaction_end, bool* manual_conflict,
  28. uint64_t max_file_num_to_ignore) override;
  29. // The maximum allowed output level. Always returns 0.
  30. virtual int MaxOutputLevel() const override { return 0; }
  31. virtual bool NeedsCompaction(
  32. const VersionStorageInfo* vstorage) const override;
  33. private:
  34. Compaction* PickTTLCompaction(const std::string& cf_name,
  35. const MutableCFOptions& mutable_cf_options,
  36. VersionStorageInfo* version,
  37. LogBuffer* log_buffer);
  38. Compaction* PickSizeCompaction(const std::string& cf_name,
  39. const MutableCFOptions& mutable_cf_options,
  40. VersionStorageInfo* version,
  41. LogBuffer* log_buffer);
  42. };
  43. } // namespace ROCKSDB_NAMESPACE
  44. #endif // !ROCKSDB_LITE