Google Cloud BigQuery C++ Client 2.10.1
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 ///
90 /// Creates a new read session. A read session divides the contents of a
91 /// BigQuery table into one or more streams, which can then be used to read
92 /// data from the table. The read session also specifies properties of the
93 /// data to be read, such as a list of columns or a push-down filter
94 /// describing the rows to be returned.
95 ///
96 /// A particular row can be read by at most one stream. When the caller has
97 /// reached the end of each stream in the session, then all the data in the
98 /// table has been read.
99 ///
100 /// Data is assigned to each stream such that roughly the same number of
101 /// rows can be read from each stream. Because the server-side unit for
102 /// assigning data is collections of rows, the API does not guarantee that
103 /// each stream will return the same number or rows. Additionally, the
104 /// limits are enforced based on the number of pre-filtered rows, so some
105 /// filters can lead to lopsided assignments.
106 ///
107 /// Read sessions automatically expire 6 hours after they are created and do
108 /// not require manual clean-up by the caller.
109 ///
110 /// @param parent Required. The request project that owns the session, in the
111 /// 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,
115 /// the server will
116 /// provide a value of streams so as to produce reasonable throughput. Must
117 /// be non-negative. The number of streams may be lower than the requested
118 /// number, depending on the amount parallelism that is reasonable for the
119 /// table. There is a default system max limit of 1,000. This must be greater
120 /// than or equal to preferred_min_stream_count. Typically, clients should
121 /// either leave this unset to let the system to determine an upper bound OR
122 /// set this a size for the maximum "units of work" it can gracefully handle.
123 /// @param opts Optional. Override the class-level options, such as retry and
124 /// backoff policies.
125 /// @return
126 /// @googleapis_link{google::cloud::bigquery::storage::v1::ReadSession,google/cloud/bigquery/storage/v1/stream.proto#L48}
127 ///
128 /// [google.cloud.bigquery.storage.v1.CreateReadSessionRequest]:
129 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L232}
130 /// [google.cloud.bigquery.storage.v1.ReadSession]:
131 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L48}
132 ///
133 StatusOr<google::cloud::bigquery::storage::v1::ReadSession> CreateReadSession(
134 std::string const& parent,
135 google::cloud::bigquery::storage::v1::ReadSession const& read_session,
136 std::int32_t max_stream_count, Options opts = {});
137
138 ///
139 /// Creates a new read session. A read session divides the contents of a
140 /// BigQuery table into one or more streams, which can then be used to read
141 /// data from the table. The read session also specifies properties of the
142 /// data to be read, such as a list of columns or a push-down filter
143 /// describing the rows to be returned.
144 ///
145 /// A particular row can be read by at most one stream. When the caller has
146 /// reached the end of each stream in the session, then all the data in the
147 /// table has been read.
148 ///
149 /// Data is assigned to each stream such that roughly the same number of
150 /// rows can be read from each stream. Because the server-side unit for
151 /// assigning data is collections of rows, the API does not guarantee that
152 /// each stream will return the same number or rows. Additionally, the
153 /// limits are enforced based on the number of pre-filtered rows, so some
154 /// filters can lead to lopsided assignments.
155 ///
156 /// Read sessions automatically expire 6 hours after they are created and do
157 /// not require manual clean-up by the caller.
158 ///
159 /// @param request
160 /// @googleapis_link{google::cloud::bigquery::storage::v1::CreateReadSessionRequest,google/cloud/bigquery/storage/v1/storage.proto#L232}
161 /// @param opts Optional. Override the class-level options, such as retry and
162 /// backoff policies.
163 /// @return
164 /// @googleapis_link{google::cloud::bigquery::storage::v1::ReadSession,google/cloud/bigquery/storage/v1/stream.proto#L48}
165 ///
166 /// [google.cloud.bigquery.storage.v1.CreateReadSessionRequest]:
167 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L232}
168 /// [google.cloud.bigquery.storage.v1.ReadSession]:
169 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L48}
170 ///
171 StatusOr<google::cloud::bigquery::storage::v1::ReadSession> CreateReadSession(
172 google::cloud::bigquery::storage::v1::CreateReadSessionRequest const&
173 request,
174 Options opts = {});
175
176 ///
177 /// Reads rows from the stream in the format prescribed by the ReadSession.
178 /// Each response contains one or more table rows, up to a maximum of 100 MiB
179 /// per response; read requests which attempt to read individual rows larger
180 /// than 100 MiB will fail.
181 ///
182 /// Each request also returns a set of stream statistics reflecting the
183 /// current state of the stream.
184 ///
185 /// @param read_stream Required. Stream to read rows from.
186 /// @param offset The offset requested must be less than the last row read
187 /// from Read.
188 /// Requesting a larger offset is undefined. If not specified, start reading
189 /// from offset zero.
190 /// @param opts Optional. Override the class-level options, such as retry and
191 /// backoff policies.
192 /// @return
193 /// @googleapis_link{google::cloud::bigquery::storage::v1::ReadRowsResponse,google/cloud/bigquery/storage/v1/storage.proto#L319}
194 ///
195 /// [google.cloud.bigquery.storage.v1.ReadRowsRequest]:
196 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L269}
197 /// [google.cloud.bigquery.storage.v1.ReadRowsResponse]:
198 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L319}
199 ///
200 StreamRange<google::cloud::bigquery::storage::v1::ReadRowsResponse> ReadRows(
201 std::string const& read_stream, std::int64_t offset, Options opts = {});
202
203 ///
204 /// Reads rows from the stream in the format prescribed by the ReadSession.
205 /// Each response contains one or more table rows, up to a maximum of 100 MiB
206 /// per response; read requests which attempt to read individual rows larger
207 /// than 100 MiB will fail.
208 ///
209 /// Each request also returns a set of stream statistics reflecting the
210 /// current state of the stream.
211 ///
212 /// @param request
213 /// @googleapis_link{google::cloud::bigquery::storage::v1::ReadRowsRequest,google/cloud/bigquery/storage/v1/storage.proto#L269}
214 /// @param opts Optional. Override the class-level options, such as retry and
215 /// backoff policies.
216 /// @return
217 /// @googleapis_link{google::cloud::bigquery::storage::v1::ReadRowsResponse,google/cloud/bigquery/storage/v1/storage.proto#L319}
218 ///
219 /// [google.cloud.bigquery.storage.v1.ReadRowsRequest]:
220 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L269}
221 /// [google.cloud.bigquery.storage.v1.ReadRowsResponse]:
222 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L319}
223 ///
224 StreamRange<google::cloud::bigquery::storage::v1::ReadRowsResponse> ReadRows(
225 google::cloud::bigquery::storage::v1::ReadRowsRequest const& request,
226 Options opts = {});
227
228 ///
229 /// Splits a given `ReadStream` into two `ReadStream` objects. These
230 /// `ReadStream` objects are referred to as the primary and the residual
231 /// streams of the split. The original `ReadStream` can still be read from in
232 /// the same manner as before. Both of the returned `ReadStream` objects can
233 /// also be read from, and the rows returned by both child streams will be
234 /// the same as the rows read from the original stream.
235 ///
236 /// Moreover, the two child streams will be allocated back-to-back in the
237 /// original `ReadStream`. Concretely, it is guaranteed that for streams
238 /// original, primary, and residual, that original[0-j] = primary[0-j] and
239 /// original[j-n] = residual[0-m] once the streams have been read to
240 /// completion.
241 ///
242 /// @param request
243 /// @googleapis_link{google::cloud::bigquery::storage::v1::SplitReadStreamRequest,google/cloud/bigquery/storage/v1/storage.proto#L354}
244 /// @param opts Optional. Override the class-level options, such as retry and
245 /// backoff policies.
246 /// @return
247 /// @googleapis_link{google::cloud::bigquery::storage::v1::SplitReadStreamResponse,google/cloud/bigquery/storage/v1/storage.proto#L374}
248 ///
249 /// [google.cloud.bigquery.storage.v1.SplitReadStreamRequest]:
250 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L354}
251 /// [google.cloud.bigquery.storage.v1.SplitReadStreamResponse]:
252 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L374}
253 ///
254 StatusOr<google::cloud::bigquery::storage::v1::SplitReadStreamResponse>
256 google::cloud::bigquery::storage::v1::SplitReadStreamRequest const&
257 request,
258 Options opts = {});
259
260 private:
261 std::shared_ptr<BigQueryReadConnection> connection_;
262 Options options_;
263};
264
265GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
266namespace gcpcxxV1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls)
267} // namespace bigquery_storage_v1
268} // namespace cloud
269} // namespace google
270
271#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