-
Notifications
You must be signed in to change notification settings - Fork 138
chore: add routing hints and cache updates for begin/commit #4392
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
Changes from all commits
82c3244
3c99d2a
e836a5d
0f39595
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,9 +158,7 @@ public void computeKeys(ReadRequest.Builder reqBuilder) { | |
| long reqFp = fingerprint(reqBuilder.buildPartial()); | ||
|
|
||
| RoutingHint.Builder hintBuilder = reqBuilder.getRoutingHintBuilder(); | ||
| if (!schemaGeneration.isEmpty()) { | ||
| hintBuilder.setSchemaGeneration(schemaGeneration); | ||
| } | ||
| applySchemaGeneration(hintBuilder); | ||
|
|
||
| PreparedRead preparedRead = getIfPresent(preparedReads, reqFp); | ||
| if (preparedRead == null) { | ||
|
|
@@ -186,10 +184,7 @@ public void computeKeys(ReadRequest.Builder reqBuilder) { | |
|
|
||
| try { | ||
| TargetRange target = recipe.keySetToTargetRange(reqBuilder.getKeySet()); | ||
| hintBuilder.setKey(target.start); | ||
| if (!target.limit.isEmpty()) { | ||
| hintBuilder.setLimitKey(target.limit); | ||
| } | ||
| applyTargetRange(hintBuilder, target); | ||
| } catch (IllegalArgumentException e) { | ||
| logger.fine("Failed key encoding: " + e.getMessage()); | ||
| } | ||
|
|
@@ -199,9 +194,7 @@ public void computeKeys(ExecuteSqlRequest.Builder reqBuilder) { | |
| long reqFp = fingerprint(reqBuilder.buildPartial()); | ||
|
|
||
| RoutingHint.Builder hintBuilder = reqBuilder.getRoutingHintBuilder(); | ||
| if (!schemaGeneration.isEmpty()) { | ||
| hintBuilder.setSchemaGeneration(schemaGeneration); | ||
| } | ||
| applySchemaGeneration(hintBuilder); | ||
|
|
||
| PreparedQuery preparedQuery = getIfPresent(preparedQueries, reqFp); | ||
| if (preparedQuery == null) { | ||
|
|
@@ -221,15 +214,25 @@ public void computeKeys(ExecuteSqlRequest.Builder reqBuilder) { | |
|
|
||
| try { | ||
| TargetRange target = recipe.queryParamsToTargetRange(reqBuilder.getParams()); | ||
| hintBuilder.setKey(target.start); | ||
| if (!target.limit.isEmpty()) { | ||
| hintBuilder.setLimitKey(target.limit); | ||
| } | ||
| applyTargetRange(hintBuilder, target); | ||
| } catch (IllegalArgumentException e) { | ||
| logger.fine("Failed query param encoding: " + e.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| void applySchemaGeneration(RoutingHint.Builder hintBuilder) { | ||
| if (!schemaGeneration.isEmpty()) { | ||
| hintBuilder.setSchemaGeneration(schemaGeneration); | ||
|
Collaborator
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. This updates the hint builder, but the method might still return false if the |
||
| } | ||
| } | ||
|
|
||
| void applyTargetRange(RoutingHint.Builder hintBuilder, TargetRange target) { | ||
| hintBuilder.setKey(target.start); | ||
| if (!target.limit.isEmpty()) { | ||
| hintBuilder.setLimitKey(target.limit); | ||
| } | ||
| } | ||
|
|
||
| public TargetRange mutationToTargetRange(Mutation mutation) { | ||
| if (mutation == null) { | ||
| return null; | ||
|
|
||
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
getOrCreateChannelFindernever returns null, the null check forfinderis redundant. You can combine these twoifstatements for better readability and conciseness.