Coverage Report

Created: 2024-07-27 06:53

/src/rocksdb/db/write_batch_base.cc
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 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
#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_NAMESPACE {
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
0
                           const SliceParts& key, const SliceParts& value) {
19
0
  std::string key_buf, value_buf;
20
0
  Slice key_slice(key, &key_buf);
21
0
  Slice value_slice(value, &value_buf);
22
23
0
  return Put(column_family, key_slice, value_slice);
24
0
}
25
26
0
Status WriteBatchBase::Put(const SliceParts& key, const SliceParts& value) {
27
0
  std::string key_buf, value_buf;
28
0
  Slice key_slice(key, &key_buf);
29
0
  Slice value_slice(value, &value_buf);
30
31
0
  return Put(key_slice, value_slice);
32
0
}
33
34
Status WriteBatchBase::Delete(ColumnFamilyHandle* column_family,
35
0
                              const SliceParts& key) {
36
0
  std::string key_buf;
37
0
  Slice key_slice(key, &key_buf);
38
0
  return Delete(column_family, key_slice);
39
0
}
40
41
0
Status WriteBatchBase::Delete(const SliceParts& key) {
42
0
  std::string key_buf;
43
0
  Slice key_slice(key, &key_buf);
44
0
  return Delete(key_slice);
45
0
}
46
47
Status WriteBatchBase::SingleDelete(ColumnFamilyHandle* column_family,
48
0
                                    const SliceParts& key) {
49
0
  std::string key_buf;
50
0
  Slice key_slice(key, &key_buf);
51
0
  return SingleDelete(column_family, key_slice);
52
0
}
53
54
0
Status WriteBatchBase::SingleDelete(const SliceParts& key) {
55
0
  std::string key_buf;
56
0
  Slice key_slice(key, &key_buf);
57
0
  return SingleDelete(key_slice);
58
0
}
59
60
Status WriteBatchBase::DeleteRange(ColumnFamilyHandle* column_family,
61
                                   const SliceParts& begin_key,
62
0
                                   const SliceParts& end_key) {
63
0
  std::string begin_key_buf, end_key_buf;
64
0
  Slice begin_key_slice(begin_key, &begin_key_buf);
65
0
  Slice end_key_slice(end_key, &end_key_buf);
66
0
  return DeleteRange(column_family, begin_key_slice, end_key_slice);
67
0
}
68
69
Status WriteBatchBase::DeleteRange(const SliceParts& begin_key,
70
0
                                   const SliceParts& end_key) {
71
0
  std::string begin_key_buf, end_key_buf;
72
0
  Slice begin_key_slice(begin_key, &begin_key_buf);
73
0
  Slice end_key_slice(end_key, &end_key_buf);
74
0
  return DeleteRange(begin_key_slice, end_key_slice);
75
0
}
76
77
Status WriteBatchBase::Merge(ColumnFamilyHandle* column_family,
78
0
                             const SliceParts& key, const SliceParts& value) {
79
0
  std::string key_buf, value_buf;
80
0
  Slice key_slice(key, &key_buf);
81
0
  Slice value_slice(value, &value_buf);
82
83
0
  return Merge(column_family, key_slice, value_slice);
84
0
}
85
86
0
Status WriteBatchBase::Merge(const SliceParts& key, const SliceParts& value) {
87
0
  std::string key_buf, value_buf;
88
0
  Slice key_slice(key, &key_buf);
89
0
  Slice value_slice(value, &value_buf);
90
91
0
  return Merge(key_slice, value_slice);
92
0
}
93
94
}  // namespace ROCKSDB_NAMESPACE