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:
18   FIFOCompactionPicker(const ImmutableCFOptions& 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       VersionStorageInfo* version, LogBuffer* log_buffer,
25       SequenceNumber earliest_memtable_seqno = kMaxSequenceNumber) override;
26 
27   virtual Compaction* CompactRange(
28       const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
29       VersionStorageInfo* vstorage, int input_level, int output_level,
30       const CompactRangeOptions& compact_range_options,
31       const InternalKey* begin, const InternalKey* end,
32       InternalKey** compaction_end, bool* manual_conflict,
33       uint64_t max_file_num_to_ignore) override;
34 
35   // The maximum allowed output level.  Always returns 0.
36   virtual int MaxOutputLevel() const override { return 0; }
37 
38   virtual bool NeedsCompaction(
39       const VersionStorageInfo* vstorage) const override;
40 
41  private:
42   Compaction* PickTTLCompaction(const std::string& cf_name,
43                                 const MutableCFOptions& mutable_cf_options,
44                                 VersionStorageInfo* version,
45                                 LogBuffer* log_buffer);
46 
47   Compaction* PickSizeCompaction(const std::string& cf_name,
48                                  const MutableCFOptions& mutable_cf_options,
49                                  VersionStorageInfo* version,
50                                  LogBuffer* log_buffer);
51 };
52 }  // namespace ROCKSDB_NAMESPACE
53 #endif  // !ROCKSDB_LITE
54