15 #include "google/cloud/spanner/read_partition.h"
16 #include <google/spanner/v1/spanner.pb.h>
24 std::string transaction_tag,
25 std::string session_id,
26 std::string partition_token,
27 std::string table_name,
29 std::vector<std::string> column_names,
31 proto_.set_session(std::move(session_id));
32 proto_.mutable_transaction()->set_id(std::move(transaction_id));
33 proto_.set_table(std::move(table_name));
34 proto_.set_index(std::move(read_options
.index_name));
35 for (
auto& column : column_names) {
36 *proto_.mutable_columns()->Add() = std::move(column);
38 *proto_.mutable_key_set() = spanner_internal::ToProto(std::move(key_set));
39 proto_.set_limit(read_options
.limit);
40 proto_.set_partition_token(std::move(partition_token));
42 auto* request_options = proto_.mutable_request_options();
45 request_options->set_priority(
46 google::spanner::v1::RequestOptions::PRIORITY_LOW);
49 request_options->set_priority(
50 google::spanner::v1::RequestOptions::PRIORITY_MEDIUM);
53 request_options->set_priority(
54 google::spanner::v1::RequestOptions::PRIORITY_HIGH);
59 proto_.mutable_request_options()->set_request_tag(
62 proto_.mutable_request_options()->set_transaction_tag(
63 std::move(transaction_tag));
69 options
.limit = proto_.limit();
70 if (proto_.has_request_options()) {
71 switch (proto_.request_options().priority()) {
72 case google::spanner::v1::RequestOptions::PRIORITY_LOW:
75 case google::spanner::v1::RequestOptions::PRIORITY_MEDIUM:
78 case google::spanner::v1::RequestOptions::PRIORITY_HIGH:
84 if (!proto_.request_options().request_tag().empty()) {
85 options
.request_tag = proto_.request_options().request_tag();
92 google::protobuf::util::MessageDifferencer differencer;
93 return differencer.Compare(lhs.proto_, rhs.proto_);
102 std::string serialized_proto;
103 if (read_partition.proto_.SerializeToString(&serialized_proto)) {
104 return serialized_proto;
107 "Failed to serialize SqlPartition");
111 std::string
const& serialized_read_partition) {
112 google::spanner::v1::ReadRequest proto;
113 if (!proto.ParseFromString(serialized_read_partition)) {
115 "Failed to deserialize into SqlPartition");