Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
read_options.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_READ_OPTIONS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_READ_OPTIONS_H
17 
18 #include "google/cloud/spanner/request_priority.h"
19 #include "google/cloud/spanner/version.h"
20 #include "google/cloud/optional.h"
21 #include <google/spanner/v1/spanner.pb.h>
22 #include <string>
23 
24 namespace google {
25 namespace cloud {
26 namespace spanner {
27 inline namespace SPANNER_CLIENT_NS {
28 
29 /// Options passed to `Client::Read` or `Client::PartitionRead`.
30 struct ReadOptions {
31  /**
32  * If non-empty, the name of an index on a database table. This index is used
33  * instead of the table primary key when interpreting the `KeySet`and sorting
34  * result rows.
35  */
36  std::string index_name;
37 
38  /**
39  * Limit on the number of rows to yield, or 0 for no limit.
40  * A limit cannot be specified when calling `PartitionRead`.
41  */
42  std::int64_t limit = 0;
43 
44  /**
45  * Priority for the read request.
46  */
48 
49  /**
50  * Tag for the read request.
51  */
52  absl::optional<std::string> request_tag;
53 };
54 
55 inline bool operator==(ReadOptions const& lhs, ReadOptions const& rhs) {
56  return lhs.limit == rhs.limit &&
58  lhs.request_tag == rhs.request_tag && lhs.index_name == rhs.index_name;
59 }
60 
61 inline bool operator!=(ReadOptions const& lhs, ReadOptions const& rhs) {
62  return !(lhs == rhs);
63 }
64 
65 } // namespace SPANNER_CLIENT_NS
66 } // namespace spanner
67 } // namespace cloud
68 } // namespace google
69 
70 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_READ_OPTIONS_H