Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
read_modify_write_rule.h
1// Copyright 2018 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_READ_MODIFY_WRITE_RULE_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_READ_MODIFY_WRITE_RULE_H
17
18#include "google/cloud/bigtable/version.h"
19#include <google/bigtable/v2/data.pb.h>
20#include <google/protobuf/util/message_differencer.h>
21#include <string>
22
23namespace google {
24namespace cloud {
25namespace bigtable {
26GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
27
28/**
29 * Define the interfaces to create ReadWriteModifyRule operations.
30 *
31 * Cloud Bigtable has operations to perform atomic updates to a row, such as
32 * incrementing an integer value or appending to a string value. The changes are
33 * represented by a ReadModifyWriteRule operations. One or much such operations
34 * can be sent in a single request. This class helps users create the operations
35 * through a more idiomatic C++ interface.
36 */
38 public:
43
44 friend bool operator==(ReadModifyWriteRule const& a,
45 ReadModifyWriteRule const& b) noexcept {
46 return google::protobuf::util::MessageDifferencer::Equivalent(a.rule_,
47 b.rule_);
48 }
49 friend bool operator!=(ReadModifyWriteRule const& a,
50 ReadModifyWriteRule const& b) noexcept {
51 return !(a == b);
52 }
53
54 /// Create an operation that appends a string value.
55 static ReadModifyWriteRule AppendValue(std::string family_name,
56 std::string column_qualifier,
57 std::string value) {
59 tmp.rule_.set_family_name(std::move(family_name));
60 tmp.rule_.set_column_qualifier(std::move(column_qualifier));
61 tmp.rule_.set_append_value(std::move(value));
62 return tmp;
63 }
64
65 /// Create an operation that increments an integer value.
66 static ReadModifyWriteRule IncrementAmount(std::string family_name,
67 std::string column_qualifier,
68 std::int64_t amount) {
70 tmp.rule_.set_family_name(std::move(family_name));
71 tmp.rule_.set_column_qualifier(std::move(column_qualifier));
72 tmp.rule_.set_increment_amount(amount);
73 return tmp;
74 }
75
76 /// Return the filter expression as a protobuf.
77 google::bigtable::v2::ReadModifyWriteRule const& as_proto() const& {
78 return rule_;
79 }
80
81 /// Move out the underlying protobuf value.
82 google::bigtable::v2::ReadModifyWriteRule&& as_proto() && {
83 return std::move(rule_);
84 }
85
86 private:
87 /**
88 * Create an empty operation.
89 *
90 * Empty operations are not usable, so this constructor is private.
91 */
92 ReadModifyWriteRule() = default;
93
94 google::bigtable::v2::ReadModifyWriteRule rule_;
95};
96
97GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
98} // namespace bigtable
99} // namespace cloud
100} // namespace google
101
102#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_READ_MODIFY_WRITE_RULE_H
Define the interfaces to create ReadWriteModifyRule operations.
Definition: read_modify_write_rule.h:37
friend bool operator!=(ReadModifyWriteRule const &a, ReadModifyWriteRule const &b) noexcept
Definition: read_modify_write_rule.h:49
google::bigtable::v2::ReadModifyWriteRule const & as_proto() const &
Return the filter expression as a protobuf.
Definition: read_modify_write_rule.h:77
friend bool operator==(ReadModifyWriteRule const &a, ReadModifyWriteRule const &b) noexcept
Definition: read_modify_write_rule.h:44
ReadModifyWriteRule(ReadModifyWriteRule &&)=default
static ReadModifyWriteRule IncrementAmount(std::string family_name, std::string column_qualifier, std::int64_t amount)
Create an operation that increments an integer value.
Definition: read_modify_write_rule.h:66
ReadModifyWriteRule(ReadModifyWriteRule const &)=default
ReadModifyWriteRule & operator=(ReadModifyWriteRule &&)=default
ReadModifyWriteRule & operator=(ReadModifyWriteRule const &)=default
static ReadModifyWriteRule AppendValue(std::string family_name, std::string column_qualifier, std::string value)
Create an operation that appends a string value.
Definition: read_modify_write_rule.h:55
google::bigtable::v2::ReadModifyWriteRule && as_proto() &&
Move out the underlying protobuf value.
Definition: read_modify_write_rule.h:82
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28