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
feat!: add CommitStats to Connection API #608
Merged
Merged
Changes from 8 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
3872199
feat!: add support for CommitStats
olavloite def8768
fix: add clirr ignored differences
olavloite 5372dae
Merge branch 'master' into commit-stats2
olavloite 34fbda6
fix: error message should start with getCommitResponse
olavloite 8f61c2a
Merge branch 'master' into commit-stats2
olavloite 47b57ea
feat: add CommitStats to Connection API
olavloite a9014bc
fix: combine commit timestamp and response methods
olavloite 1063ced
fix: clirr-diff and add some tests
olavloite 2f56c29
fix: remove profile change from this PR
olavloite 041b34d
Merge branch 'master' into commit-stats2
olavloite df7273a
Merge branch 'master' into connection-api-commit-stats
olavloite 8299054
fix: remove overload delay
olavloite 9b710a7
Merge branch 'master' into commit-stats2
olavloite 9a2e555
Merge branch 'master' into connection-api-commit-stats
olavloite 57a10a8
fix: remove overload delay
olavloite 88c2d83
Merge branch 'commit-stats2' into connection-api-commit-stats
olavloite 043555d
fix: fix test failure
olavloite 8c15641
Merge branch 'master' into commit-stats2
olavloite 919cf02
chore: cleanup after merge
olavloite 97ec917
fix: update copyright years of new files
olavloite afeb0fd
test: fix flaky test
olavloite 8524526
test: skip commit stats tests on emulator
olavloite 06b3e22
test: missed one commit stats tests against emulator
olavloite 1c17d16
test: skip another emulator test
olavloite 664b87d
test: add missing test cases
olavloite 6573a0f
fix: address review comments
olavloite 0b448c3
Merge branch 'master' into commit-stats2
olavloite 83039fb
Merge branch 'master' into commit-stats2
olavloite 57ea714
chore: use junit assertion instead of truth
olavloite 74f5951
Merge branch 'master' into connection-api-commit-stats
olavloite 1b077e4
chore: cleanup after merge
olavloite ea061f8
Merge branch 'commit-stats2' into connection-api-commit-stats
olavloite 51fb048
fix: address review comments
olavloite 66c5f88
chore: replace truth asserts with junit asserts
olavloite bd9bf11
Merge branch 'commit-stats2' into connection-api-commit-stats
olavloite b351d08
test: skip CommitStats integration tests on emulator
olavloite da0e434
fix: address review comments
olavloite 1d17973
chore: replace truth assertions with junit
olavloite a2531cb
Merge branch 'commit-stats2' into connection-api-commit-stats
olavloite c01152d
test: add additional tests + replace truth with junit assertions
olavloite bf0a7bd
fix: fix wrong error code
olavloite 48ef21b
chore: cleanup test and variable names
olavloite 1f33c42
fix: rename test method and variables
olavloite 7d45ace
fix: address review comments
olavloite fcb9eda
Merge branch 'commit-stats2' into connection-api-commit-stats
olavloite 682b849
Merge branch 'master' into connection-api-commit-stats
olavloite 0e341a9
chore: remove unnecessary changes + JUnit assertions
olavloite 7540c31
fix: remove reference to overload_delay
olavloite f86255e
chore: address review comments
olavloite File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,20 +17,36 @@ | |
package com.google.cloud.spanner; | ||
|
||
import com.google.cloud.Timestamp; | ||
import com.google.common.base.Preconditions; | ||
import java.util.Objects; | ||
|
||
/** Represents a response from a commit operation. */ | ||
public class CommitResponse { | ||
|
||
private final Timestamp commitTimestamp; | ||
private final com.google.spanner.v1.CommitResponse proto; | ||
|
||
public CommitResponse(Timestamp commitTimestamp) { | ||
this.commitTimestamp = commitTimestamp; | ||
CommitResponse(com.google.spanner.v1.CommitResponse proto) { | ||
this.proto = proto; | ||
} | ||
|
||
/** Returns a {@link Timestamp} representing the commit time of the write operation. */ | ||
/** Returns a {@link Timestamp} representing the commit time of the transaction. */ | ||
public Timestamp getCommitTimestamp() { | ||
return commitTimestamp; | ||
return Timestamp.fromProto(proto.getCommitTimestamp()); | ||
} | ||
|
||
/** @return true if the {@link CommitResponse} includes {@link CommitStats}. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: no period There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
public boolean hasCommitStats() { | ||
olavloite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return proto.hasCommitStats(); | ||
} | ||
|
||
/** | ||
* Commit statistics are returned by a read/write transaction if specifically requested by passing | ||
* in {@link Options#commitStats()} to the transaction. | ||
*/ | ||
public CommitStats getCommitStats() { | ||
Preconditions.checkState( | ||
proto.hasCommitStats(), "The CommitResponse does not contain any commit statistics."); | ||
return CommitStats.fromProto(proto.getCommitStats()); | ||
} | ||
|
||
@Override | ||
|
@@ -42,11 +58,11 @@ public boolean equals(Object o) { | |
return false; | ||
} | ||
CommitResponse that = (CommitResponse) o; | ||
return Objects.equals(commitTimestamp, that.commitTimestamp); | ||
return Objects.equals(proto, that.proto); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(commitTimestamp); | ||
return Objects.hash(proto); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 was a missing piece of configuration that was still in the JDBC repository, but that belongs in the Connection API. It is a Maven profile for automatically generating tests for new client side SQL statements.
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.
Could we add this as a separate PR? Otherwise we won't have this until the commit stats is merged into master.
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.
Good point, I've added #611 for that, and I'll remove it from this PR.