]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/include/rocksdb/utilities/table_properties_collectors.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / include / rocksdb / utilities / table_properties_collectors.h
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 #pragma once
7 #ifndef ROCKSDB_LITE
8 #include <atomic>
9 #include <memory>
10
11 #include "rocksdb/table_properties.h"
12
13 namespace ROCKSDB_NAMESPACE {
14
15 // A factory of a table property collector that marks a SST
16 // file as need-compaction when it observe at least "D" deletion
17 // entries in any "N" consecutive entires.
18 class CompactOnDeletionCollectorFactory
19 : public TablePropertiesCollectorFactory {
20 public:
21 virtual ~CompactOnDeletionCollectorFactory() {}
22
23 virtual TablePropertiesCollector* CreateTablePropertiesCollector(
24 TablePropertiesCollectorFactory::Context context) override;
25
26 // Change the value of sliding_window_size "N"
27 // Setting it to 0 disables the delete triggered compaction
28 void SetWindowSize(size_t sliding_window_size) {
29 sliding_window_size_.store(sliding_window_size);
30 }
31
32 // Change the value of deletion_trigger "D"
33 void SetDeletionTrigger(size_t deletion_trigger) {
34 deletion_trigger_.store(deletion_trigger);
35 }
36
37 virtual const char* Name() const override {
38 return "CompactOnDeletionCollector";
39 }
40
41 private:
42 friend std::shared_ptr<CompactOnDeletionCollectorFactory>
43 NewCompactOnDeletionCollectorFactory(size_t sliding_window_size,
44 size_t deletion_trigger);
45 // A factory of a table property collector that marks a SST
46 // file as need-compaction when it observe at least "D" deletion
47 // entries in any "N" consecutive entires.
48 //
49 // @param sliding_window_size "N"
50 // @param deletion_trigger "D"
51 CompactOnDeletionCollectorFactory(size_t sliding_window_size,
52 size_t deletion_trigger)
53 : sliding_window_size_(sliding_window_size),
54 deletion_trigger_(deletion_trigger) {}
55
56 std::atomic<size_t> sliding_window_size_;
57 std::atomic<size_t> deletion_trigger_;
58 };
59
60 // Creates a factory of a table property collector that marks a SST
61 // file as need-compaction when it observe at least "D" deletion
62 // entries in any "N" consecutive entires.
63 //
64 // @param sliding_window_size "N". Note that this number will be
65 // round up to the smallest multiple of 128 that is no less
66 // than the specified size.
67 // @param deletion_trigger "D". Note that even when "N" is changed,
68 // the specified number for "D" will not be changed.
69 extern std::shared_ptr<CompactOnDeletionCollectorFactory>
70 NewCompactOnDeletionCollectorFactory(size_t sliding_window_size,
71 size_t deletion_trigger);
72 } // namespace ROCKSDB_NAMESPACE
73
74 #endif // !ROCKSDB_LITE