-
Notifications
You must be signed in to change notification settings - Fork 433
Implement CreateTable() for the admin client #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bigtable/admin/table_admin.cc
Outdated
| break; | ||
| } | ||
| if (not rpc_policy->on_failure(status)) { | ||
| throw std::runtime_error("could not create table"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't tell me which table it had trouble creating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
bigtable/admin/table_admin_test.cc
Outdated
| EXPECT_THROW(tested.ListTables(btproto::Table::FULL), std::exception); | ||
| } | ||
|
|
||
| /// @test Verify that bigtable::TableAdmin::Create works in the easy case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bigtable::TableAdmin::Create() <-- code font + () ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
bigtable/admin/table_admin_test.cc
Outdated
| initial_splits { key: 'p' } | ||
| )"""; | ||
| btproto::CreateTableRequest expected; | ||
| EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(expected_text, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASSERT_TRUE? If it can't parse it, might as well fail now. Similarly elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| std::string delta; | ||
| google::protobuf::util::MessageDifferencer differencer; | ||
| differencer.ReportDifferencesToString(&delta); | ||
| EXPECT_TRUE(differencer.Compare(expected, request)) << delta; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only thing we have for protobuf comparisons? There's no ASSERT_THAT gMock matcher support?
I couldn't find it; just asking if you know of anything that's more readable than MessageDifferencer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did look too, could not find anything in googletest, nor in protobuf. At least the output is readable with the MessageDifferencer, though yes, the test code is less than awesome.
| auto delay = backoff_policy->on_completion(status); | ||
| std::this_thread::sleep_for(delay); | ||
| } | ||
| return response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit unfortunate that we're returning a Table and not something like StatusOr, so we cannot propagate the error gracefully to the caller, just print it out to stderr.
Should we consider an exception-free implementation which returns the error as a Status? Or can that be the default implementation, and the exception version converts Status to an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #119 for this. We can create our own exception that derives from std::exception and encapsulates the grpc::Status.
bigtable/admin/table_admin.cc
Outdated
| ::google::bigtable::admin::v2::Table TableAdmin::CreateTable( | ||
| std::string table_id, std::map<std::string, GcRule> column_families, | ||
| std::vector<std::string> splits, | ||
| ::google::bigtable::admin::v2::Table::TimestampGranularity granularity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only support millisecond granularity right now. At the very least we should document this, or perhaps not expose it at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, thoughts on creating a TableConfig or similar structure to make it easier to add new table params in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should expose the API to set the granularity because if we don't then when we do it is a backwards incompatible change that would require a new major version number. Though maybe it would require that anyway.
Not opposed to TableConfig and in this case probably makes sense, will update this PR tomorrow.
| if (status.ok()) { | ||
| break; | ||
| } | ||
| if (not rpc_policy->on_failure(status)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the original requests succeeds but a transient error is returned, followed by an ALREADY_EXISTS error? Probably should not throw an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... there is a certain amount of ad-hoc logic that would be needed. We would need to query the table to return something meaningful. Created #121 for it because we will need to implement GetTable() to fix this. And that is coming in a future PR already.
bigtable/admin/table_config.h
Outdated
| granularity_(TIMESTAMP_GRANULARITY_UNSPECIFIED) {} | ||
|
|
||
| /// Move the contents to the proto to create tables. | ||
| void MoveTo(::google::bigtable::admin::v2::CreateTableRequest& request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google C++ style guide suggests (recommends?) using pointers for output params.
bigtable/admin/table_config_test.cc
Outdated
| config.set_timestamp_granularity(bigtable::TableConfig::MILLIS); | ||
|
|
||
| auto const& families = config.column_families(); | ||
| ASSERT_NE(families.end(), families.find("fam")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
auto it = families.find("fam");
ASSERT_NE(families.end(), it);
EXPECT_EQ(2, it->second...);
mbrukman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
All my concerns have been addressed (thanks!); over to @garye for approval.
|
@coryan — looks like builds are failing: Was this file moved to |
The ASSERT_* macros return void, they cannot be used in functions or lambdas that return something else.
Per the code review.
Also fixed some of the formatting problems, but running into issues with my version of clang-format.
And explain why in like 8 lines.
5498d64 to
b06abe1
Compare
|
Needed to rebase and then fix a path. It was hilarious to get a clean merge that broken all the builds. |
This is another PR in the series to fix #79. It implements the CreateTable() function.