Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
Loading...
Searching...
No Matches
read_options.h
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// https://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/cloud/options.h"
22#include "absl/types/optional.h"
23#include <cstdint>
24#include <string>
25
26namespace google {
27namespace cloud {
28namespace spanner {
29GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
30
31/// Options passed to `Client::Read` or `Client::PartitionRead`.
32struct ReadOptions {
33 /**
34 * If non-empty, the name of an index on a database table. This index is
35 * used instead of the table primary key when interpreting the `KeySet`
36 * and sorting result rows.
37 */
38 std::string index_name;
39
40 /**
41 * Limit on the number of rows to yield, or 0 for no limit.
42 * A limit cannot be specified when calling `PartitionRead`.
43 */
44 std::int64_t limit = 0;
45
46 /**
47 * Priority for the read request.
48 */
49 absl::optional<RequestPriority> request_priority;
50
51 /**
52 * Tag for the read request.
53 */
54 absl::optional<std::string> request_tag;
55};
56
57inline bool operator==(ReadOptions const& lhs, ReadOptions const& rhs) {
58 return lhs.limit == rhs.limit &&
61}
62
63inline bool operator!=(ReadOptions const& lhs, ReadOptions const& rhs) {
64 return !(lhs == rhs);
65}
66
67/// Converts `ReadOptions` to common `Options`.
69
70/// Converts common `Options` to `ReadOptions`.
72
73GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
74} // namespace spanner
75} // namespace cloud
76} // namespace google
77
78#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_READ_OPTIONS_H
Contains all the Cloud Spanner C++ client types and functions.
Definition: backoff_policy.h:23
bool operator!=(ReadOptions const &lhs, ReadOptions const &rhs)
Definition: read_options.h:63
RequestPriority
Definition: request_priority.h:26
ReadOptions ToReadOptions(Options const &)
Converts common Options to ReadOptions.
bool operator==(ReadOptions const &lhs, ReadOptions const &rhs)
Definition: read_options.h:57
Options ToOptions(ReadOptions const &)
Converts ReadOptions to common Options.
Options passed to Client::Read or Client::PartitionRead.
Definition: read_options.h:32
std::int64_t limit
Limit on the number of rows to yield, or 0 for no limit.
Definition: read_options.h:44
std::string index_name
If non-empty, the name of an index on a database table.
Definition: read_options.h:38
absl::optional< std::string > request_tag
Tag for the read request.
Definition: read_options.h:54
absl::optional< RequestPriority > request_priority
Priority for the read request.
Definition: read_options.h:49