]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/write_batch_base.cc
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / db / write_batch_base.cc
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 #include "rocksdb/write_batch_base.h"
7
8 #include <string>
9
10 #include "rocksdb/slice.h"
11 #include "rocksdb/status.h"
12
13 namespace rocksdb {
14
15 // Simple implementation of SlicePart variants of Put(). Child classes
16 // can override these method with more performant solutions if they choose.
17 Status WriteBatchBase::Put(ColumnFamilyHandle* column_family,
18 const SliceParts& key, const SliceParts& value) {
19 std::string key_buf, value_buf;
20 Slice key_slice(key, &key_buf);
21 Slice value_slice(value, &value_buf);
22
23 return Put(column_family, key_slice, value_slice);
24 }
25
26 Status WriteBatchBase::Put(const SliceParts& key, const SliceParts& value) {
27 std::string key_buf, value_buf;
28 Slice key_slice(key, &key_buf);
29 Slice value_slice(value, &value_buf);
30
31 return Put(key_slice, value_slice);
32 }
33
34 Status WriteBatchBase::Delete(ColumnFamilyHandle* column_family,
35 const SliceParts& key) {
36 std::string key_buf;
37 Slice key_slice(key, &key_buf);
38 return Delete(column_family, key_slice);
39 }
40
41 Status WriteBatchBase::Delete(const SliceParts& key) {
42 std::string key_buf;
43 Slice key_slice(key, &key_buf);
44 return Delete(key_slice);
45 }
46
47 Status WriteBatchBase::SingleDelete(ColumnFamilyHandle* column_family,
48 const SliceParts& key) {
49 std::string key_buf;
50 Slice key_slice(key, &key_buf);
51 return SingleDelete(column_family, key_slice);
52 }
53
54 Status WriteBatchBase::SingleDelete(const SliceParts& key) {
55 std::string key_buf;
56 Slice key_slice(key, &key_buf);
57 return SingleDelete(key_slice);
58 }
59
60 Status WriteBatchBase::DeleteRange(ColumnFamilyHandle* column_family,
61 const SliceParts& begin_key,
62 const SliceParts& end_key) {
63 std::string begin_key_buf, end_key_buf;
64 Slice begin_key_slice(begin_key, &begin_key_buf);
65 Slice end_key_slice(end_key, &end_key_buf);
66 return DeleteRange(column_family, begin_key_slice, end_key_slice);
67 }
68
69 Status WriteBatchBase::DeleteRange(const SliceParts& begin_key,
70 const SliceParts& end_key) {
71 std::string begin_key_buf, end_key_buf;
72 Slice begin_key_slice(begin_key, &begin_key_buf);
73 Slice end_key_slice(end_key, &end_key_buf);
74 return DeleteRange(begin_key_slice, end_key_slice);
75 }
76
77 Status WriteBatchBase::Merge(ColumnFamilyHandle* column_family,
78 const SliceParts& key, const SliceParts& value) {
79 std::string key_buf, value_buf;
80 Slice key_slice(key, &key_buf);
81 Slice value_slice(value, &value_buf);
82
83 return Merge(column_family, key_slice, value_slice);
84 }
85
86 Status WriteBatchBase::Merge(const SliceParts& key, const SliceParts& value) {
87 std::string key_buf, value_buf;
88 Slice key_slice(key, &key_buf);
89 Slice value_slice(value, &value_buf);
90
91 return Merge(key_slice, value_slice);
92 }
93
94 } // namespace rocksdb