Google Cloud BigQuery C++ Client 2.13.0
A C++ Client Library for Google Cloud BigQuery
Loading...
Searching...
No Matches
bigquery_read_client.h
1// Copyright 2021 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// Generated by the Codegen C++ plugin.
16// If you make any local changes, they will be lost.
17// source: google/cloud/bigquery/storage/v1/storage.proto
18
19#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_BIGQUERY_READ_CLIENT_H
20#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_BIGQUERY_READ_CLIENT_H
21
22#include "google/cloud/bigquery/storage/v1/bigquery_read_connection.h"
23#include "google/cloud/future.h"
24#include "google/cloud/options.h"
25#include "google/cloud/polling_policy.h"
26#include "google/cloud/status_or.h"
27#include "google/cloud/version.h"
28#include <memory>
29
30namespace google {
31namespace cloud {
32namespace bigquery_storage_v1 {
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
34
35///
36/// BigQuery Read API.
37///
38/// The Read API can be used to read data from BigQuery.
39///
40/// @par Equality
41///
42/// Instances of this class created via copy-construction or copy-assignment
43/// always compare equal. Instances created with equal
44/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare
45/// equal share the same underlying resources.
46///
47/// @par Performance
48///
49/// Creating a new instance of this class is a relatively expensive operation,
50/// new objects establish new connections to the service. In contrast,
51/// copy-construction, move-construction, and the corresponding assignment
52/// operations are relatively efficient as the copies share all underlying
53/// resources.
54///
55/// @par Thread Safety
56///
57/// Concurrent access to different instances of this class, even if they compare
58/// equal, is guaranteed to work. Two or more threads operating on the same
59/// instance of this class is not guaranteed to work. Since copy-construction
60/// and move-construction is a relatively efficient operation, consider using
61/// such a copy when using this class from multiple threads.
62///
64 public:
65 explicit BigQueryReadClient(
66 std::shared_ptr<BigQueryReadConnection> connection, Options opts = {});
68
69 ///@{
70 /// @name Copy and move support
71 BigQueryReadClient(BigQueryReadClient const&) = default;
75 ///@}
76
77 ///@{
78 /// @name Equality
79 friend bool operator==(BigQueryReadClient const& a,
80 BigQueryReadClient const& b) {
81 return a.connection_ == b.connection_;
82 }
83 friend bool operator!=(BigQueryReadClient const& a,
84 BigQueryReadClient const& b) {
85 return !(a == b);
86 }
87 ///@}
88
89 // clang-format off
90 ///
91 /// Creates a new read session. A read session divides the contents of a
92 /// BigQuery table into one or more streams, which can then be used to read
93 /// data from the table. The read session also specifies properties of the
94 /// data to be read, such as a list of columns or a push-down filter describing
95 /// the rows to be returned.
96 ///
97 /// A particular row can be read by at most one stream. When the caller has
98 /// reached the end of each stream in the session, then all the data in the
99 /// table has been read.
100 ///
101 /// Data is assigned to each stream such that roughly the same number of
102 /// rows can be read from each stream. Because the server-side unit for
103 /// assigning data is collections of rows, the API does not guarantee that
104 /// each stream will return the same number or rows. Additionally, the
105 /// limits are enforced based on the number of pre-filtered rows, so some
106 /// filters can lead to lopsided assignments.
107 ///
108 /// Read sessions automatically expire 6 hours after they are created and do
109 /// not require manual clean-up by the caller.
110 ///
111 /// @param parent Required. The request project that owns the session, in the form of
112 /// `projects/{project_id}`.
113 /// @param read_session Required. Session to be created.
114 /// @param max_stream_count Max initial number of streams. If unset or zero, the server will
115 /// provide a value of streams so as to produce reasonable throughput. Must be
116 /// non-negative. The number of streams may be lower than the requested number,
117 /// depending on the amount parallelism that is reasonable for the table.
118 /// There is a default system max limit of 1,000.
119 /// @n
120 /// This must be greater than or equal to preferred_min_stream_count.
121 /// Typically, clients should either leave this unset to let the system to
122 /// determine an upper bound OR set this a size for the maximum "units of work"
123 /// it can gracefully handle.
124 /// @param opts Optional. Override the class-level options, such as retry and
125 /// backoff policies.
126 /// @return the result of the RPC. The response message type
127 /// ([google.cloud.bigquery.storage.v1.ReadSession])
128 /// is mapped to a C++ class using the [Protobuf mapping rules].
129 /// If the request fails, the [`StatusOr`] contains the error details.
130 ///
131 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
132 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
133 /// [Long Running Operation]: https://google.aip.dev/151
134 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
135 /// [`future`]: @ref google::cloud::future
136 /// [`StatusOr`]: @ref google::cloud::StatusOr
137 /// [`Status`]: @ref google::cloud::Status
138 /// [google.cloud.bigquery.storage.v1.CreateReadSessionRequest]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L232}
139 /// [google.cloud.bigquery.storage.v1.ReadSession]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L48}
140 ///
141 // clang-format on
142 StatusOr<google::cloud::bigquery::storage::v1::ReadSession> CreateReadSession(
143 std::string const& parent,
144 google::cloud::bigquery::storage::v1::ReadSession const& read_session,
145 std::int32_t max_stream_count, Options opts = {});
146
147 // clang-format off
148 ///
149 /// Creates a new read session. A read session divides the contents of a
150 /// BigQuery table into one or more streams, which can then be used to read
151 /// data from the table. The read session also specifies properties of the
152 /// data to be read, such as a list of columns or a push-down filter describing
153 /// the rows to be returned.
154 ///
155 /// A particular row can be read by at most one stream. When the caller has
156 /// reached the end of each stream in the session, then all the data in the
157 /// table has been read.
158 ///
159 /// Data is assigned to each stream such that roughly the same number of
160 /// rows can be read from each stream. Because the server-side unit for
161 /// assigning data is collections of rows, the API does not guarantee that
162 /// each stream will return the same number or rows. Additionally, the
163 /// limits are enforced based on the number of pre-filtered rows, so some
164 /// filters can lead to lopsided assignments.
165 ///
166 /// Read sessions automatically expire 6 hours after they are created and do
167 /// not require manual clean-up by the caller.
168 ///
169 /// @param request Unary RPCs, such as the one wrapped by this
170 /// function, receive a single `request` proto message which includes all
171 /// the inputs for the RPC. In this case, the proto message is a
172 /// [google.cloud.bigquery.storage.v1.CreateReadSessionRequest].
173 /// Proto messages are converted to C++ classes by Protobuf, using the
174 /// [Protobuf mapping rules].
175 /// @param opts Optional. Override the class-level options, such as retry and
176 /// backoff policies.
177 /// @return the result of the RPC. The response message type
178 /// ([google.cloud.bigquery.storage.v1.ReadSession])
179 /// is mapped to a C++ class using the [Protobuf mapping rules].
180 /// If the request fails, the [`StatusOr`] contains the error details.
181 ///
182 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
183 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
184 /// [Long Running Operation]: https://google.aip.dev/151
185 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
186 /// [`future`]: @ref google::cloud::future
187 /// [`StatusOr`]: @ref google::cloud::StatusOr
188 /// [`Status`]: @ref google::cloud::Status
189 /// [google.cloud.bigquery.storage.v1.CreateReadSessionRequest]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L232}
190 /// [google.cloud.bigquery.storage.v1.ReadSession]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L48}
191 ///
192 // clang-format on
193 StatusOr<google::cloud::bigquery::storage::v1::ReadSession> CreateReadSession(
194 google::cloud::bigquery::storage::v1::CreateReadSessionRequest const&
195 request,
196 Options opts = {});
197
198 // clang-format off
199 ///
200 /// Reads rows from the stream in the format prescribed by the ReadSession.
201 /// Each response contains one or more table rows, up to a maximum of 100 MiB
202 /// per response; read requests which attempt to read individual rows larger
203 /// than 100 MiB will fail.
204 ///
205 /// Each request also returns a set of stream statistics reflecting the current
206 /// state of the stream.
207 ///
208 /// @param read_stream Required. Stream to read rows from.
209 /// @param offset The offset requested must be less than the last row read from Read.
210 /// Requesting a larger offset is undefined. If not specified, start reading
211 /// from offset zero.
212 /// @param opts Optional. Override the class-level options, such as retry and
213 /// backoff policies.
214 /// @return the result of the RPC. The response message type
215 /// ([google.cloud.bigquery.storage.v1.ReadRowsResponse])
216 /// is mapped to a C++ class using the [Protobuf mapping rules].
217 /// If the request fails, the [`StatusOr`] contains the error details.
218 ///
219 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
220 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
221 /// [Long Running Operation]: https://google.aip.dev/151
222 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
223 /// [`future`]: @ref google::cloud::future
224 /// [`StatusOr`]: @ref google::cloud::StatusOr
225 /// [`Status`]: @ref google::cloud::Status
226 /// [google.cloud.bigquery.storage.v1.ReadRowsRequest]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L269}
227 /// [google.cloud.bigquery.storage.v1.ReadRowsResponse]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L319}
228 ///
229 // clang-format on
230 StreamRange<google::cloud::bigquery::storage::v1::ReadRowsResponse> ReadRows(
231 std::string const& read_stream, std::int64_t offset, Options opts = {});
232
233 // clang-format off
234 ///
235 /// Reads rows from the stream in the format prescribed by the ReadSession.
236 /// Each response contains one or more table rows, up to a maximum of 100 MiB
237 /// per response; read requests which attempt to read individual rows larger
238 /// than 100 MiB will fail.
239 ///
240 /// Each request also returns a set of stream statistics reflecting the current
241 /// state of the stream.
242 ///
243 /// @param request Unary RPCs, such as the one wrapped by this
244 /// function, receive a single `request` proto message which includes all
245 /// the inputs for the RPC. In this case, the proto message is a
246 /// [google.cloud.bigquery.storage.v1.ReadRowsRequest].
247 /// Proto messages are converted to C++ classes by Protobuf, using the
248 /// [Protobuf mapping rules].
249 /// @param opts Optional. Override the class-level options, such as retry and
250 /// backoff policies.
251 /// @return the result of the RPC. The response message type
252 /// ([google.cloud.bigquery.storage.v1.ReadRowsResponse])
253 /// is mapped to a C++ class using the [Protobuf mapping rules].
254 /// If the request fails, the [`StatusOr`] contains the error details.
255 ///
256 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
257 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
258 /// [Long Running Operation]: https://google.aip.dev/151
259 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
260 /// [`future`]: @ref google::cloud::future
261 /// [`StatusOr`]: @ref google::cloud::StatusOr
262 /// [`Status`]: @ref google::cloud::Status
263 /// [google.cloud.bigquery.storage.v1.ReadRowsRequest]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L269}
264 /// [google.cloud.bigquery.storage.v1.ReadRowsResponse]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L319}
265 ///
266 // clang-format on
267 StreamRange<google::cloud::bigquery::storage::v1::ReadRowsResponse> ReadRows(
268 google::cloud::bigquery::storage::v1::ReadRowsRequest const& request,
269 Options opts = {});
270
271 // clang-format off
272 ///
273 /// Splits a given `ReadStream` into two `ReadStream` objects. These
274 /// `ReadStream` objects are referred to as the primary and the residual
275 /// streams of the split. The original `ReadStream` can still be read from in
276 /// the same manner as before. Both of the returned `ReadStream` objects can
277 /// also be read from, and the rows returned by both child streams will be
278 /// the same as the rows read from the original stream.
279 ///
280 /// Moreover, the two child streams will be allocated back-to-back in the
281 /// original `ReadStream`. Concretely, it is guaranteed that for streams
282 /// original, primary, and residual, that original[0-j] = primary[0-j] and
283 /// original[j-n] = residual[0-m] once the streams have been read to
284 /// completion.
285 ///
286 /// @param request Unary RPCs, such as the one wrapped by this
287 /// function, receive a single `request` proto message which includes all
288 /// the inputs for the RPC. In this case, the proto message is a
289 /// [google.cloud.bigquery.storage.v1.SplitReadStreamRequest].
290 /// Proto messages are converted to C++ classes by Protobuf, using the
291 /// [Protobuf mapping rules].
292 /// @param opts Optional. Override the class-level options, such as retry and
293 /// backoff policies.
294 /// @return the result of the RPC. The response message type
295 /// ([google.cloud.bigquery.storage.v1.SplitReadStreamResponse])
296 /// is mapped to a C++ class using the [Protobuf mapping rules].
297 /// If the request fails, the [`StatusOr`] contains the error details.
298 ///
299 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
300 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
301 /// [Long Running Operation]: https://google.aip.dev/151
302 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
303 /// [`future`]: @ref google::cloud::future
304 /// [`StatusOr`]: @ref google::cloud::StatusOr
305 /// [`Status`]: @ref google::cloud::Status
306 /// [google.cloud.bigquery.storage.v1.SplitReadStreamRequest]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L354}
307 /// [google.cloud.bigquery.storage.v1.SplitReadStreamResponse]: @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L374}
308 ///
309 // clang-format on
310 StatusOr<google::cloud::bigquery::storage::v1::SplitReadStreamResponse>
312 google::cloud::bigquery::storage::v1::SplitReadStreamRequest const&
313 request,
314 Options opts = {});
315
316 private:
317 std::shared_ptr<BigQueryReadConnection> connection_;
318 Options options_;
319};
320
321GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
322namespace gcpcxxV1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls)
323} // namespace bigquery_storage_v1
324} // namespace cloud
325} // namespace google
326
327#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_BIGQUERY_READ_CLIENT_H
BigQuery Read API.
Definition: bigquery_read_client.h:63
friend bool operator==(BigQueryReadClient const &a, BigQueryReadClient const &b)
Definition: bigquery_read_client.h:79
StatusOr< google::cloud::bigquery::storage::v1::SplitReadStreamResponse > SplitReadStream(google::cloud::bigquery::storage::v1::SplitReadStreamRequest const &request, Options opts={})
Splits a given ReadStream into two ReadStream objects.
StreamRange< google::cloud::bigquery::storage::v1::ReadRowsResponse > ReadRows(google::cloud::bigquery::storage::v1::ReadRowsRequest const &request, Options opts={})
Reads rows from the stream in the format prescribed by the ReadSession.
StatusOr< google::cloud::bigquery::storage::v1::ReadSession > CreateReadSession(std::string const &parent, google::cloud::bigquery::storage::v1::ReadSession const &read_session, std::int32_t max_stream_count, Options opts={})
Creates a new read session.
BigQueryReadClient & operator=(BigQueryReadClient const &)=default
BigQueryReadClient(std::shared_ptr< BigQueryReadConnection > connection, Options opts={})
BigQueryReadClient & operator=(BigQueryReadClient &&)=default
StreamRange< google::cloud::bigquery::storage::v1::ReadRowsResponse > ReadRows(std::string const &read_stream, std::int64_t offset, Options opts={})
Reads rows from the stream in the format prescribed by the ReadSession.
friend bool operator!=(BigQueryReadClient const &a, BigQueryReadClient const &b)
Definition: bigquery_read_client.h:83
StatusOr< google::cloud::bigquery::storage::v1::ReadSession > CreateReadSession(google::cloud::bigquery::storage::v1::CreateReadSessionRequest const &request, Options opts={})
Creates a new read session.
BigQueryReadClient(BigQueryReadClient const &)=default
The BigQueryReadConnection object for BigQueryReadClient.
Definition: bigquery_read_connection.h:61
Definition: bigquery_read_client.h:32
Definition: analytics_hub_client.h:30