Google Cloud BigQuery C++ Client 2.11.0
A C++ Client Library for Google Cloud BigQuery
Loading...
Searching...
No Matches
Public Member Functions | List of all members
google::cloud::bigquery_storage_v1::BigQueryWriteClient Class Reference

BigQuery Write API. More...

#include <google/cloud/bigquery/storage/v1/bigquery_write_client.h>

Public Member Functions

 BigQueryWriteClient (std::shared_ptr< BigQueryWriteConnection > connection, Options opts={})
 
 ~BigQueryWriteClient ()
 
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. More...
 
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. More...
 
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. More...
 
StatusOr< google::cloud::bigquery::storage::v1::WriteStream > GetWriteStream (std::string const &name, Options opts={})
 Gets information about a write stream. More...
 
StatusOr< google::cloud::bigquery::storage::v1::WriteStream > GetWriteStream (google::cloud::bigquery::storage::v1::GetWriteStreamRequest const &request, Options opts={})
 Gets information about a write stream. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
StatusOr< google::cloud::bigquery::storage::v1::FlushRowsResponse > FlushRows (std::string const &write_stream, Options opts={})
 Flushes rows to a BUFFERED stream. More...
 
StatusOr< google::cloud::bigquery::storage::v1::FlushRowsResponse > FlushRows (google::cloud::bigquery::storage::v1::FlushRowsRequest const &request, Options opts={})
 Flushes rows to a BUFFERED stream. More...
 
Copy and move support
 BigQueryWriteClient (BigQueryWriteClient const &)=default
 
BigQueryWriteClientoperator= (BigQueryWriteClient const &)=default
 
 BigQueryWriteClient (BigQueryWriteClient &&)=default
 
BigQueryWriteClientoperator= (BigQueryWriteClient &&)=default
 

Friends

Equality
bool operator== (BigQueryWriteClient const &a, BigQueryWriteClient const &b)
 
bool operator!= (BigQueryWriteClient const &a, BigQueryWriteClient const &b)
 

Detailed Description

BigQuery Write API.

The Write API can be used to write data to BigQuery.

For supplementary information about the Write API, see: https://cloud.google.com/bigquery/docs/write-api

Equality

Instances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal std::shared_ptr<*Connection> objects compare equal. Objects that compare equal share the same underlying resources.

Performance

Creating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.

Thread Safety

Concurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.

Constructor & Destructor Documentation

◆ BigQueryWriteClient() [1/3]

google::cloud::bigquery_storage_v1::BigQueryWriteClient::BigQueryWriteClient ( std::shared_ptr< BigQueryWriteConnection connection,
Options  opts = {} 
)
explicit

◆ ~BigQueryWriteClient()

google::cloud::bigquery_storage_v1::BigQueryWriteClient::~BigQueryWriteClient ( )

◆ BigQueryWriteClient() [2/3]

google::cloud::bigquery_storage_v1::BigQueryWriteClient::BigQueryWriteClient ( BigQueryWriteClient const &  )
default

◆ BigQueryWriteClient() [3/3]

google::cloud::bigquery_storage_v1::BigQueryWriteClient::BigQueryWriteClient ( BigQueryWriteClient &&  )
default

Member Function Documentation

◆ AsyncAppendRows()

std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::bigquery::storage::v1::AppendRowsRequest, google::cloud::bigquery::storage::v1::AppendRowsResponse > > google::cloud::bigquery_storage_v1::BigQueryWriteClient::AsyncAppendRows ( Options  opts = {})

Appends data to the given stream.

If offset is specified, the offset is checked against the end of stream. The server returns OUT_OF_RANGE in AppendRowsResponse if an attempt is made to append to an offset beyond the current end of the stream or ALREADY_EXISTS if user provides an offset that has already been written to. User can retry with adjusted offset within the same RPC connection. If offset is not specified, append happens at the end of the stream.

The response contains an optional offset at which the append happened. No offset information will be returned for appends to a default stream.

Responses are received in the same order in which requests are sent. There will be one response for each successful inserted request. Responses may optionally embed error information if the originating AppendRequest was not successfully processed.

The specifics of when successfully appended data is made visible to the table are governed by the type of stream:

  • For COMMITTED streams (which includes the default stream), data is visible immediately upon successful append.
  • For BUFFERED streams, data is made visible via a subsequent FlushRows rpc which advances a cursor to a newer offset in the stream.
  • For PENDING streams, data is not made visible until the stream itself is finalized (via the FinalizeWriteStream rpc), and the stream is explicitly committed via the BatchCommitWriteStreams rpc.
Parameters
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
An object representing the bidirectional streaming RPC. Applications can send multiple request messages and receive multiple response messages through this API. Bidirectional streaming RPCs can impose restrictions on the sequence of request and response messages. Please consult the service documentation for details. The request message type (google.cloud.bigquery.storage.v1.AppendRowsRequest) and response messages (google.cloud.bigquery.storage.v1.AppendRowsResponse) are mapped to C++ classes using the Protobuf mapping rules.

◆ BatchCommitWriteStreams() [1/2]

StatusOr< google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse > google::cloud::bigquery_storage_v1::BigQueryWriteClient::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.

Streams must be finalized before commit and cannot be committed multiple times. Once a stream is committed, data in the stream becomes available for read operations.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ BatchCommitWriteStreams() [2/2]

StatusOr< google::cloud::bigquery::storage::v1::BatchCommitWriteStreamsResponse > google::cloud::bigquery_storage_v1::BigQueryWriteClient::BatchCommitWriteStreams ( std::string const &  parent,
Options  opts = {} 
)

