Skip to content

Commit b83d689

Browse files
authored
Merge branch 'main' into schema-change-error
2 parents 29e3521 + 829bce3 commit b83d689

File tree

11 files changed

+33
-47
lines changed

11 files changed

+33
-47
lines changed

google/cloud/bigtable/bound_query.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#include "google/cloud/bigtable/bound_query.h"
16+
#include "google/cloud/bigtable/internal/query_plan.h"
1617

1718
namespace google {
1819
namespace cloud {
@@ -23,12 +24,6 @@ StatusOr<google::bigtable::v2::PrepareQueryResponse> BoundQuery::response() {
2324
return query_plan_->response();
2425
}
2526

26-
std::unordered_map<std::string, Value> const& BoundQuery::parameters() const {
27-
return parameters_;
28-
}
29-
30-
InstanceResource const& BoundQuery::instance() const { return instance_; }
31-
3227
google::bigtable::v2::ExecuteQueryRequest BoundQuery::ToRequestProto() const {
3328
google::bigtable::v2::ExecuteQueryRequest result;
3429
*result.mutable_instance_name() = instance_.FullName();

google/cloud/bigtable/bound_query.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_BOUND_QUERY_H
1717

1818
#include "google/cloud/bigtable/instance_resource.h"
19-
#include "google/cloud/bigtable/internal/query_plan.h"
2019
#include "google/cloud/bigtable/value.h"
2120
#include "google/cloud/bigtable/version.h"
2221
#include "google/cloud/completion_queue.h"
@@ -29,6 +28,7 @@ namespace cloud {
2928
namespace bigtable_internal {
3029
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3130
class DataConnectionImpl;
31+
class QueryPlan;
3232
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
3333
} // namespace bigtable_internal
3434

@@ -48,17 +48,14 @@ class BoundQuery {
4848
BoundQuery& operator=(BoundQuery&&) = default;
4949

5050
// Accessors
51+
InstanceResource const& instance() const { return instance_; }
52+
std::unordered_map<std::string, Value> const& parameters() const {
53+
return parameters_;
54+
}
5155
StatusOr<google::bigtable::v2::PrepareQueryResponse> response();
52-
std::unordered_map<std::string, Value> const& parameters() const;
53-
InstanceResource const& instance() const;
5456

5557
google::bigtable::v2::ExecuteQueryRequest ToRequestProto() const;
5658

57-
GOOGLE_CLOUD_CPP_DEPRECATED("use response()")
58-
StatusOr<std::string> prepared_query() const;
59-
GOOGLE_CLOUD_CPP_DEPRECATED("use response()")
60-
StatusOr<google::bigtable::v2::ResultSetMetadata> metadata() const;
61-
6259
private:
6360
friend class PreparedQuery;
6461
friend class bigtable_internal::DataConnectionImpl;

google/cloud/bigtable/bound_query_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#include "google/cloud/bigtable/bound_query.h"
16+
#include "google/cloud/bigtable/internal/query_plan.h"
1617
#include "google/cloud/bigtable/prepared_query.h"
1718
#include "google/cloud/bigtable/sql_statement.h"
1819
#include "google/cloud/bigtable/value.h"
@@ -27,7 +28,7 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2728
namespace {
2829
using ::google::bigtable::v2::PrepareQueryResponse;
2930

30-
TEST(BoundQuery, FromPreparedQuery) {
31+
TEST(BoundQueryTest, FromPreparedQuery) {
3132
auto fake_cq_impl = std::make_shared<testing_util::FakeCompletionQueueImpl>();
3233
Project p("dummy-project");
3334
InstanceResource instance(p, "dummy-instance");
@@ -67,7 +68,7 @@ TEST(BoundQuery, FromPreparedQuery) {
6768
fake_cq_impl->SimulateCompletion(false);
6869
}
6970

70-
TEST(BoundQuery, ToRequestProto) {
71+
TEST(BoundQueryTest, ToRequestProto) {
7172
auto fake_cq_impl = std::make_shared<testing_util::FakeCompletionQueueImpl>();
7273
Project p("dummy-project");
7374
InstanceResource instance(p, "dummy-instance");

google/cloud/bigtable/internal/data_connection_impl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "google/cloud/bigtable/internal/partial_result_set_reader.h"
2525
#include "google/cloud/bigtable/internal/partial_result_set_resume.h"
2626
#include "google/cloud/bigtable/internal/partial_result_set_source.h"
27+
#include "google/cloud/bigtable/internal/query_plan.h"
2728
#include "google/cloud/bigtable/internal/retry_traits.h"
2829
#include "google/cloud/bigtable/internal/rpc_policy_parameters.h"
2930
#include "google/cloud/bigtable/options.h"

google/cloud/bigtable/internal/data_connection_impl_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "google/cloud/bigtable/internal/data_connection_impl.h"
1616
#include "google/cloud/bigtable/data_connection.h"
1717
#include "google/cloud/bigtable/internal/defaults.h"
18+
#include "google/cloud/bigtable/internal/query_plan.h"
1819
#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
1920
#include "google/cloud/bigtable/internal/metrics.h"
2021
#include "google/cloud/testing_util/fake_clock.h"

google/cloud/bigtable/internal/query_plan.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ std::shared_ptr<QueryPlan> QueryPlan::Create(
3535
return plan;
3636
}
3737

38+
QueryPlan::~QueryPlan() {
39+
if (refresh_timer_.valid()) refresh_timer_.cancel();
40+
}
41+
3842
void QueryPlan::Initialize() {
3943
std::unique_lock<std::mutex> lock(mu_);
4044
if (state_ == RefreshState::kDone) ScheduleRefresh(lock);

google/cloud/bigtable/internal/query_plan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class QueryPlan : public std::enable_shared_from_this<QueryPlan> {
4343
StatusOr<google::bigtable::v2::PrepareQueryResponse> response,
4444
RefreshFn fn, std::shared_ptr<Clock> clock = std::make_shared<Clock>());
4545

46+
~QueryPlan();
47+
4648
// Invalidates the current QueryPlan and triggers a refresh.
4749
void Invalidate(Status status, std::string const& invalid_query_plan_id);
4850

google/cloud/bigtable/prepared_query.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ BoundQuery PreparedQuery::BindParameters(
2525
return BoundQuery(instance_, query_plan_, std::move(params));
2626
}
2727

28-
InstanceResource const& PreparedQuery::instance() const { return instance_; }
29-
30-
SqlStatement const& PreparedQuery::sql_statement() const {
31-
return sql_statement_;
32-
}
33-
3428
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
3529
} // namespace bigtable
3630
} // namespace cloud

google/cloud/bigtable/prepared_query.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "google/cloud/bigtable/bound_query.h"
1919
#include "google/cloud/bigtable/instance_resource.h"
20-
#include "google/cloud/bigtable/internal/query_plan.h"
2120
#include "google/cloud/bigtable/sql_statement.h"
2221
#include "google/cloud/bigtable/value.h"
2322
#include "google/cloud/bigtable/version.h"
@@ -28,28 +27,33 @@
2827

2928
namespace google {
3029
namespace cloud {
30+
namespace bigtable_internal {
31+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
32+
class QueryPlan;
33+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
34+
} // namespace bigtable_internal
3135
namespace bigtable {
3236
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3337

3438
// Represents a long-lived query execution plan.
3539
// Query plans can expire and are refreshed as a background task.
3640
class PreparedQuery {
3741
public:
38-
// Creates an instance of BoundQuery using the query plan ID from the
39-
// response.
40-
BoundQuery BindParameters(
41-
std::unordered_map<std::string, Value> params) const;
42-
43-
// Accessors
44-
InstanceResource const& instance() const;
45-
SqlStatement const& sql_statement() const;
46-
4742
PreparedQuery(InstanceResource instance, SqlStatement sql_statement,
4843
std::shared_ptr<bigtable_internal::QueryPlan> query_plan)
4944
: instance_(std::move(instance)),
5045
sql_statement_(std::move(sql_statement)),
5146
query_plan_(std::move(query_plan)) {}
5247

48+
// Accessors
49+
InstanceResource const& instance() const { return instance_; }
50+
SqlStatement const& sql_statement() const { return sql_statement_; }
51+
52+
// Creates an instance of BoundQuery using the query plan ID from the
53+
// response.
54+
BoundQuery BindParameters(
55+
std::unordered_map<std::string, Value> params) const;
56+
5357
private:
5458
InstanceResource instance_;
5559
SqlStatement sql_statement_;

google/cloud/bigtable/prepared_query_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#include "google/cloud/bigtable/prepared_query.h"
16+
#include "google/cloud/bigtable/internal/query_plan.h"
1617
#include "google/cloud/bigtable/sql_statement.h"
1718
#include "google/cloud/testing_util/fake_completion_queue_impl.h"
1819
#include "google/cloud/testing_util/status_matchers.h"
@@ -25,7 +26,7 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2526
namespace {
2627
using ::google::bigtable::v2::PrepareQueryResponse;
2728

28-
TEST(PreparedQuery, DefaultConstructor) {
29+
TEST(PreparedQueryTest, DefaultConstructor) {
2930
auto fake_cq_impl = std::make_shared<testing_util::FakeCompletionQueueImpl>();
3031
Project p("dummy-project");
3132
InstanceResource instance(p, "dummy-instance");

0 commit comments

Comments
 (0)