]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/compaction_filters/layered_compaction_filter_base.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / utilities / compaction_filters / layered_compaction_filter_base.h
1 // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. See the AUTHORS file for names of contributors.
5
6 #pragma once
7 #include <memory>
8
9 #include "rocksdb/compaction_filter.h"
10
11 namespace ROCKSDB_NAMESPACE {
12
13 // Abstract base class for building layered compaction filter on top of
14 // user compaction filter.
15 // See BlobIndexCompactionFilter or TtlCompactionFilter for a basic usage.
16 class LayeredCompactionFilterBase : public CompactionFilter {
17 public:
18 LayeredCompactionFilterBase(
19 const CompactionFilter* _user_comp_filter,
20 std::unique_ptr<const CompactionFilter> _user_comp_filter_from_factory)
21 : user_comp_filter_(_user_comp_filter),
22 user_comp_filter_from_factory_(
23 std::move(_user_comp_filter_from_factory)) {
24 if (!user_comp_filter_) {
25 user_comp_filter_ = user_comp_filter_from_factory_.get();
26 }
27 }
28
29 // Return a pointer to user compaction filter
30 const CompactionFilter* user_comp_filter() const { return user_comp_filter_; }
31
32 const Customizable* Inner() const override { return user_comp_filter_; }
33
34 protected:
35 const CompactionFilter* user_comp_filter_;
36
37 private:
38 std::unique_ptr<const CompactionFilter> user_comp_filter_from_factory_;
39 };
40
41 } // namespace ROCKSDB_NAMESPACE