Atomically commits a group of PENDING streams that belong to the same parent table.

Streams must be finalized before commit and cannot be committed multiple times. Once a stream is committed, data in the stream becomes available for read operations.

Parameters
parentRequired. Parent table that all the streams should belong to, in the form of projects/{project}/datasets/{dataset}/tables/{table}.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ CreateWriteStream() [1/2]

StatusOr< google::cloud::bigquery::storage::v1::WriteStream > google::cloud::bigquery_storage_v1::BigQueryWriteClient::CreateWriteStream ( google::cloud::bigquery::storage::v1::CreateWriteStreamRequest const &  request,
Options  opts = {} 
)

Creates a write stream to the given table.

Additionally, every table has a special stream named '_default' to which data can be written. This stream doesn't need to be created using CreateWriteStream. It is a stream that can be used simultaneously by any number of clients. Data written to this stream is considered committed as soon as an acknowledgement is received.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.cloud.bigquery.storage.v1.CreateWriteStreamRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.WriteStream) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ CreateWriteStream() [2/2]

StatusOr< google::cloud::bigquery::storage::v1::WriteStream > google::cloud::bigquery_storage_v1::BigQueryWriteClient::CreateWriteStream ( std::string const &  parent,
google::cloud::bigquery::storage::v1::WriteStream const &  write_stream,
Options  opts = {} 
)

Creates a write stream to the given table.

Additionally, every table has a special stream named '_default' to which data can be written. This stream doesn't need to be created using CreateWriteStream. It is a stream that can be used simultaneously by any number of clients. Data written to this stream is considered committed as soon as an acknowledgement is received.

Parameters
parentRequired. Reference to the table to which the stream belongs, in the format of projects/{project}/datasets/{dataset}/tables/{table}.
write_streamRequired. Stream to be created.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.WriteStream) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ FinalizeWriteStream() [1/2]

StatusOr< google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse > google::cloud::bigquery_storage_v1::BigQueryWriteClient::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.

Finalize is not supported on the '_default' stream.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.cloud.bigquery.storage.v1.FinalizeWriteStreamRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.FinalizeWriteStreamResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ FinalizeWriteStream() [2/2]

StatusOr< google::cloud::bigquery::storage::v1::FinalizeWriteStreamResponse > google::cloud::bigquery_storage_v1::BigQueryWriteClient::FinalizeWriteStream ( std::string const &  name,
Options  opts = {} 
)

Finalize a write stream so that no new data can be appended to the stream.

Finalize is not supported on the '_default' stream.

Parameters
nameRequired. Name of the stream to finalize, in the form of projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.FinalizeWriteStreamResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ FlushRows() [1/2]

StatusOr< google::cloud::bigquery::storage::v1::FlushRowsResponse > google::cloud::bigquery_storage_v1::BigQueryWriteClient::FlushRows ( google::cloud::bigquery::storage::v1::FlushRowsRequest const &  request,
Options  opts = {} 
)

Flushes rows to a BUFFERED stream.

If users are appending rows to BUFFERED stream, flush operation is required in order for the rows to become available for reading. A Flush operation flushes up to any previously flushed offset in a BUFFERED stream, to the offset specified in the request.

Flush is not supported on the _default stream, since it is not BUFFERED.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.cloud.bigquery.storage.v1.FlushRowsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.FlushRowsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ FlushRows() [2/2]

StatusOr< google::cloud::bigquery::storage::v1::FlushRowsResponse > google::cloud::bigquery_storage_v1::BigQueryWriteClient::FlushRows ( std::string const &  write_stream,
Options  opts = {} 
)

Flushes rows to a BUFFERED stream.

If users are appending rows to BUFFERED stream, flush operation is required in order for the rows to become available for reading. A Flush operation flushes up to any previously flushed offset in a BUFFERED stream, to the offset specified in the request.

Flush is not supported on the _default stream, since it is not BUFFERED.

Parameters
write_streamRequired. The stream that is the target of the flush operation.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.FlushRowsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ GetWriteStream() [1/2]

StatusOr< google::cloud::bigquery::storage::v1::WriteStream > google::cloud::bigquery_storage_v1::BigQueryWriteClient::GetWriteStream ( google::cloud::bigquery::storage::v1::GetWriteStreamRequest const &  request,
Options  opts = {} 
)

Gets information about a write stream.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.cloud.bigquery.storage.v1.GetWriteStreamRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.WriteStream) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ GetWriteStream() [2/2]

StatusOr< google::cloud::bigquery::storage::v1::WriteStream > google::cloud::bigquery_storage_v1::BigQueryWriteClient::GetWriteStream ( std::string const &  name,
Options  opts = {} 
)

Gets information about a write stream.

Parameters
nameRequired. Name of the stream to get, in the form of projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.cloud.bigquery.storage.v1.WriteStream) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ operator=() [1/2]

BigQueryWriteClient & google::cloud::bigquery_storage_v1::BigQueryWriteClient::operator= ( BigQueryWriteClient &&  )
default

◆ operator=() [2/2]

BigQueryWriteClient & google::cloud::bigquery_storage_v1::BigQueryWriteClient::operator= ( BigQueryWriteClient const &  )
default

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( BigQueryWriteClient const &  a,
BigQueryWriteClient const &  b 
)
friend

◆ operator==

bool operator== ( BigQueryWriteClient const &  a,
BigQueryWriteClient const &  b 
)
friend