-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add arbitrary filtering for get operations #1834
Conversation
DistributedTransaction transaction = | ||
manager.begin(Isolation.SERIALIZABLE, SerializableStrategy.EXTRA_READ); |
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.
I first created a bug regarding the extra read with get operations since I missed that integration tests are done with snapshot isolation by default, and this setting should be added in some cases.
Note that we might also be better to use SERIALIZABLE
for some other tests (e.g., get_GetGivenForCommittedRecord_ShouldReturnRecord
) because they are almost the same as the one in DistributedTransactionIntegrationTestBase
if we run them with SNAPSHOT
. However, I left it as is for now since it's a bit out of the scope of this PR.
@@ -51,6 +51,7 @@ public class Snapshot { | |||
private final TransactionTableMetadataManager tableMetadataManager; | |||
private final ParallelExecutor parallelExecutor; | |||
private final ConcurrentMap<Key, Optional<TransactionResult>> readSet; | |||
private final Map<Get, Key> getSet; |
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.
Because we need to add the where clause into the Get
operation for the extra read, as below, we start managing the issued Get
operations similar to Scan
.
@@ -1582,83 +1580,4 @@ public BuildableScanFromExistingWithOngoingWhereAnd and(OrConditionSet orConditi | |||
return this; | |||
} | |||
} | |||
|
|||
private static class Where { |
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.
Moved to SelectionBuilder
to commonly use in both GetBuilder
and ScanBuilder
.
@@ -197,7 +197,7 @@ DistributedTransaction begin(String txId, Isolation isolation, SerializableStrat | |||
if (!config.getIsolation().equals(isolation) | |||
|| !config.getSerializableStrategy().equals(strategy)) { | |||
logger.warn( | |||
"Setting different isolation level or serializable strategy from the ones" | |||
"Setting different isolation level or serializable strategy from the ones " |
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.
Since it's very minor, I fixed it in this PR.
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.
LGTM, thank you.
|
||
public static class BuildableGetWithWhere extends BuildableGet { | ||
|
||
protected final SelectionBuilder.Where where; |
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.
[minor] This exposes the package-private Where
to classes that inherit this class. How about making this to package-private?
protected final SelectionBuilder.Where where; | |
final SelectionBuilder.Where where; |
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 catch, thank you! Fixed in 527d0b6.
BTW, I noticed that I can receive such warnings in IntelliJ by using a recent version. I'm using a bit old version due to some reasons, but I will migrate it : )
implements Consistency<BuildableGetWithIndexWhere>, Projection<BuildableGetWithIndexWhere> { | ||
|
||
protected BuildableGetWithIndex buildableGetWithIndex; | ||
protected final SelectionBuilder.Where where; |
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.
Same as above
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.
Fixed in 527d0b6.
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.
LGTM! 👍
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.
I've left some minor suggestions. Other than that, LGTM. Thank you!🙇🏻♂️
GET_BUILD_ERROR_OPERATION_SUPPORTED_ONLY_WHEN_NO_CONDITIONS_ARE_SPECIFIED( | ||
Category.USER_ERROR, | ||
"0141", | ||
"This operation is supported only when no conditions are specified at all. " |
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 operation is supported only when no conditions are specified at all. " | |
"This operation is supported only when no conditions are specified. " |
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.
Thank you for the feedback. Fixed in e9840a9, including a similar message for the scan operation.
Category.USER_ERROR, | ||
"0141", | ||
"This operation is supported only when no conditions are specified at all. " | ||
+ "If you want to modify the condition, please use clearConditions() to remove all existing conditions first", |
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.
+ "If you want to modify the condition, please use clearConditions() to remove all existing conditions first", | |
+ "If you want to modify a condition, please use clearConditions() to remove all existing conditions first", |
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.
Ditto, fixed in e9840a9.
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.
Overall, looking good to me!
Left one minor comment. PTAL!
@@ -133,6 +133,11 @@ public Get withProjections(Collection<String> projections) { | |||
return (Get) super.withProjections(projections); | |||
} | |||
|
|||
@Override | |||
Get withConjunctions(Collection<Conjunction> conjunctions) { |
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.
Should we add conjunctions
to the toString()
method?
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 catch, thank you! Fixed in e9840a9.
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.
Left a minor comment, but other than that, LGTM! Thank you!
core/import_schema.json
Outdated
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.
It looks like this file is unnecessary?
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.
Sorry, my bad. Removed in d6d6475.
@feeblefakie PTAL again when you get a chance. I will submit the following two related PRs once this is merged. Thank you!
|
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.
LGTM! Thank you!
Description
This PR adds arbitrary filtering for get operations.
Related issues and/or PRs
Changes made
where()
clause inGetBuilder
, as the same asScanBuilder
.Snapshot
to manage the issuedGet
operations so that it can re-read with the where clause in the extra read.Checklist
Additional notes (optional)
See inline comments.
Release notes
Added support for arbitrary filtering for get operations.