-
Notifications
You must be signed in to change notification settings - Fork 125
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 support for CommitStats #544
Merged
Merged
Changes from all commits
Commits
Show all changes
25 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 041b34d
Merge branch 'master' into commit-stats2
olavloite 8299054
fix: remove overload delay
olavloite 9b710a7
Merge branch 'master' into commit-stats2
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 66c5f88
chore: replace truth asserts with junit asserts
olavloite 1d17973
chore: replace truth assertions with junit
olavloite 48ef21b
chore: cleanup test and variable names
olavloite 1f33c42
fix: rename test method and variables
olavloite 7d45ace
fix: address review comments
olavloite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
54 changes: 54 additions & 0 deletions
54
google-cloud-spanner/src/main/java/com/google/cloud/spanner/CommitStats.java
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.spanner; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
/** | ||
* Commit statistics are returned by a read/write transaction if specifically requested by passing | ||
* in {@link Options#commitStats()} to the transaction. | ||
*/ | ||
public class CommitStats { | ||
private final long mutationCount; | ||
|
||
private CommitStats(long mutationCount) { | ||
this.mutationCount = mutationCount; | ||
} | ||
|
||
static CommitStats fromProto(com.google.spanner.v1.CommitResponse.CommitStats proto) { | ||
Preconditions.checkNotNull(proto); | ||
return new CommitStats(proto.getMutationCount()); | ||
} | ||
|
||
/** | ||
* The number of mutations that were executed by the transaction. Insert and update operations | ||
* count with the multiplicity of the number of columns they affect. For example, inserting a new | ||
* record may count as five mutations, if values are inserted into five columns. Delete and delete | ||
* range operations count as one mutation regardless of the number of columns affected. Deleting a | ||
* row from a parent table that has the ON DELETE CASCADE annotation is also counted as one | ||
* mutation regardless of the number of interleaved child rows present. The exception to this is | ||
* if there are secondary indexes defined on rows being deleted, then the changes to the secondary | ||
* indexes are counted individually. For example, if a table has 2 secondary indexes, deleting a | ||
* range of rows in the table counts as 1 mutation for the table, plus 2 mutations for each row | ||
* that is deleted because the rows in the secondary index might be scattered over the key-space, | ||
* making it impossible for Cloud Spanner to call a single delete range operation on the secondary | ||
* indexes. Secondary indexes include the foreign keys backing indexes. | ||
*/ | ||
public long getMutationCount() { | ||
return mutationCount; | ||
} | ||
} |
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
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.
letting it slide because it isn't changed in this PR, but catching Throwable is only rarely what you want. This is probably worth filing a bug on.
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.
Added issue: #875