-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spanner: Refactor SpannerImpl.java #4749
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
Spanner: Refactor SpannerImpl.java #4749
Conversation
Clean up SpannerImpl by moving inner classes to separate files and group these into logical units.
Codecov Report
@@ 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 8319Continue to review full report at Codecov.
|
| @@ -401,18 +326,9 @@ Object value() { | |||
| return ImmutableMap.copyOf(tmp); | |||
| } | |||
|
|
|||
| private static <T extends Message> T unpack(Any response, Class<T> clazz) | |||
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.
This method was removed as it turned out that it was never used.
|
Replaced by separate PR's per change set. |
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 allcom.google.cloud.spanner.ReadContextimplementations, as well as all concrete implementations of read-onlyReadContexts. Read-write transactions, that also implementReadContext, are not included in this file.AbstractResultSet.java: Contains the abstract base class forResultSetimplementations and the concrete implementation ofGrpcResultSet(theResultSetreturned by database queries on Spanner).DatabaseAdminClientImpl.java: The concrete implementation ofDatabaseAdminClient. Used to be an inner class ofSpannerImpl.InstanceAdminClientImpl.java: The concrete implementation ofInstanceAdminClient. Used to be an inner class ofSpannerImpl.PartitionedDmlTransaction.java: Implementation of partitioned DML transactions for Spanner. Used to be an inner class ofSpannerImpl.SessionImpl.java: Implementation ofSession. Used to be an inner class ofSpannerImpl.TransactionRunnerImpl.java: Implemenation ofTransactionRunnerandTransactionContext.TransactionContextis also an implementation ofReadContextand a subclass ofAbstractReadContext, but defined in this file as it is only used by 'TransactionRunnerImpl. Used to be an inner class ofSpannerImpl`.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.SessionImplbutSessionImpl), 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.