]>
git.proxmox.com Git - ceph.git/blob - 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.
6 #include "rocksdb/write_batch_base.h"
10 #include "rocksdb/slice.h"
11 #include "rocksdb/status.h"
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
);
23 return Put(column_family
, key_slice
, value_slice
);
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
);
31 return Put(key_slice
, value_slice
);
34 Status
WriteBatchBase::Delete(ColumnFamilyHandle
* column_family
,
35 const SliceParts
& key
) {
37 Slice
key_slice(key
, &key_buf
);
38 return Delete(column_family
, key_slice
);
41 Status
WriteBatchBase::Delete(const SliceParts
& key
) {
43 Slice
key_slice(key
, &key_buf
);
44 return Delete(key_slice
);
47 Status
WriteBatchBase::SingleDelete(ColumnFamilyHandle
* column_family
,
48 const SliceParts
& key
) {
50 Slice
key_slice(key
, &key_buf
);
51 return SingleDelete(column_family
, key_slice
);
54 Status
WriteBatchBase::SingleDelete(const SliceParts
& key
) {
56 Slice
key_slice(key
, &key_buf
);
57 return SingleDelete(key_slice
);
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
);
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
);
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
);
83 return Merge(column_family
, key_slice
, value_slice
);
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
);
91 return Merge(key_slice
, value_slice
);
94 } // namespace rocksdb