15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_READ_PARTITION_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_READ_PARTITION_H
18 #include "google/cloud/spanner/connection.h"
19 #include "google/cloud/spanner/keys.h"
20 #include "google/cloud/spanner/version.h"
21 #include "google/cloud/status_or.h"
22 #include <google/spanner/v1/spanner.pb.h>
28 namespace spanner_internal {
30 struct ReadPartitionInternals;
77 std::string
const& serialized_read_partition);
103 std::string
TableName()
const {
return proto_.table(); }
106 auto const& columns = proto_.columns();
107 return std::vector<std::string>(columns.begin(), columns.end());
119 friend class ReadPartitionTester;
124 std::string
const& serialized_read_partition);
126 explicit ReadPartition(
google::spanner::v1::ReadRequest proto)
127 : proto_(std::move(proto)) {}
128 ReadPartition(std::string transaction_id, std::string transaction_tag,
129 std::string session_id, std::string partition_token,
131 std::vector<std::string> column_names,
135 std::string PartitionToken()
const {
return proto_.partition_token(); }
136 std::string SessionId()
const {
return proto_.session(); }
137 std::string TransactionId()
const {
return proto_.transaction().id(); }
138 std::string TransactionTag()
const {
139 return proto_.request_options().transaction_tag();
141 google::spanner::v1::KeySet KeySet()
const {
return proto_.key_set(); }
143 google::spanner::v1::ReadRequest proto_;
150 namespace spanner_internal {
153 struct ReadPartitionInternals {
155 std::string transaction_id, std::string transaction_tag,
156 std::string session_id, std::string partition_token,
158 std::vector<std::string> column_names,
161 std::move(transaction_id), std::move(transaction_tag),
162 std::move(session_id), std::move(partition_token),
163 std::move(table_name), std::move(key_set), std::move(column_names),
164 std::move(read_options));
170 MakeTransactionFromIds(read_partition.SessionId(),
171 read_partition.TransactionId(),
172 read_partition.TransactionTag()),
174 FromProto(read_partition.KeySet()),
176 read_partition.ReadOptions(),
177 read_partition.PartitionToken()};
182 std::string transaction_id, std::string transaction_tag,
183 std::string session_id, std::string partition_token, std::string table_name,
184 spanner::
KeySet key_set, std::vector<std::string> column_names,
186 return ReadPartitionInternals::MakeReadPartition(
187 std::move(transaction_id), std::move(transaction_tag),
188 std::move(session_id), std::move(partition_token), std::move(table_name),
189 std::move(key_set), std::move(column_names), std::move(read_options));
194 return ReadPartitionInternals::MakeReadParams(read_partition);