Google Cloud Spanner C++ Client
A C++ Client Library for Google Cloud Spanner
connection.h
Go to the documentation of this file.
1 // Copyright 2019 Google LLC
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 // http://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_SPANNER_CONNECTION_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CONNECTION_H
17 
31 #include "google/cloud/optional.h"
32 #include "google/cloud/status_or.h"
33 #include <string>
34 #include <vector>
35 
36 namespace google {
37 namespace cloud {
38 namespace spanner {
39 inline namespace SPANNER_CLIENT_NS {
40 
41 class ReadPartition;
42 class QueryPartition;
43 
57 class Connection {
58  public:
59  virtual ~Connection() = default;
60 
62 
71  struct ReadParams {
74  std::string table;
76  std::vector<std::string> columns;
78  google::cloud::optional<std::string> partition_token;
79  };
80 
85  };
86 
89  struct SqlParams {
93  google::cloud::optional<std::string> partition_token;
94  };
95 
99  };
100 
106  };
107 
111  std::vector<SqlStatement> statements;
112  };
113 
115  struct CommitParams {
118  };
119 
121  struct RollbackParams {
123  };
125 
127  virtual RowStream Read(ReadParams) = 0;
128 
130  virtual StatusOr<std::vector<ReadPartition>> PartitionRead(
131  PartitionReadParams) = 0;
132 
134  virtual RowStream ExecuteQuery(SqlParams) = 0;
135 
137  virtual StatusOr<DmlResult> ExecuteDml(SqlParams) = 0;
138 
140  virtual ProfileQueryResult ProfileQuery(SqlParams) = 0;
141 
143  virtual StatusOr<ProfileDmlResult> ProfileDml(SqlParams) = 0;
144 
146  virtual StatusOr<ExecutionPlan> AnalyzeSql(SqlParams) = 0;
147 
149  virtual StatusOr<PartitionedDmlResult> ExecutePartitionedDml(
151 
153  virtual StatusOr<std::vector<QueryPartition>> PartitionQuery(
155 
157  virtual StatusOr<BatchDmlResult> ExecuteBatchDml(ExecuteBatchDmlParams) = 0;
158 
160  virtual StatusOr<CommitResult> Commit(CommitParams) = 0;
161 
163  virtual Status Rollback(RollbackParams) = 0;
164 };
165 
166 } // namespace SPANNER_CLIENT_NS
167 } // namespace spanner
168 } // namespace cloud
169 } // namespace google
170 
171 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CONNECTION_H
Wrap the arguments to PartitionQuery().
Definition: connection.h:102
Wrap the arguments to ExecuteQuery(), ExecuteDml(), ProfileQuery(), ProfileDml(), and AnalyzeSql().
Definition: connection.h:89
Represents the stream of Rows and profile stats returned from spanner::Client::ProfileQuery().
Definition: results.h:150
Wrap the arguments to ExecutePartitionedDml().
Definition: connection.h:97
std::vector< Mutation > Mutations
An ordered sequence of mutations to pass to Client::Commit() or return from the Client::Commit() muta...
Definition: mutations.h:95
google::cloud::optional< std::string > partition_token
Definition: connection.h:78
The KeySet class is a regular type that represents a collection of Keys.
Definition: keys.h:158
Wrap the arguments to PartitionRead().
Definition: connection.h:82
google::cloud::optional< std::string > partition_token
Definition: connection.h:93
Contains all the Cloud Spanner C++ client types and functions.
These QueryOptions allow users to configure features about how their SQL queries executes on the serv...
Definition: query_options.h:31
#define SPANNER_CLIENT_NS
Definition: version.h:22
Wrap the arguments to ExecuteBatchDml().
Definition: connection.h:109
The representation of a Cloud Spanner transaction.
Definition: transaction.h:63
Represents the stream of Rows returned from spanner::Client::Read() or spanner::Client::ExecuteQuery(...
Definition: results.h:68
A connection to a Spanner database instance.
Definition: connection.h:57
Options passed to Client::PartitionRead or Client::PartitionQuery.
Options passed to Client::Read or Client::PartitionRead.
Definition: read_options.h:28
Represents a potentially parameterized SQL statement.
Definition: sql_statement.h:55