Skip to content

Spanner: Refactor SpannerImpl.java - #4749

Closed
olavloite wants to merge 3 commits into
googleapis:masterfrom
olavloite:spanner-refactor-spannerimpl
Closed

Spanner: Refactor SpannerImpl.java#4749
olavloite wants to merge 3 commits into
googleapis:masterfrom
olavloite:spanner-refactor-spannerimpl

Conversation

@olavloite

@olavloiteolavloite commented Mar 27, 2019

Copy link
Copy Markdown
Contributor

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-onlyReadContexts. 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.
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 27, 2019
@olavloiteolavloite added the api: spanner Issues related to the Spanner API. label Mar 27, 2019
@codecov

codecovBot commented Mar 27, 2019

Copy link
Copy Markdown

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.

@sduskissduskis 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
Copy Markdown
ContributorAuthor

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.

@olavloiteolavloite changed the title [WIP] Spanner refactor spannerimplSpanner: Refactor SpannerImpl.javaApr 1, 2019
@olavloite
olavloite marked this pull request as ready for review April 1, 2019 09:07
@olavloite
olavloite requested a review from a teamApril 1, 2019 09:07
@yoshi-automationyoshi-automation added the 🚨 critical P0 critical issue. Requires immediate fix label Apr 3, 2019
@sduskissduskis added needs work This is a pull request that needs a little love. and removed 🚨 critical P0 critical issue. Requires immediate fix labels Apr 3, 2019
@olavloite

Copy link
Copy Markdown
ContributorAuthor

Replaced by separate PR's per change set.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spannerIssues related to the Spanner API.cla: yesThis human has signed the Contributor License Agreement.do not mergeIndicates a pull request not ready for merge, due to either quality or timing.needs workThis is a pull request that needs a little love.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@olavloite@sduskis@googlebot@yoshi-automation