forked from googleapis/google-cloud-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_connection_impl.h
More file actions
155 lines (125 loc) · 6.44 KB
/
Copy pathdata_connection_impl.h
File metadata and controls
155 lines (125 loc) · 6.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_DATA_CONNECTION_IMPL_H
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_DATA_CONNECTION_IMPL_H
#include "google/cloud/bigtable/data_connection.h"
#include "google/cloud/bigtable/instance_resource.h"
#include "google/cloud/bigtable/internal/bigtable_stub.h"
#include "google/cloud/bigtable/internal/mutate_rows_limiter.h"
#include "google/cloud/bigtable/internal/operation_context_factory.h"
#include "google/cloud/bigtable/internal/partial_result_set_reader.h"
#include "google/cloud/bigtable/internal/stub_manager.h"
#include "google/cloud/bigtable/prepared_query.h"
#include "google/cloud/bigtable/result_source_interface.h"
#include "google/cloud/background_threads.h"
#include "google/cloud/options.h"
#include "google/cloud/status_or.h"
#include "google/cloud/version.h"
#include <memory>
#include <vector>
namespace google {
namespace cloud {
namespace bigtable_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
// TODO(#16216): Remove this option in favor of addind a member variable to
// store the instances.
struct InstanceChannelAffinityOption {
using Type = std::vector<bigtable::InstanceResource>;
};
bigtable::Row TransformReadModifyWriteRowResponse(
google::bigtable::v2::ReadModifyWriteRowResponse response);
class DataConnectionImpl : public bigtable::DataConnection {
public:
~DataConnectionImpl() override = default;
DataConnectionImpl(std::unique_ptr<BackgroundThreads> background,
std::unique_ptr<StubManager> stub_manager,
std::shared_ptr<MutateRowsLimiter> limiter,
Options options);
// This constructor is used for testing.
DataConnectionImpl(
std::unique_ptr<BackgroundThreads> background,
std::unique_ptr<StubManager> stub_manager,
std::unique_ptr<OperationContextFactory> operation_context_factory,
std::shared_ptr<MutateRowsLimiter> limiter, Options options);
DataConnectionImpl(std::unique_ptr<BackgroundThreads> background,
std::shared_ptr<BigtableStub> stub,
std::shared_ptr<MutateRowsLimiter> limiter,
Options options);
// This constructor is used for testing.
DataConnectionImpl(
std::unique_ptr<BackgroundThreads> background,
std::shared_ptr<BigtableStub> stub,
std::unique_ptr<OperationContextFactory> operation_context_factory,
std::shared_ptr<MutateRowsLimiter> limiter, Options options);
Options options() override { return options_; }
Status Apply(std::string const& table_name,
bigtable::SingleRowMutation mut) override;
future<Status> AsyncApply(std::string const& table_name,
bigtable::SingleRowMutation mut) override;
std::vector<bigtable::FailedMutation> BulkApply(
std::string const& table_name, bigtable::BulkMutation mut) override;
future<std::vector<bigtable::FailedMutation>> AsyncBulkApply(
std::string const& table_name, bigtable::BulkMutation mut) override;
bigtable::RowReader ReadRowsFull(bigtable::ReadRowsParams params) override;
StatusOr<std::pair<bool, bigtable::Row>> ReadRow(
std::string const& table_name, std::string row_key,
bigtable::Filter filter) override;
StatusOr<bigtable::MutationBranch> CheckAndMutateRow(
std::string const& table_name, std::string row_key,
bigtable::Filter filter, std::vector<bigtable::Mutation> true_mutations,
std::vector<bigtable::Mutation> false_mutations) override;
future<StatusOr<bigtable::MutationBranch>> AsyncCheckAndMutateRow(
std::string const& table_name, std::string row_key,
bigtable::Filter filter, std::vector<bigtable::Mutation> true_mutations,
std::vector<bigtable::Mutation> false_mutations) override;
StatusOr<std::vector<bigtable::RowKeySample>> SampleRows(
std::string const& table_name) override;
future<StatusOr<std::vector<bigtable::RowKeySample>>> AsyncSampleRows(
std::string const& table_name) override;
StatusOr<bigtable::Row> ReadModifyWriteRow(
google::bigtable::v2::ReadModifyWriteRowRequest request) override;
future<StatusOr<bigtable::Row>> AsyncReadModifyWriteRow(
google::bigtable::v2::ReadModifyWriteRowRequest request) override;
void AsyncReadRows(std::string const& table_name,
std::function<future<bool>(bigtable::Row)> on_row,
std::function<void(Status)> on_finish,
bigtable::RowSet row_set, std::int64_t rows_limit,
bigtable::Filter filter) override;
future<StatusOr<std::pair<bool, bigtable::Row>>> AsyncReadRow(
std::string const& table_name, std::string row_key,
bigtable::Filter filter) override;
StatusOr<bigtable::PreparedQuery> PrepareQuery(
bigtable::PrepareQueryParams const& p) override;
future<StatusOr<bigtable::PreparedQuery>> AsyncPrepareQuery(
bigtable::PrepareQueryParams const& p) override;
bigtable::RowStream ExecuteQuery(bigtable::ExecuteQueryParams p) override;
private:
void AsyncReadRowsHelper(std::string const& table_name,
std::function<future<bool>(bigtable::Row)> on_row,
std::function<void(Status)> on_finish,
bigtable::RowSet row_set, std::int64_t rows_limit,
bigtable::Filter filter,
internal::ImmutableOptions const& current,
std::shared_ptr<OperationContext> operation_context);
std::unique_ptr<BackgroundThreads> background_;
std::unique_ptr<StubManager> stub_manager_;
std::unique_ptr<OperationContextFactory> operation_context_factory_;
std::shared_ptr<MutateRowsLimiter> limiter_;
Options options_;
};
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace bigtable_internal
} // namespace cloud
} // namespace google
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_DATA_CONNECTION_IMPL_H