-
Notifications
You must be signed in to change notification settings - Fork 40
Add scanner API to transaction abstraction #2729
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
da1cb57
Add getScanner() method to transaction interfaces (#2698)
brfrn169 29ca31b
Merge branch 'master' into add-scanner-api-to-transaction-abstraction
brfrn169 8ea08fa
Implement scanner API for single CRUD transactions (#2701)
brfrn169 5042c49
Implement scanner API for JDBC transactions (#2702)
brfrn169 e4db961
Merge branch 'master' into add-scanner-api-to-transaction-abstraction
brfrn169 7b91326
Implement scanner API for Consensus Commit (#2711)
brfrn169 9ad1219
Add more integration tests for scanner API (#2724)
brfrn169 7ab8b65
Merge branch 'master' into add-scanner-api-to-transaction-abstraction
brfrn169 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
2 changes: 1 addition & 1 deletion
2
...rc/integration-test/java/com/scalar/db/storage/cassandra/ConsensusCommitCassandraEnv.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
core/src/integration-test/java/com/scalar/db/storage/cosmos/ConsensusCommitCosmosEnv.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
core/src/integration-test/java/com/scalar/db/storage/dynamo/ConsensusCommitDynamoEnv.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
core/src/integration-test/java/com/scalar/db/storage/jdbc/ConsensusCommitJdbcEnv.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...r/db/storage/multistorage/ConsensusCommitNullMetadataIntegrationTestWithMultiStorage.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...calar/db/storage/multistorage/ConsensusCommitSpecificIntegrationTestWithMultiStorage.java
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,18 @@ Optional<Result> get(Get get) | |||||
| List<Result> scan(Scan scan) | ||||||
| throws CrudConflictException, CrudException, UnknownTransactionStatusException; | ||||||
|
|
||||||
| /** | ||||||
| * {@inheritDoc} | ||||||
| * | ||||||
| * @throws CrudConflictException if the transaction CRUD operation fails due to transient faults | ||||||
| * (e.g., a conflict error). You can retry the transaction from the beginning | ||||||
| * @throws CrudException if the transaction CRUD operation fails due to transient or nontransient | ||||||
| * faults. You can try retrying the transaction from the beginning, but the transaction may | ||||||
| * still fail if the cause is nontranient | ||||||
|
||||||
| * still fail if the cause is nontranient | |
| * still fail if the cause is nontransient |
61 changes: 61 additions & 0 deletions
61
core/src/main/java/com/scalar/db/common/AbstractCrudOperableScanner.java
This file contains hidden or 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,61 @@ | ||
| package com.scalar.db.common; | ||
|
|
||
| import com.google.errorprone.annotations.concurrent.LazyInit; | ||
| import com.scalar.db.api.CrudOperable; | ||
| import com.scalar.db.api.Result; | ||
| import com.scalar.db.exception.transaction.TransactionException; | ||
| import java.util.Iterator; | ||
| import java.util.NoSuchElementException; | ||
| import java.util.Objects; | ||
| import javax.annotation.Nonnull; | ||
| import javax.annotation.concurrent.NotThreadSafe; | ||
|
|
||
| public abstract class AbstractCrudOperableScanner<E extends TransactionException> | ||
| implements CrudOperable.Scanner<E> { | ||
|
|
||
| @LazyInit private ScannerIterator scannerIterator; | ||
|
|
||
| @Override | ||
| @Nonnull | ||
| public Iterator<Result> iterator() { | ||
| if (scannerIterator == null) { | ||
| scannerIterator = new ScannerIterator(this); | ||
| } | ||
| return scannerIterator; | ||
| } | ||
|
|
||
| @NotThreadSafe | ||
| public class ScannerIterator implements Iterator<Result> { | ||
|
|
||
| private final CrudOperable.Scanner<E> scanner; | ||
| private Result next; | ||
|
|
||
| public ScannerIterator(CrudOperable.Scanner<E> scanner) { | ||
| this.scanner = Objects.requireNonNull(scanner); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasNext() { | ||
| if (next != null) { | ||
| return true; | ||
| } | ||
|
|
||
| try { | ||
| return (next = scanner.one().orElse(null)) != null; | ||
| } catch (TransactionException e) { | ||
| throw new RuntimeException(e.getMessage(), e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Result next() { | ||
| if (!hasNext()) { | ||
| throw new NoSuchElementException(); | ||
| } | ||
|
|
||
| Result ret = next; | ||
| next = null; | ||
| return ret; | ||
| } | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/com/scalar/db/common/AbstractTransactionCrudOperableScanner.java
This file contains hidden or 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,7 @@ | ||
| package com.scalar.db.common; | ||
|
|
||
| import com.scalar.db.api.TransactionCrudOperable; | ||
| import com.scalar.db.exception.transaction.CrudException; | ||
|
|
||
| public abstract class AbstractTransactionCrudOperableScanner | ||
| extends AbstractCrudOperableScanner<CrudException> implements TransactionCrudOperable.Scanner {} |
8 changes: 8 additions & 0 deletions
8
core/src/main/java/com/scalar/db/common/AbstractTransactionManagerCrudOperableScanner.java
This file contains hidden or 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,8 @@ | ||
| package com.scalar.db.common; | ||
|
|
||
| import com.scalar.db.api.TransactionManagerCrudOperable; | ||
| import com.scalar.db.exception.transaction.TransactionException; | ||
|
|
||
| public abstract class AbstractTransactionManagerCrudOperableScanner | ||
| extends AbstractCrudOperableScanner<TransactionException> | ||
| implements TransactionManagerCrudOperable.Scanner {} |
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.
Consider correcting the spelling of 'nontranient' to 'nontransient' in the documentation to improve clarity.