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