]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/cassandra/merge_operator.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / utilities / cassandra / merge_operator.h
1 // Copyright (c) 2017-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 "rocksdb/merge_operator.h"
8 #include "rocksdb/slice.h"
9 #include "utilities/cassandra/cassandra_options.h"
10
11 namespace ROCKSDB_NAMESPACE {
12 namespace cassandra {
13
14 /**
15 * A MergeOperator for rocksdb that implements Cassandra row value merge.
16 */
17 class CassandraValueMergeOperator : public MergeOperator {
18 public:
19 explicit CassandraValueMergeOperator(int32_t gc_grace_period_in_seconds,
20 size_t operands_limit = 0);
21
22 virtual bool FullMergeV2(const MergeOperationInput& merge_in,
23 MergeOperationOutput* merge_out) const override;
24
25 virtual bool PartialMergeMulti(const Slice& key,
26 const std::deque<Slice>& operand_list,
27 std::string* new_value,
28 Logger* logger) const override;
29
30 const char* Name() const override { return kClassName(); }
31 static const char* kClassName() { return "CassandraValueMergeOperator"; }
32
33 virtual bool AllowSingleOperand() const override { return true; }
34
35 virtual bool ShouldMerge(const std::vector<Slice>& operands) const override {
36 return options_.operands_limit > 0 &&
37 operands.size() >= options_.operands_limit;
38 }
39
40 private:
41 CassandraOptions options_;
42 };
43 } // namespace cassandra
44 } // namespace ROCKSDB_NAMESPACE