YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/rocksdb/utilities/merge_operators.h
Line
Count
Source (jump to first uncovered line)
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under the BSD-style license found in the
3
//  LICENSE file in the root directory of this source tree. An additional grant
4
//  of patent rights can be found in the PATENTS file in the same directory.
5
//
6
// The following only applies to changes made to this file as part of YugaByte development.
7
//
8
// Portions Copyright (c) YugaByte, Inc.
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
11
// in compliance with the License.  You may obtain a copy of the License at
12
//
13
// http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software distributed under the License
16
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17
// or implied.  See the License for the specific language governing permissions and limitations
18
// under the License.
19
//
20
#ifndef MERGE_OPERATORS_H
21
#define MERGE_OPERATORS_H
22
23
#include <memory>
24
#include <stdio.h>
25
26
#include "yb/rocksdb/merge_operator.h"
27
28
namespace rocksdb {
29
30
class MergeOperators {
31
 public:
32
  static std::shared_ptr<MergeOperator> CreatePutOperator();
33
  static std::shared_ptr<MergeOperator> CreateUInt64AddOperator();
34
  static std::shared_ptr<MergeOperator> CreateStringAppendOperator();
35
  static std::shared_ptr<MergeOperator> CreateStringAppendTESTOperator();
36
37
  // Will return a different merge operator depending on the string.
38
  // TODO: Hook the "name" up to the actual Name() of the MergeOperators?
39
  static std::shared_ptr<MergeOperator> CreateFromStringId(
40
55
      const std::string& name) {
41
55
    if (name == "put") {
42
0
      return CreatePutOperator();
43
55
    } else if ( name == "uint64add") {
44
0
      return CreateUInt64AddOperator();
45
55
    } else if (name == "stringappend") {
46
55
      return CreateStringAppendOperator();
47
0
    } else if (name == "stringappendtest") {
48
0
      return CreateStringAppendTESTOperator();
49
0
    } else {
50
      // Empty or unknown, just return nullptr
51
0
      return nullptr;
52
0
    }
53
55
  }
54
55
};
56
57
} // namespace rocksdb
58
59
#endif