]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/cassandra/cassandra_compaction_filter.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / utilities / cassandra / cassandra_compaction_filter.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 #include <string>
8 #include "rocksdb/compaction_filter.h"
9 #include "rocksdb/slice.h"
10
11 namespace ROCKSDB_NAMESPACE {
12 namespace cassandra {
13
14 /**
15 * Compaction filter for removing expired Cassandra data with ttl.
16 * If option `purge_ttl_on_expiration` is set to true, expired data
17 * will be directly purged. Otherwise expired data will be converted
18 * tombstones first, then be eventally removed after gc grace period.
19 * `purge_ttl_on_expiration` should only be on in the case all the
20 * writes have same ttl setting, otherwise it could bring old data back.
21 *
22 * Compaction filter is also in charge of removing tombstone that has been
23 * promoted to kValue type after serials of merging in compaction.
24 */
25 class CassandraCompactionFilter : public CompactionFilter {
26 public:
27 explicit CassandraCompactionFilter(bool purge_ttl_on_expiration,
28 int32_t gc_grace_period_in_seconds)
29 : purge_ttl_on_expiration_(purge_ttl_on_expiration),
30 gc_grace_period_in_seconds_(gc_grace_period_in_seconds) {}
31
32 const char* Name() const override;
33 virtual Decision FilterV2(int level, const Slice& key, ValueType value_type,
34 const Slice& existing_value, std::string* new_value,
35 std::string* skip_until) const override;
36
37 private:
38 bool purge_ttl_on_expiration_;
39 int32_t gc_grace_period_in_seconds_;
40 };
41 } // namespace cassandra
42 } // namespace ROCKSDB_NAMESPACE