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).
7 #include "rocksdb/merge_operator.h"
8 #include "rocksdb/slice.h"
9 #include "utilities/cassandra/cassandra_options.h"
11 namespace ROCKSDB_NAMESPACE
{
15 * A MergeOperator for rocksdb that implements Cassandra row value merge.
17 class CassandraValueMergeOperator
: public MergeOperator
{
19 explicit CassandraValueMergeOperator(int32_t gc_grace_period_in_seconds
,
20 size_t operands_limit
= 0);
22 virtual bool FullMergeV2(const MergeOperationInput
& merge_in
,
23 MergeOperationOutput
* merge_out
) const override
;
25 virtual bool PartialMergeMulti(const Slice
& key
,
26 const std::deque
<Slice
>& operand_list
,
27 std::string
* new_value
,
28 Logger
* logger
) const override
;
30 const char* Name() const override
{ return kClassName(); }
31 static const char* kClassName() { return "CassandraValueMergeOperator"; }
33 virtual bool AllowSingleOperand() const override
{ return true; }
35 virtual bool ShouldMerge(const std::vector
<Slice
>& operands
) const override
{
36 return options_
.operands_limit
> 0 &&
37 operands
.size() >= options_
.operands_limit
;
41 CassandraOptions options_
;
43 } // namespace cassandra
44 } // namespace ROCKSDB_NAMESPACE