Google Cloud BigQuery C++ Client 2.10.1
A C++ Client Library for Google Cloud BigQuery
Loading...
Searching...
No Matches
bigquery_write_client.h
1// Copyright 2022 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_WRITE_CLIENT_H
20#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_BIGQUERY_WRITE_CLIENT_H
21
22#include "google/cloud/bigquery/storage/v1/bigquery_write_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 <map>
29#include <memory>
30
31namespace google {
32namespace cloud {
33namespace bigquery_storage_v1 {
34GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
35
36///
37/// BigQuery Write API.
38///
39/// The Write API can be used to write data to BigQuery.
40///
41/// For supplementary information about the Write API, see:
42/// https://cloud.google.com/bigquery/docs/write-api
43///
44/// @par Equality
45///
46/// Instances of this class created via copy-construction or copy-assignment
47/// always compare equal. Instances created with equal
48/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare
49/// equal share the same underlying resources.
50///
51/// @par Performance
52///
53/// Creating a new instance of this class is a relatively expensive operation,
54/// new objects establish new connections to the service. In contrast,
55/// copy-construction, move-construction, and the corresponding assignment
56/// operations are relatively efficient as the copies share all underlying
57/// resources.
58///
59/// @par Thread Safety
60///
61/// Concurrent access to different instances of this class, even if they compare
62/// equal, is guaranteed to work. Two or more threads operating on the same
63/// instance of this class is not guaranteed to work. Since copy-construction
64/// and move-construction is a relatively efficient operation, consider using
65/// such a copy when using this class from multiple threads.
66///
68 public:
69 explicit BigQueryWriteClient(
70 std::shared_ptr<BigQueryWriteConnection> connection, Options opts = {});
72
73 ///@{
74 /// @name Copy and move support
79 ///@}
80
81 ///@{
82 /// @name Equality
83 friend bool operator==(BigQueryWriteClient const& a,
84 BigQueryWriteClient const& b) {
85 return a.connection_ == b.connection_;
86 }
87 friend bool operator!=(BigQueryWriteClient const& a,
88 BigQueryWriteClient const& b) {
89 return !(a == b);
90 }
91 ///@}
92
93 ///
94 /// Creates a write stream to the given table.
95 /// Additionally, every table has a special stream named '_default'
96 /// to which data can be written. This stream doesn't need to be created using
97 /// CreateWriteStream. It is a stream that can be used simultaneously by any
98 /// number of clients. Data written to this stream is considered committed as
99 /// soon as an acknowledgement is received.
100 ///
101 /// @param parent Required. Reference to the table to which the stream
102 /// belongs, in the format
103 /// of `projects/{project}/datasets/{dataset}/tables/{table}`.
104 /// @param write_stream Required. Stream to be created.
105 /// @param opts Optional. Override the class-level options, such as retry and
106 /// backoff policies.
107 /// @return
108 /// @googleapis_link{google::cloud::bigquery::storage::v1::WriteStream,google/cloud/bigquery/storage/v1/stream.proto#L234}
109 ///
110 /// [google.cloud.bigquery.storage.v1.CreateWriteStreamRequest]:
111 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L386}
112 /// [google.cloud.bigquery.storage.v1.WriteStream]:
113 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L234}
114 ///
115 StatusOr<google::cloud::bigquery::storage::v1::WriteStream> CreateWriteStream(
116 std::string const& parent,
117 google::cloud::bigquery::storage::v1::WriteStream const& write_stream,
118 Options opts = {});
119
120 ///
121 /// Creates a write stream to the given table.
122 /// Additionally, every table has a special stream named '_default'
123 /// to which data can be written. This stream doesn't need to be created using
124 /// CreateWriteStream. It is a stream that can be used simultaneously by any
125 /// number of clients. Data written to this stream is considered committed as
126 /// soon as an acknowledgement is received.
127 ///
128 /// @param request
129 /// @googleapis_link{google::cloud::bigquery::storage::v1::CreateWriteStreamRequest,google/cloud/bigquery/storage/v1/storage.proto#L386}
130 /// @param opts Optional. Override the class-level options, such as retry and
131 /// backoff policies.
132 /// @return
133 /// @googleapis_link{google::cloud::bigquery::storage::v1::WriteStream,google/cloud/bigquery/storage/v1/stream.proto#L234}
134 ///
135 /// [google.cloud.bigquery.storage.v1.CreateWriteStreamRequest]:
136 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L386}
137 /// [google.cloud.bigquery.storage.v1.WriteStream]:
138 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L234}
139 ///
140 StatusOr<google::cloud::bigquery::storage::v1::WriteStream> CreateWriteStream(
141 google::cloud::bigquery::storage::v1::CreateWriteStreamRequest const&
142 request,
143 Options opts = {});
144
145 ///
146 /// Appends data to the given stream.
147 ///
148 /// If `offset` is specified, the `offset` is checked against the end of
149 /// stream. The server returns `OUT_OF_RANGE` in `AppendRowsResponse` if an
150 /// attempt is made to append to an offset beyond the current end of the
151 /// stream or `ALREADY_EXISTS` if user provides an `offset` that has already
152 /// been written to. User can retry with adjusted offset within the same RPC
153 /// connection. If `offset` is not specified, append happens at the end of the
154 /// stream.
155 ///
156 /// The response contains an optional offset at which the append
157 /// happened. No offset information will be returned for appends to a
158 /// default stream.
159 ///
160 /// Responses are received in the same order in which requests are sent.
161 /// There will be one response for each successful inserted request. Responses
162 /// may optionally embed error information if the originating AppendRequest
163 /// was not successfully processed.
164 ///
165 /// The specifics of when successfully appended data is made visible to the
166 /// table are governed by the type of stream:
167 ///
168 /// * For COMMITTED streams (which includes the default stream), data is
169 /// visible immediately upon successful append.
170 ///
171 /// * For BUFFERED streams, data is made visible via a subsequent `FlushRows`
172 /// rpc which advances a cursor to a newer offset in the stream.
173 ///
174 /// * For PENDING streams, data is not made visible until the stream itself is
175 /// finalized (via the `FinalizeWriteStream` rpc), and the stream is
176 /// explicitly committed via the `BatchCommitWriteStreams` rpc.
177 ///
178 /// @param opts Optional. Override the class-level options, such as retry and
179 /// backoff policies.
180 /// @return A bidirectional streaming interface with request (write) type:
181 /// @googleapis_link{google::cloud::bigquery::storage::v1::AppendRowsRequest,google/cloud/bigquery/storage/v1/storage.proto#L406}
182 /// and response (read) type:
183 /// @googleapis_link{google::cloud::bigquery::storage::v1::AppendRowsResponse,google/cloud/bigquery/storage/v1/storage.proto#L499}
184 ///
185 /// [google.cloud.bigquery.storage.v1.AppendRowsRequest]:
186 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L406}
187 /// [google.cloud.bigquery.storage.v1.AppendRowsResponse]:
188 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L499}
189 ///
190 std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
191 google::cloud::bigquery::storage::v1::AppendRowsRequest,
192 google::cloud::bigquery::storage::v1::AppendRowsResponse>>
194
195 ///
196 /// Gets information about a write stream.
197 ///
198 /// @param name Required. Name of the stream to get, in the form of
199 /// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
200 /// @param opts Optional. Override the class-level options, such as retry and
201 /// backoff policies.
202 /// @return
203 /// @googleapis_link{google::cloud::bigquery::storage::v1::WriteStream,google/cloud/bigquery/storage/v1/stream.proto#L234}
204 ///
205 /// [google.cloud.bigquery.storage.v1.GetWriteStreamRequest]:
206 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L550}
207 /// [google.cloud.bigquery.storage.v1.WriteStream]:
208 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L234}
209 ///
210 StatusOr<google::cloud::bigquery::storage::v1::WriteStream> GetWriteStream(
211 std::string const& name, Options opts = {});
212
213 ///
214 /// Gets information about a write stream.
215 ///
216 /// @param request
217 /// @googleapis_link{google::cloud::bigquery::storage::v1::GetWriteStreamRequest,google/cloud/bigquery/storage/v1/storage.proto#L550}
218 /// @param opts Optional. Override the class-level options, such as retry and
219 /// backoff policies.
220 /// @return
221 /// @googleapis_link{google::cloud::bigquery::storage::v1::WriteStream,google/cloud/bigquery/storage/v1/stream.proto#L234}
222 ///
223 /// [google.cloud.bigquery.storage.v1.GetWriteStreamRequest]:
224 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L550}
225 /// [google.cloud.bigquery.storage.v1.WriteStream]:
226 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/stream.proto#L234}
227 ///
228 StatusOr<google::cloud::bigquery::storage::v1::WriteStream> GetWriteStream(
229 google::cloud::bigquery::storage::v1::GetWriteStreamRequest const&
230 request,
231 Options opts = {});
232
233 ///
234 /// Finalize a write stream so that no new data can be appended to the
235 /// stream. Finalize is not supported on the '_default' stream.
236 ///
237 /// @param name Required. Name of the stream to finalize, in the form of
238 /// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
239 /// @param opts Optional. Override the class-level options, such as retry and
240 /// backoff policies.
241 /// @return
242 /// @googleapis_link{google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse,google/cloud/bigquery/storage/v1/storage.proto#L606}
243 ///
244 /// [google.cloud.bigquery.storage.v1.FinalizeWriteStreamRequest]:
245 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L594}
246 /// [google.cloud.bigquery.storage.v1.FinalizeWriteStreamResponse]:
247 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L606}
248 ///
249 StatusOr<google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse>
250 FinalizeWriteStream(std::string const& name, Options opts = {});
251
252 ///
253 /// Finalize a write stream so that no new data can be appended to the
254 /// stream. Finalize is not supported on the '_default' stream.
255 ///
256 /// @param request
257 /// @googleapis_link{google::cloud::bigquery::storage::v1::FinalizeWriteStreamRequest,google/cloud/bigquery/storage/v1/storage.proto#L594}
258 /// @param opts Optional. Override the class-level options, such as retry and
259 /// backoff policies.
260 /// @return
261 /// @googleapis_link{google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse,google/cloud/bigquery/storage/v1/storage.proto#L606}
262 ///
263 /// [google.cloud.bigquery.storage.v1.FinalizeWriteStreamRequest]:
264 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L594}
265 /// [google.cloud.bigquery.storage.v1.FinalizeWriteStreamResponse]:
266 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L606}
267 ///
268 StatusOr<google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse>
270 google::cloud::bigquery::storage::v1::FinalizeWriteStreamRequest const&
271 request,
272 Options opts = {});
273
274 ///
275 /// Atomically commits a group of `PENDING` streams that belong to the same
276 /// `parent` table.
277 ///
278 /// Streams must be finalized before commit and cannot be committed multiple
279 /// times. Once a stream is committed, data in the stream becomes available
280 /// for read operations.
281 ///
282 /// @param parent Required. Parent table that all the streams should belong
283 /// to, in the form
284 /// of `projects/{project}/datasets/{dataset}/tables/{table}`.
285 /// @param opts Optional. Override the class-level options, such as retry and
286 /// backoff policies.
287 /// @return
288 /// @googleapis_link{google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse,google/cloud/bigquery/storage/v1/storage.proto#L579}
289 ///
290 /// [google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsRequest]:
291 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L566}
292 /// [google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsResponse]:
293 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L579}
294 ///
295 StatusOr<
296 google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse>
297 BatchCommitWriteStreams(std::string const& parent, Options opts = {});
298
299 ///
300 /// Atomically commits a group of `PENDING` streams that belong to the same
301 /// `parent` table.
302 ///
303 /// Streams must be finalized before commit and cannot be committed multiple
304 /// times. Once a stream is committed, data in the stream becomes available
305 /// for read operations.
306 ///
307 /// @param request
308 /// @googleapis_link{google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsRequest,google/cloud/bigquery/storage/v1/storage.proto#L566}
309 /// @param opts Optional. Override the class-level options, such as retry and
310 /// backoff policies.
311 /// @return
312 /// @googleapis_link{google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse,google/cloud/bigquery/storage/v1/storage.proto#L579}
313 ///
314 /// [google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsRequest]:
315 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L566}
316 /// [google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsResponse]:
317 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L579}
318 ///
319 StatusOr<
320 google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse>
322 BatchCommitWriteStreamsRequest const& request,
323 Options opts = {});
324
325 ///
326 /// Flushes rows to a BUFFERED stream.
327 ///
328 /// If users are appending rows to BUFFERED stream, flush operation is
329 /// required in order for the rows to become available for reading. A
330 /// Flush operation flushes up to any previously flushed offset in a BUFFERED
331 /// stream, to the offset specified in the request.
332 ///
333 /// Flush is not supported on the _default stream, since it is not BUFFERED.
334 ///
335 /// @param write_stream Required. The stream that is the target of the flush
336 /// operation.
337 /// @param opts Optional. Override the class-level options, such as retry and
338 /// backoff policies.
339 /// @return
340 /// @googleapis_link{google::cloud::bigquery::storage::v1::FlushRowsResponse,google/cloud/bigquery/storage/v1/storage.proto#L627}
341 ///
342 /// [google.cloud.bigquery.storage.v1.FlushRowsRequest]:
343 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L612}
344 /// [google.cloud.bigquery.storage.v1.FlushRowsResponse]:
345 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L627}
346 ///
347 StatusOr<google::cloud::bigquery::storage::v1::FlushRowsResponse> FlushRows(
348 std::string const& write_stream, Options opts = {});
349
350 ///
351 /// Flushes rows to a BUFFERED stream.
352 ///
353 /// If users are appending rows to BUFFERED stream, flush operation is
354 /// required in order for the rows to become available for reading. A
355 /// Flush operation flushes up to any previously flushed offset in a BUFFERED
356 /// stream, to the offset specified in the request.
357 ///
358 /// Flush is not supported on the _default stream, since it is not BUFFERED.
359 ///
360 /// @param request
361 /// @googleapis_link{google::cloud::bigquery::storage::v1::FlushRowsRequest,google/cloud/bigquery/storage/v1/storage.proto#L612}
362 /// @param opts Optional. Override the class-level options, such as retry and
363 /// backoff policies.
364 /// @return
365 /// @googleapis_link{google::cloud::bigquery::storage::v1::FlushRowsResponse,google/cloud/bigquery/storage/v1/storage.proto#L627}
366 ///
367 /// [google.cloud.bigquery.storage.v1.FlushRowsRequest]:
368 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L612}
369 /// [google.cloud.bigquery.storage.v1.FlushRowsResponse]:
370 /// @googleapis_reference_link{google/cloud/bigquery/storage/v1/storage.proto#L627}
371 ///
372 StatusOr<google::cloud::bigquery::storage::v1::FlushRowsResponse> FlushRows(
373 google::cloud::bigquery::storage::v1::FlushRowsRequest const& request,
374 Options opts = {});
375
376 private:
377 std::shared_ptr<BigQueryWriteConnection> connection_;
378 Options options_;
379};
380
381GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
382} // namespace bigquery_storage_v1
383} // namespace cloud
384} // namespace google
385
386#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_BIGQUERY_WRITE_CLIENT_H
BigQuery Write API.
Definition: bigquery_write_client.h:67
StatusOr< google::cloud::bigquery::storage::v1::WriteStream > CreateWriteStream(google::cloud::bigquery::storage::v1::CreateWriteStreamRequest const &request, Options opts={})
Creates a write stream to the given table.
BigQueryWriteClient(BigQueryWriteClient const &)=default
BigQueryWriteClient(BigQueryWriteClient &&)=default
StatusOr< google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse > FinalizeWriteStream(google::cloud::bigquery::storage::v1::FinalizeWriteStreamRequest const &request, Options opts={})
Finalize a write stream so that no new data can be appended to the stream.
StatusOr< google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse > BatchCommitWriteStreams(std::string const &parent, Options opts={})
Atomically commits a group of PENDING streams that belong to the same parent table.
StatusOr< google::cloud::bigquery::storage::v1::FlushRowsResponse > FlushRows(std::string const &write_stream, Options opts={})
Flushes rows to a BUFFERED stream.
friend bool operator==(BigQueryWriteClient const &a, BigQueryWriteClient const &b)
Definition: bigquery_write_client.h:83
friend bool operator!=(BigQueryWriteClient const &a, BigQueryWriteClient const &b)
Definition: bigquery_write_client.h:87
StatusOr< google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse > BatchCommitWriteStreams(google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsRequest const &request, Options opts={})
Atomically commits a group of PENDING streams that belong to the same parent table.
StatusOr< google::cloud::bigquery::storage::v1::FlushRowsResponse > FlushRows(google::cloud::bigquery::storage::v1::FlushRowsRequest const &request, Options opts={})
Flushes rows to a BUFFERED stream.
BigQueryWriteClient(std::shared_ptr< BigQueryWriteConnection > connection, Options opts={})
StatusOr< google::cloud::bigquery::storage::v1::WriteStream > CreateWriteStream(std::string const &parent, google::cloud::bigquery::storage::v1::WriteStream const &write_stream, Options opts={})
Creates a write stream to the given table.
StatusOr< google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse > FinalizeWriteStream(std::string const &name, Options opts={})
Finalize a write stream so that no new data can be appended to the stream.
std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::bigquery::storage::v1::AppendRowsRequest, google::cloud::bigquery::storage::v1::AppendRowsResponse > > AsyncAppendRows(Options opts={})
Appends data to the given stream.
StatusOr< google::cloud::bigquery::storage::v1::WriteStream > GetWriteStream(std::string const &name, Options opts={})
Gets information about a write stream.
BigQueryWriteClient & operator=(BigQueryWriteClient const &)=default
StatusOr< google::cloud::bigquery::storage::v1::WriteStream > GetWriteStream(google::cloud::bigquery::storage::v1::GetWriteStreamRequest const &request, Options opts={})
Gets information about a write stream.
BigQueryWriteClient & operator=(BigQueryWriteClient &&)=default
The BigQueryWriteConnection object for BigQueryWriteClient.
Definition: bigquery_write_connection.h:61
Definition: bigquery_read_client.h:32
Definition: analytics_hub_client.h:30