Skip to content

Conversation

@olavloite
Copy link

@olavloite olavloite commented Mar 27, 2019

SpannerImpl has become quite long and difficult to read. This PR splits it into a number of logical parts.

The following new files have been added as a result of splitting SpannerImpl (all classes defined at top-level of these files are package-private):

  • AbstractReadContext.java: Contains the abstract base class of all com.google.cloud.spanner.ReadContext implementations, as well as all concrete implementations of read-only ReadContexts. Read-write transactions, that also implement ReadContext, are not included in this file.
  • AbstractResultSet.java: Contains the abstract base class for ResultSet implementations and the concrete implementation of GrpcResultSet (the ResultSet returned by database queries on Spanner).
  • DatabaseAdminClientImpl.java: The concrete implementation of DatabaseAdminClient. Used to be an inner class of SpannerImpl.
  • InstanceAdminClientImpl.java: The concrete implementation of InstanceAdminClient. Used to be an inner class of SpannerImpl.
  • PartitionedDmlTransaction.java: Implementation of partitioned DML transactions for Spanner. Used to be an inner class of SpannerImpl.
  • SessionImpl.java: Implementation of Session. Used to be an inner class of SpannerImpl.
  • TransactionRunnerImpl.java: Implemenation of TransactionRunner and TransactionContext. TransactionContext is also an implementation of ReadContext and a subclass of AbstractReadContext, but defined in this file as it is only used by 'TransactionRunnerImpl. Used to be an inner class of SpannerImpl`.

As a result of the above, SpannerImpl is reduced from more than 3,000 lines of code to approx 360 lines of code.

Changes to other files are a result of updated references (i.e. no longer referencing SpannerImpl.SessionImpl but SessionImpl), the need to pass in a reference to SpannerImpl or SpannerGrpc, the need to change private inner classes into package-private inner classes or the need to change private methods and final fields in SpannerImpl into package-private methods and final fields.

Clean up SpannerImpl by moving inner classes to separate files and group
these into logical units.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 27, 2019
@olavloite olavloite added the api: spanner Issues related to the Spanner API. label Mar 27, 2019
@codecov
Copy link

codecov bot commented Mar 27, 2019

Codecov Report

Merging #4749 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4749   +/-   ##
=========================================
  Coverage     49.62%   49.62%           
  Complexity    22779    22779           
=========================================
  Files          2168     2168           
  Lines        214157   214157           
  Branches      24253    24253           
=========================================
  Hits         106279   106279           
  Misses        99559    99559           
  Partials       8319     8319

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 8d02cf3...49f7ae6. Read the comment docs.

@sduskis sduskis added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 28, 2019
@@ -401,18 +326,9 @@ Object value() {
return ImmutableMap.copyOf(tmp);
}

private static <T extends Message> T unpack(Any response, Class<T> clazz)
Copy link
Author

Choose a reason for hiding this comment

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

This method was removed as it turned out that it was never used.

@olavloite olavloite changed the title [WIP] Spanner refactor spannerimpl Spanner: Refactor SpannerImpl.java Apr 1, 2019
@olavloite olavloite marked this pull request as ready for review April 1, 2019 09:07
@olavloite olavloite requested a review from a team as a code owner April 1, 2019 09:07
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 3, 2019
@sduskis sduskis added needs work This is a pull request that needs a little love. and removed 🚨 This issue needs some love. labels Apr 3, 2019
@olavloite
Copy link
Author

Replaced by separate PR's per change set.

@olavloite olavloite closed this Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API. cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing. needs work This is a pull request that needs a little love.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants