blob: 602a4d01aa3f5344c4382b5ffa037195086e1aac [file] [log] [blame]
Marc Kupietz28cc53e2017-12-23 17:24:55 +01001// 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#ifndef MERGE_OPERATORS_H
7#define MERGE_OPERATORS_H
8
9#include <memory>
10#include <stdio.h>
11
12#include "rocksdb/merge_operator.h"
13
14namespace rocksdb {
15
16class MergeOperators {
17 public:
18 static std::shared_ptr<MergeOperator> CreatePutOperator();
19 static std::shared_ptr<MergeOperator> CreateDeprecatedPutOperator();
20 static std::shared_ptr<MergeOperator> CreateUInt64AddOperator();
21 static std::shared_ptr<MergeOperator> CreateStringAppendOperator();
22 static std::shared_ptr<MergeOperator> CreateStringAppendTESTOperator();
23 static std::shared_ptr<MergeOperator> CreateMaxOperator();
24
25 // Will return a different merge operator depending on the string.
26 // TODO: Hook the "name" up to the actual Name() of the MergeOperators?
27 static std::shared_ptr<MergeOperator> CreateFromStringId(
28 const std::string& name) {
29 if (name == "put") {
30 return CreatePutOperator();
31 } else if (name == "put_v1") {
32 return CreateDeprecatedPutOperator();
33 } else if ( name == "uint64add") {
34 return CreateUInt64AddOperator();
35 } else if (name == "stringappend") {
36 return CreateStringAppendOperator();
37 } else if (name == "stringappendtest") {
38 return CreateStringAppendTESTOperator();
39 } else if (name == "max") {
40 return CreateMaxOperator();
41 } else {
42 // Empty or unknown, just return nullptr
43 return nullptr;
44 }
45 }
46
47};
48
49} // namespace rocksdb
50
51#endif