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>
28namespace spanner_internal {
29GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
30class ReadPartitionTester;
31struct ReadPartitionInternals;
32GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
36GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
78 std::string
const& serialized_read_partition);
81
82
83
84
85
86
87
88
89
93
94
95
106 std::string
TableName()
const {
return proto_.table(); }
109 auto const& columns = proto_.columns();
110 return std::vector<std::string>(columns.begin(), columns.end());
119 return !(lhs
== rhs);
124 friend class spanner_internal::ReadPartitionTester;
125 friend struct spanner_internal::ReadPartitionInternals;
129 std::string
const& serialized_read_partition);
131 explicit ReadPartition(
google::spanner::v1::ReadRequest proto)
132 : proto_(std::move(proto)) {}
133 ReadPartition(std::string transaction_id,
bool route_to_leader,
134 std::string transaction_tag, std::string session_id,
135 std::string partition_token, std::string table_name,
137 std::vector<std::string> column_names,
bool data_boost,
141 std::string TransactionId()
const {
return proto_.transaction().id(); }
142 bool RouteToLeader()
const;
143 std::string TransactionTag()
const {
144 return proto_.request_options().transaction_tag();
146 std::string SessionId()
const {
return proto_.session(); }
147 std::string PartitionToken()
const {
return proto_.partition_token(); }
148 google::spanner::v1::KeySet KeySet()
const {
return proto_.key_set(); }
149 bool DataBoost()
const {
return proto_.data_boost_enabled(); }
151 google::spanner::v1::ReadRequest proto_;
154GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
158namespace spanner_internal {
159GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
161struct ReadPartitionInternals {
163 std::string transaction_id,
bool route_to_leader,
164 std::string transaction_tag, std::string session_id,
165 std::string partition_token, std::string table_name,
166 spanner::
KeySet key_set, std::vector<std::string> column_names,
169 std::move(transaction_id), route_to_leader, std::move(transaction_tag),
170 std::move(session_id), std::move(partition_token),
171 std::move(table_name), std::move(key_set), std::move(column_names),
172 data_boost, std::move(read_options));
178 MakeTransactionFromIds(
179 read_partition.SessionId(), read_partition.TransactionId(),
180 read_partition.RouteToLeader(), read_partition.TransactionTag()),
182 FromProto(read_partition.KeySet()),
184 read_partition.ReadOptions(),
185 read_partition.PartitionToken(),
186 read_partition.DataBoost()};
191 std::string transaction_id,
bool route_to_leader,
192 std::string transaction_tag, std::string session_id,
193 std::string partition_token, std::string table_name,
194 spanner::
KeySet key_set, std::vector<std::string> column_names,
196 return ReadPartitionInternals::MakeReadPartition(
197 std::move(transaction_id), route_to_leader, std::move(transaction_tag),
198 std::move(session_id), std::move(partition_token), std::move(table_name),
199 std::move(key_set), std::move(column_names), data_boost,
200 std::move(read_options));
205 return ReadPartitionInternals::MakeReadParams(read_partition);
208GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
A connection to a Spanner database instance.
Definition: connection.h:59
The KeySet class is a regular type that represents a collection of Keys.
Definition: keys.h:157
The ReadPartition class is a regular type that represents a single slice of a parallel Read operation...
Definition: read_partition.h:90
std::vector< std::string > ColumnNames() const
Definition: read_partition.h:108
ReadPartition(ReadPartition const &)=default
friend bool operator!=(ReadPartition const &lhs, ReadPartition const &rhs)
Definition: read_partition.h:118
ReadPartition(ReadPartition &&)=default
std::string TableName() const
Definition: read_partition.h:106
friend bool operator==(ReadPartition const &lhs, ReadPartition const &rhs)
ReadPartition & operator=(ReadPartition const &)=default
ReadPartition()=default
Constructs an instance of ReadPartition that does not specify any table or columns to be read.
ReadPartition & operator=(ReadPartition &&)=default
Contains all the Cloud Spanner C++ client types and functions.
Definition: backoff_policy.h:23
StatusOr< ReadPartition > DeserializeReadPartition(std::string const &serialized_read_partition)
Deserializes the provided string into a ReadPartition.
StatusOr< std::string > SerializeReadPartition(ReadPartition const &read_partition)
Serializes an instance of ReadPartition to a string of bytes.
Wrap the arguments to Read().
Definition: connection.h:74
Options passed to Client::Read or Client::PartitionRead.
Definition: read_options.h:32