Skip to content

Commit 655e7f4

Browse files
authored
impl(bigtable): Table accepts Options (#9307)
1 parent d12b9c4 commit 655e7f4

File tree

3 files changed

+78
-40
lines changed

3 files changed

+78
-40
lines changed

google/cloud/bigtable/table.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static_assert(std::is_copy_assignable<bigtable::Table>::value,
4848

4949
Status Table::Apply(SingleRowMutation mut) {
5050
if (connection_) {
51+
google::cloud::internal::OptionsSpan span(options_);
5152
return connection_->Apply(app_profile_id_, table_name_, std::move(mut));
5253
}
5354

@@ -94,6 +95,7 @@ Status Table::Apply(SingleRowMutation mut) {
9495

9596
future<Status> Table::AsyncApply(SingleRowMutation mut) {
9697
if (connection_) {
98+
google::cloud::internal::OptionsSpan span(options_);
9799
return connection_->AsyncApply(app_profile_id_, table_name_,
98100
std::move(mut));
99101
}
@@ -138,6 +140,7 @@ future<Status> Table::AsyncApply(SingleRowMutation mut) {
138140

139141
std::vector<FailedMutation> Table::BulkApply(BulkMutation mut) {
140142
if (connection_) {
143+
google::cloud::internal::OptionsSpan span(options_);
141144
return connection_->BulkApply(app_profile_id_, table_name_, std::move(mut));
142145
}
143146

@@ -171,6 +174,7 @@ std::vector<FailedMutation> Table::BulkApply(BulkMutation mut) {
171174

172175
future<std::vector<FailedMutation>> Table::AsyncBulkApply(BulkMutation mut) {
173176
if (connection_) {
177+
google::cloud::internal::OptionsSpan span(options_);
174178
return connection_->AsyncBulkApply(app_profile_id_, table_name_,
175179
std::move(mut));
176180
}
@@ -191,6 +195,7 @@ RowReader Table::ReadRows(RowSet row_set, Filter filter) {
191195
RowReader Table::ReadRows(RowSet row_set, std::int64_t rows_limit,
192196
Filter filter) {
193197
if (connection_) {
198+
google::cloud::internal::OptionsSpan span(options_);
194199
return connection_->ReadRows(app_profile_id_, table_name_,
195200
std::move(row_set), rows_limit,
196201
std::move(filter));
@@ -207,6 +212,7 @@ RowReader Table::ReadRows(RowSet row_set, std::int64_t rows_limit,
207212
StatusOr<std::pair<bool, Row>> Table::ReadRow(std::string row_key,
208213
Filter filter) {
209214
if (connection_) {
215+
google::cloud::internal::OptionsSpan span(options_);
210216
return connection_->ReadRow(app_profile_id_, table_name_,
211217
std::move(row_key), std::move(filter));
212218
}
@@ -236,6 +242,7 @@ StatusOr<MutationBranch> Table::CheckAndMutateRow(
236242
std::string row_key, Filter filter, std::vector<Mutation> true_mutations,
237243
std::vector<Mutation> false_mutations) {
238244
if (connection_) {
245+
google::cloud::internal::OptionsSpan span(options_);
239246
return connection_->CheckAndMutateRow(
240247
app_profile_id_, table_name_, std::move(row_key), std::move(filter),
241248
std::move(true_mutations), std::move(false_mutations));
@@ -272,6 +279,7 @@ future<StatusOr<MutationBranch>> Table::AsyncCheckAndMutateRow(
272279
std::string row_key, Filter filter, std::vector<Mutation> true_mutations,
273280
std::vector<Mutation> false_mutations) {
274281
if (connection_) {
282+
google::cloud::internal::OptionsSpan span(options_);
275283
return connection_->AsyncCheckAndMutateRow(
276284
app_profile_id_, table_name_, std::move(row_key), std::move(filter),
277285
std::move(true_mutations), std::move(false_mutations));
@@ -325,6 +333,7 @@ future<StatusOr<MutationBranch>> Table::AsyncCheckAndMutateRow(
325333
// samples otherwise the result is an inconsistent set of sample row keys.
326334
StatusOr<std::vector<bigtable::RowKeySample>> Table::SampleRows() {
327335
if (connection_) {
336+
google::cloud::internal::OptionsSpan span(options_);
328337
return connection_->SampleRows(app_profile_id_, table_name_);
329338
}
330339

@@ -370,6 +379,7 @@ StatusOr<std::vector<bigtable::RowKeySample>> Table::SampleRows() {
370379

371380
future<StatusOr<std::vector<bigtable::RowKeySample>>> Table::AsyncSampleRows() {
372381
if (connection_) {
382+
google::cloud::internal::OptionsSpan span(options_);
373383
return connection_->AsyncSampleRows(app_profile_id_, table_name_);
374384
}
375385

@@ -385,6 +395,7 @@ StatusOr<Row> Table::ReadModifyWriteRowImpl(
385395
::google::bigtable::v2::ReadModifyWriteRowRequest>(
386396
request, app_profile_id_, table_name_);
387397
if (connection_) {
398+
google::cloud::internal::OptionsSpan span(options_);
388399
return connection_->ReadModifyWriteRow(std::move(request));
389400
}
390401

@@ -406,6 +417,7 @@ future<StatusOr<Row>> Table::AsyncReadModifyWriteRowImpl(
406417
::google::bigtable::v2::ReadModifyWriteRowRequest>(
407418
request, app_profile_id_, table_name_);
408419
if (connection_) {
420+
google::cloud::internal::OptionsSpan span(options_);
409421
return connection_->AsyncReadModifyWriteRow(std::move(request));
410422
}
411423

@@ -435,6 +447,7 @@ future<StatusOr<Row>> Table::AsyncReadModifyWriteRowImpl(
435447
future<StatusOr<std::pair<bool, Row>>> Table::AsyncReadRow(std::string row_key,
436448
Filter filter) {
437449
if (connection_) {
450+
google::cloud::internal::OptionsSpan span(options_);
438451
return connection_->AsyncReadRow(app_profile_id_, table_name_,
439452
std::move(row_key), std::move(filter));
440453
}

google/cloud/bigtable/table.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "google/cloud/bigtable/filters.h"
2121
#include "google/cloud/bigtable/idempotent_mutation_policy.h"
2222
#include "google/cloud/bigtable/internal/data_connection.h"
23+
#include "google/cloud/bigtable/internal/defaults.h"
2324
#include "google/cloud/bigtable/internal/legacy_async_row_reader.h"
2425
#include "google/cloud/bigtable/mutation_branch.h"
2526
#include "google/cloud/bigtable/mutations.h"
@@ -52,7 +53,8 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
5253
// public.
5354
bigtable::Table MakeTable(std::shared_ptr<DataConnection> conn,
5455
std::string project_id, std::string instance_id,
55-
std::string app_profile_id, std::string table_id);
56+
std::string app_profile_id, std::string table_id,
57+
Options options = {});
5658

5759
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
5860
} // namespace bigtable_internal
@@ -888,6 +890,7 @@ class Table {
888890
"RowFunctor should return a future<bool>.");
889891

890892
if (connection_) {
893+
google::cloud::internal::OptionsSpan span(options_);
891894
connection_->AsyncReadRows(
892895
app_profile_id_, table_name_, std::move(on_row), std::move(on_finish),
893896
std::move(row_set), rows_limit, std::move(filter));
@@ -937,18 +940,22 @@ class Table {
937940
private:
938941
friend Table bigtable_internal::MakeTable(
939942
std::shared_ptr<bigtable_internal::DataConnection>, std::string,
940-
std::string, std::string, std::string);
943+
std::string, std::string, std::string, Options);
941944
explicit Table(std::shared_ptr<bigtable_internal::DataConnection> conn,
942945
std::string project_id, std::string instance_id,
943-
std::string app_profile_id, std::string table_id)
946+
std::string app_profile_id, std::string table_id,
947+
Options options = {})
944948
: app_profile_id_(std::move(app_profile_id)),
945949
project_id_(std::move(project_id)),
946950
instance_id_(std::move(instance_id)),
947951
table_name_(TableName(project_id_, instance_id_, table_id)),
948952
table_id_(std::move(table_id)),
949953
metadata_update_policy_(
950954
MetadataUpdatePolicy(table_name_, MetadataParamTypes::TABLE_NAME)),
951-
connection_(std::move(conn)) {}
955+
connection_(std::move(conn)),
956+
options_(google::cloud::internal::MergeOptions(
957+
std::move(options),
958+
internal::DefaultDataOptions(connection_->options()))) {}
952959

953960
/**
954961
* Send request ReadModifyWriteRowRequest to modify the row and get it back
@@ -1021,6 +1028,7 @@ class Table {
10211028
std::shared_ptr<IdempotentMutationPolicy> idempotent_mutation_policy_;
10221029
std::shared_ptr<BackgroundThreads> background_threads_;
10231030
std::shared_ptr<bigtable_internal::DataConnection> connection_;
1031+
Options options_;
10241032
};
10251033

10261034
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
@@ -1032,10 +1040,10 @@ inline bigtable::Table MakeTable(std::shared_ptr<DataConnection> conn,
10321040
std::string project_id,
10331041
std::string instance_id,
10341042
std::string app_profile_id,
1035-
std::string table_id) {
1043+
std::string table_id, Options options) {
10361044
return bigtable::Table(std::move(conn), std::move(project_id),
10371045
std::move(instance_id), std::move(app_profile_id),
1038-
std::move(table_id));
1046+
std::move(table_id), std::move(options));
10391047
}
10401048

10411049
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

0 commit comments

Comments
 (0)