Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

refactor!: replaced Row<...> with std::tuple<...> #967

Merged
merged 7 commits into from
Oct 18, 2019

Conversation

devjgm
Copy link
Contributor

@devjgm devjgm commented Oct 18, 2019

This is a prefactoring (pre-refactoring) in preparatoin for #387, which will create a new non-templated Row class. This PR makes room for that new class, and leave most of the code looking like it will ultimately look: When a user wants a typed-Row, they will specify the row's type using std::tuple.

BREAKING CHANGE: Removes the Row<...> type.


This change is Reviewable

@devjgm devjgm requested a review from coryan October 18, 2019 18:44
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 18, 2019
Copy link
Member

@coryan coryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chore or Refactor? Up to you... Couple of items below, reverting the changes to the README.md file is a blocker in my opinion.

Reviewed 16 of 16 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @devjgm)


google/cloud/spanner/README.md, line 24 at r1 (raw file):

* **Breaking Changes**
  * refactor `Read` to return `ReadResult`; remove `ResultSet` (#935)
  * removed `std::tuple<>` from mutations API (#938). Removes the `AddRow(std::tuple<Ts...>)`

This is probably a search&replace error, the release notes for previous versions should not change.


google/cloud/spanner/integration_tests/client_integration_test.cc, line 622 at r1 (raw file):

      EXPECT_STATUS_OK(row);
      if (!row) break;
      std::vector<Value> v;

FYI, this pattern to initialize a std::vector<Value> repeats 3 times here, should we refactor it?

@devjgm devjgm changed the title chore!: replaced Row<...> with std::tuple<...> refactor!: replaced Row<...> with std::tuple<...> Oct 18, 2019
@codecov
Copy link

codecov bot commented Oct 18, 2019

Codecov Report

Merging #967 into master will decrease coverage by 0.44%.
The diff coverage is 97.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #967      +/-   ##
==========================================
- Coverage    94.5%   94.06%   -0.45%     
==========================================
  Files          94      158      +64     
  Lines        3951    10294    +6343     
==========================================
+ Hits         3734     9683    +5949     
- Misses        217      611     +394
Impacted Files Coverage Δ
...ud/spanner/integration_tests/client_stress_test.cc 81.89% <ø> (ø)
.../spanner/integration_tests/throughput_benchmark.cc 72.07% <ø> (ø)
google/cloud/spanner/results.h 93.33% <ø> (ø) ⬆️
google/cloud/spanner/client.h 100% <ø> (ø) ⬆️
google/cloud/spanner/samples/mock_execute_query.cc 100% <ø> (ø) ⬆️
google/cloud/spanner/row_parser_test.cc 100% <100%> (ø)
...gle/cloud/spanner/internal/connection_impl_test.cc 93.49% <100%> (ø)
.../spanner/integration_tests/spanner_install_test.cc 78.72% <100%> (ø)
...anner/integration_tests/client_integration_test.cc 99.46% <100%> (ø)
google/cloud/spanner/client_test.cc 95.31% <100%> (ø)
... and 74 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2ef267...8f32801. Read the comment docs.

Copy link
Contributor Author

@devjgm devjgm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think refactor: is better. Changed.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @coryan)


google/cloud/spanner/README.md, line 24 at r1 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

This is probably a search&replace error, the release notes for previous versions should not change.

Oops! reverted. Yes, search-n-replace issue.


google/cloud/spanner/integration_tests/client_integration_test.cc, line 622 at r1 (raw file):

Previously, coryan (Carlos O'Ryan) wrote…

FYI, this pattern to initialize a std::vector<Value> repeats 3 times here, should we refactor it?

Yeah, I noticed and thought about this too. Here are the relevant trade offs that I considered.

  1. Each of these three cases happen to use a tuple with the exact same type. A std::tuple<int, string, string>. So we could write a helper function that accepts that specific type and returns a vector<Value>. But if any of these integration tests change the tuple type, the helper would no longer work.

  2. If we instead wrote a helper function that generically works for any std::tuple<...>, the helper function gets much more complicated. Probably more complicated than makes sense in a _test.cc file.

  3. We could just repeat the few lines in each place because it's probably what end-users would actually write, and it's easy to change if the tuple elements change.

Basically, option 2 didn't sound good to me. The helper would be more complicated than repeating these lines a few times.

Option 1 would be OK with me.

As you can see, I went with option 3, but I'm happy to go with option 1 if you prefer that one. Or an option 4 that I didn't consider.

Copy link
Member

@coryan coryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Whatever you decide to make clang-tidy happy is Okay with me.

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


google/cloud/spanner/integration_tests/client_integration_test.cc, line 622 at r1 (raw file):

Previously, devjgm (Greg Miller) wrote…

Yeah, I noticed and thought about this too. Here are the relevant trade offs that I considered.

  1. Each of these three cases happen to use a tuple with the exact same type. A std::tuple<int, string, string>. So we could write a helper function that accepts that specific type and returns a vector<Value>. But if any of these integration tests change the tuple type, the helper would no longer work.

  2. If we instead wrote a helper function that generically works for any std::tuple<...>, the helper function gets much more complicated. Probably more complicated than makes sense in a _test.cc file.

  3. We could just repeat the few lines in each place because it's probably what end-users would actually write, and it's easy to change if the tuple elements change.

Basically, option 2 didn't sound good to me. The helper would be more complicated than repeating these lines a few times.

Option 1 would be OK with me.

As you can see, I went with option 3, but I'm happy to go with option 1 if you prefer that one. Or an option 4 that I didn't consider.

SGTM.

Copy link
Contributor Author

@devjgm devjgm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Didn't see that tidy warning. Changed to emplace_back to quiet clang-tidy. I'll let the CI builds pass before submitting.

Reviewable status: 14 of 15 files reviewed, all discussions resolved (waiting on @coryan)

@devjgm devjgm merged commit b51367d into googleapis:master Oct 18, 2019
@devjgm devjgm deleted the select-star branch October 18, 2019 20:13
devjgm added a commit to devjgm/google-cloud-cpp that referenced this pull request May 7, 2020
…cloud-cpp-spanner#967)

This is a prefactoring (pre-refactoring) in preparatoin for googleapis/google-cloud-cpp-spanner#387, which will create a new non-templated Row class. This PR makes room for that new class, and leave most of the code looking like it will ultimately look: When a user wants a typed-Row, they will specify the row's type using std::tuple.

BREAKING CHANGE: Removes the Row<...> type.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants