Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
|
The main interface to interact with data in a Cloud Bigtable table. More...
#include <google/cloud/bigtable/table.h>
Public Member Functions | |
Table (std::shared_ptr< bigtable::DataConnection > conn, TableResource tr, Options options={}) | |
Constructs a Table object. More... | |
std::string const & | table_name () const |
std::string const & | app_profile_id () const |
std::string const & | project_id () const |
std::string const & | instance_id () const |
std::string const & | table_id () const |
Table | WithNewTarget (std::string project_id, std::string instance_id, std::string table_id) const |
Returns a Table that reuses the connection and configuration of this Table, but with a different resource name. More... | |
Table | WithNewTarget (std::string project_id, std::string instance_id, std::string app_profile_id, std::string table_id) const |
Returns a Table that reuses the connection and configuration of this Table, but with a different resource name. More... | |
Status | Apply (SingleRowMutation mut, Options opts={}) |
Attempts to apply the mutation to a row. More... | |
future< Status > | AsyncApply (SingleRowMutation mut, Options opts={}) |
Makes asynchronous attempts to apply the mutation to a row. More... | |
std::vector< FailedMutation > | BulkApply (BulkMutation mut, Options opts={}) |
Attempts to apply mutations to multiple rows. More... | |
future< std::vector< FailedMutation > > | AsyncBulkApply (BulkMutation mut, Options opts={}) |
Makes asynchronous attempts to apply mutations to multiple rows. More... | |
RowReader | ReadRows (RowSet row_set, Filter filter, Options opts={}) |
Reads a set of rows from the table. More... | |
RowReader | ReadRows (RowSet row_set, std::int64_t rows_limit, Filter filter, Options opts={}) |
Reads a limited set of rows from the table. More... | |
StatusOr< std::pair< bool, Row > > | ReadRow (std::string row_key, Filter filter, Options opts={}) |
Read and return a single row from the table. More... | |
StatusOr< MutationBranch > | CheckAndMutateRow (std::string row_key, Filter filter, std::vector< Mutation > true_mutations, std::vector< Mutation > false_mutations, Options opts={}) |
Atomic test-and-set for a row using filter expressions. More... | |
future< StatusOr< MutationBranch > > | AsyncCheckAndMutateRow (std::string row_key, Filter filter, std::vector< Mutation > true_mutations, std::vector< Mutation > false_mutations, Options opts={}) |
Make an asynchronous request to conditionally mutate a row. More... | |
StatusOr< std::vector< bigtable::RowKeySample > > | SampleRows (Options opts={}) |
Sample of the row keys in the table, including approximate data sizes. More... | |
future< StatusOr< std::vector< bigtable::RowKeySample > > > | AsyncSampleRows (Options opts={}) |
Asynchronously obtains a sample of the row keys in the table, including approximate data sizes. More... | |
template<typename... Args> | |
StatusOr< Row > | ReadModifyWriteRow (std::string row_key, bigtable::ReadModifyWriteRule rule, Args &&... rules_and_options) |
Atomically read and modify the row in the server, returning the resulting row. More... | |
template<typename... Args> | |
future< StatusOr< Row > > | AsyncReadModifyWriteRow (std::string row_key, bigtable::ReadModifyWriteRule rule, Args &&... rules_and_options) |
Make an asynchronous request to atomically read and modify a row. More... | |
template<typename RowFunctor , typename FinishFunctor > | |
void | AsyncReadRows (RowFunctor on_row, FinishFunctor on_finish, RowSet row_set, Filter filter, Options opts={}) |
Asynchronously reads a set of rows from the table. More... | |
template<typename RowFunctor , typename FinishFunctor > | |
void | AsyncReadRows (RowFunctor on_row, FinishFunctor on_finish, RowSet row_set, std::int64_t rows_limit, Filter filter, Options opts={}) |
Asynchronously reads a set of rows from the table. More... | |
future< StatusOr< std::pair< bool, Row > > > | AsyncReadRow (std::string row_key, Filter filter, Options opts={}) |
Asynchronously read and return a single row from the table. More... | |
Table (std::shared_ptr< DataClient > client, std::string const &table_id) | |
Constructor with default policies. More... | |
Table (std::shared_ptr< DataClient > client, std::string app_profile_id, std::string const &table_id) | |
Constructor with default policies. More... | |
template<typename... Policies> | |
Table (std::shared_ptr< DataClient > client, std::string const &table_id, Policies &&... policies) | |
Constructor with explicit policies. More... | |
template<typename... Policies> | |
Table (std::shared_ptr< DataClient > client, std::string app_profile_id, std::string const &table_id, Policies &&... policies) | |
Constructor with explicit policies. More... | |
Friends | |
class | MutationBatcher |
The main interface to interact with data in a Cloud Bigtable table.
This class provides member functions to:
Table::ReadRow()
Table::ReadRows()
Table::Apply()
Table::BulkApply()
Table::CheckAndMutateRow()
Table::ReadModifyWriteRow()
Table::SampleRows()
.The class deals with the most common transient failures, and retries the underlying RPC calls subject to the policies configured by the application. These policies are documented in Table::Table()
.
Table
is comparable to creating a few objects of type std::string
or a few objects of type std::shared_ptr<int>
. The class represents a shallow handle to a remote object.StatusOr<T>
to report errors. When an operation fails to perform its work the returned StatusOr<T>
contains the error details. If the ok()
member function in the StatusOr<T>
returns true
then it contains the expected result. Operations that do not return a value simply return a google::cloud::Status
indicating success or the details of the error Please consult the `StatusOr<T>` documentation for more details.In addition, the main page contains examples using StatusOr<T>
to handle errors.
The application can override these policies when constructing objects of this class. The documentation for the constructors show examples of this in action.
LimitedTimeRetryPolicy
and LimitedErrorCountRetryPolicy
for alternative retry policies.ExponentialBackoffPolicy
to configure different parameters for the exponential backoff policy.SafeIdempotentMutationPolicy
and AlwaysRetryMutationPolicy
for alternative idempotency policies.
|
inlineexplicit |
Constructs a Table
object.
conn | the connection to the Cloud Bigtable service. See MakeDataConnection() for how to create a connection. To mock the behavior of Table in your tests, use a bigtable_mocks::MockDataConnection . |
tr | identifies the table resource by its project, instance, and table ids. |
options | Configuration options for the table. Use AppProfileIdOption to supply an app profile for the Table operations. Or configure retry / backoff / idempotency policies with the options enumerated in DataPolicyOptionList . |
|
inline |
Constructor with default policies.
client | how to communicate with Cloud Bigtable, including credentials, the project id, and the instance id. |
table_id | the table id within the instance defined by client. The full table name is client->instance_name() + "/tables/" + table_id . |
|
inline |
Constructor with default policies.
client | how to communicate with Cloud Bigtable, including credentials, the project id, and the instance id. |
app_profile_id | the app_profile_id needed for using the replication API. |
table_id | the table id within the instance defined by client. The full table name is client->instance_name() + "/tables/" + table_id . |
|
inline |
Constructor with explicit policies.
The policies are passed by value, because this makes it easy for applications to create them.
client | how to communicate with Cloud Bigtable, including credentials, the project id, and the instance id. |
table_id | the table id within the instance defined by client. The full table name is client->instance_name() + "/tables/" + table_id . |
policies | the set of policy overrides for this object. |
Policies | the types of the policies to override, the types must derive from one of the following types: |
IdempotentMutationPolicy
which mutations are retried. Use SafeIdempotentMutationPolicy
to only retry idempotent operations, use AlwaysRetryMutationPolicy
to retry all operations. Read the caveats in the class definition to understand the downsides of the latter. You can also create your own policies that decide which mutations to retry.RPCBackoffPolicy
how to backoff from a failed RPC. Currently only ExponentialBackoffPolicy
is implemented. You can also create your own policies that backoff using a different algorithm.RPCRetryPolicy
for how long to retry failed RPCs. Use LimitedErrorCountRetryPolicy
to limit the number of failures allowed. Use LimitedTimeRetryPolicy
to bound the time for any request. You can also create your own policies that combine time and error counts.
|
inline |
Constructor with explicit policies.
The policies are passed by value, because this makes it easy for applications to create them.
client | how to communicate with Cloud Bigtable, including credentials, the project id, and the instance id. |
app_profile_id | the app_profile_id needed for using the replication API. |
table_id | the table id within the instance defined by client. The full table name is client->instance_name() + "/tables/" + table_id . |
policies | the set of policy overrides for this object. |
Policies | the types of the policies to override, the types must derive from one of the following types:
|
|
inline |
Status google::cloud::bigtable::Table::Apply | ( | SingleRowMutation | mut, |
Options | opts = {} |
||
) |
Attempts to apply the mutation to a row.
mut | the mutation. Note that this function takes ownership (and then discards) the data in the mutation. In general, a SingleRowMutation can be used to modify and/or delete multiple cells, across different columns and column families. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
google::cloud::bigtable::SetCell()
without an explicit timestamp is not an idempotent operation.future< Status > google::cloud::bigtable::Table::AsyncApply | ( | SingleRowMutation | mut, |
Options | opts = {} |
||
) |
Makes asynchronous attempts to apply the mutation to a row.
mut | the mutation. Note that this function takes ownership (and then discards) the data in the mutation. In general, a SingleRowMutation can be used to modify and/or delete multiple cells, across different columns and column families. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
google::cloud::bigtable::SetCell()
without an explicit timestamp is not an idempotent operation.future< std::vector< FailedMutation > > google::cloud::bigtable::Table::AsyncBulkApply | ( | BulkMutation | mut, |
Options | opts = {} |
||
) |
Makes asynchronous attempts to apply mutations to multiple rows.
These mutations are applied in bulk, in a single MutateRowsRequest
RPC. Failures are handled on a per mutation basis. If the result of a mutation is a permanent (non-retryable) error, or if a non-idempotent mutation fails for any reason, the mutation will not be retried. Only idempotent mutations that encounter transient (retryable) errors can be retried. These mutations are collected and retried in bulk. This function will continue to retry any remaining errors until this class's retry policy is exhausted.
It is possible that some mutations may not be attempted at all. These mutations are considered failing and will be returned.
BulkMutation
can modify multiple rows, and the modifications for each row can change (or create) multiple cells, across different columns and column families.mut | the mutations |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
google::cloud::bigtable::SetCell()
without an explicit timestamp is not an idempotent operation.future< StatusOr< MutationBranch > > google::cloud::bigtable::Table::AsyncCheckAndMutateRow | ( | std::string | row_key, |
Filter | filter, | ||
std::vector< Mutation > | true_mutations, | ||
std::vector< Mutation > | false_mutations, | ||
Options | opts = {} |
||
) |
Make an asynchronous request to conditionally mutate a row.
row_key | the row key on which the conditional mutation will be performed |
filter | the condition, depending on which the mutation will be performed |
true_mutations | the mutations which will be performed if filter is true |
false_mutations | the mutations which will be performed if filter is false |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
|
inline |
Make an asynchronous request to atomically read and modify a row.
Args | this is zero or more ReadModifyWriteRules to apply on a row. Options to override the class-level options, such as retry, backoff, and idempotency policies are also be passed via this parameter pack. |
row_key | the row key on which modification will be performed |
rule | to modify the row. Two types of rules are applied here AppendValue which will read the existing value and append the text provided to the value. IncrementAmount which will read the existing uint64 big-endian-int and add the value provided. Both rules accept the family and column identifier to modify. |
rules_and_options | is the zero or more ReadModifyWriteRules to apply on a row. Options to override the class-level options, such as retry, backoff, and idempotency policies are also be passed via this parameter pack. |
future< StatusOr< std::pair< bool, Row > > > google::cloud::bigtable::Table::AsyncReadRow | ( | std::string | row_key, |
Filter | filter, | ||
Options | opts = {} |
||
) |
Asynchronously read and return a single row from the table.
row_key | the row to read. |
filter | a filter expression, can be used to select a subset of the column families and columns in the row. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
false
if the row does not exist. If the first element is true
the second element has the contents of the Row. Note that the contents may be empty if the filter expression removes all column families and columns.
|
inline |
Asynchronously reads a set of rows from the table.
on_row | the callback to be invoked on each successfully read row; it should be invocable with Row and return a future<bool>; the returned future<bool> should be satisfied with true when the user is ready to receive the next callback and with false when the user doesn't want any more rows; if on_row throws, the results are undefined |
on_finish | the callback to be invoked when the stream is closed; it should be invocable with Status and not return anything; it will always be called as the last callback; if on_finish throws, the results are undefined |
row_set | the rows to read from. |
filter | is applied on the server-side to data in the rows. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
RowFunctor | the type of the on_row callback. |
FinishFunctor | the type of the on_finish callback. |
|
inline |
Asynchronously reads a set of rows from the table.
on_row | the callback to be invoked on each successfully read row; it should be invocable with Row and return a future<bool>; the returned future<bool> should be satisfied with true when the user is ready to receive the next callback and with false when the user doesn't want any more rows; if on_row throws, the results are undefined |
on_finish | the callback to be invoked when the stream is closed; it should be invocable with Status and not return anything; it will always be called as the last callback; if on_finish throws, the results are undefined |
row_set | the rows to read from. |
rows_limit | the maximum number of rows to read. Cannot be a negative number or zero. Use AsyncReadRows(RowSet, Filter) to read all matching rows. |
filter | is applied on the server-side to data in the rows. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
RowFunctor | the type of the on_row callback. |
FinishFunctor | the type of the on_finish callback. |
future< StatusOr< std::vector< bigtable::RowKeySample > > > google::cloud::bigtable::Table::AsyncSampleRows | ( | Options | opts = {} | ) |
Asynchronously obtains a sample of the row keys in the table, including approximate data sizes.
std::vector< FailedMutation > google::cloud::bigtable::Table::BulkApply | ( | BulkMutation | mut, |
Options | opts = {} |
||
) |
Attempts to apply mutations to multiple rows.
These mutations are applied in bulk, in a single MutateRowsRequest
RPC. Failures are handled on a per mutation basis. If the result of a mutation is a permanent (non-retryable) error, or if a non-idempotent mutation fails for any reason, the mutation will not be retried. Only idempotent mutations that encounter transient (retryable) errors can be retried. These mutations are collected and retried in bulk. This function will continue to retry any remaining errors until this class's retry policy is exhausted.
It is possible that some mutations may not be attempted at all. These mutations are considered failing and will be returned.
BulkMutation
can modify multiple rows, and the modifications for each row can change (or create) multiple cells, across different columns and column families.mut | the mutations |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
google::cloud::bigtable::SetCell()
without an explicit timestamp is not an idempotent operation.StatusOr< MutationBranch > google::cloud::bigtable::Table::CheckAndMutateRow | ( | std::string | row_key, |
Filter | filter, | ||
std::vector< Mutation > | true_mutations, | ||
std::vector< Mutation > | false_mutations, | ||
Options | opts = {} |
||
) |
Atomic test-and-set for a row using filter expressions.
Atomically check the value of a row using a filter expression. If the expression passes (meaning at least one element is returned by it), one set of mutations is applied. If the filter does not pass, a different set of mutations is applied. The changes are atomically applied in the server.
row_key | the row to modify. |
filter | the filter expression. |
true_mutations | the mutations for the "filter passed" case. |
false_mutations | the mutations for the "filter did not pass" case. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
|
inline |
|
inline |
|
inline |
Atomically read and modify the row in the server, returning the resulting row.
Args | this is zero or more ReadModifyWriteRules to apply on a row. Options to override the class-level options, such as retry, backoff, and idempotency policies are also be passed via this parameter pack. |
row_key | the row to read |
rule | to modify the row. Two types of rules are applied here AppendValue which will read the existing value and append the text provided to the value. IncrementAmount which will read the existing uint64 big-endian-int and add the value provided. Both rules accept the family and column identifier to modify. |
rules_and_options | is the zero or more ReadModifyWriteRules to apply on a row. Options to override the class-level options, such as retry, backoff, and idempotency policies are also be passed via this parameter pack. |
StatusOr< std::pair< bool, Row > > google::cloud::bigtable::Table::ReadRow | ( | std::string | row_key, |
Filter | filter, | ||
Options | opts = {} |
||
) |
Read and return a single row from the table.
row_key | the row to read. |
filter | a filter expression, can be used to select a subset of the column families and columns in the row. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
false
if the row does not exist. If the first element is true
the second element has the contents of the Row. Note that the contents may be empty if the filter expression removes all column families and columns.RowReader google::cloud::bigtable::Table::ReadRows | ( | RowSet | row_set, |
Filter | filter, | ||
Options | opts = {} |
||
) |
Reads a set of rows from the table.
row_set | the rows to read from. |
filter | is applied on the server-side to data in the rows. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
RowReader
documentation for more details.RowReader google::cloud::bigtable::Table::ReadRows | ( | RowSet | row_set, |
std::int64_t | rows_limit, | ||
Filter | filter, | ||
Options | opts = {} |
||
) |
Reads a limited set of rows from the table.
row_set | the rows to read from. |
rows_limit | the maximum number of rows to read. Cannot be a negative number or zero. Use ReadRows(RowSet, Filter) to read all matching rows. |
filter | is applied on the server-side to data in the rows. |
opts | (Optional) Override the class-level options, such as retry, backoff, and idempotency policies. |
RowReader
documentation for more details.StatusOr< std::vector< bigtable::RowKeySample > > google::cloud::bigtable::Table::SampleRows | ( | Options | opts = {} | ) |
Sample of the row keys in the table, including approximate data sizes.
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |