-
Notifications
You must be signed in to change notification settings - Fork 58
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 binary string support for java client for sorted set commands #1648
Conversation
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.
Add IT
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
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.
Instead of duplicating all classes, consider adding new method toBinaryArgs
to all existing. That will cause smaller changes.
Update docs in SortedSetBaseCommands.java
if you do that.
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.
The reason I didn't create one class that supports toArgs and toArgsBinary is because this makes the usage more implicit. For example, each class will need a constructor with regular strings and a constructor with GlideStrings. If the user uses the GlideString constructor and then calls toArgs instead of toArgsBinary he could get unexpected results. So I think it is better to separate the logic.
Of course there tradeoffs and both implementations have their pros and cons.
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
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.
Too many changes for 1 PR
Try to split
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
The reason I had to add changes to this PR is because I needed functions/interfaces that I created in the original PR to implement z* commands. The reason I didn't create one class that supports |
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
Added IT |
IT are added, but I can't validate anything above that. The PR is too huge. |
MAX; | ||
|
||
public GlideString[] toArgs() { | ||
return new GlideString[] {gs(AGGREGATE_REDIS_API), gs(toString())}; |
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.
What does toString() do here? Same in String implementation
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
arguments = concatenateArrays(arguments, new GlideString[] {gs("REV")}); | ||
} | ||
|
||
if (rangeQuery.getLimit() != 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.
nit: use ArgsBuilder
for smaller code footprint
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/WeightAggregateOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/WeightAggregateOptions.java
Outdated
Show resolved
Hide resolved
@@ -139,11 +157,12 @@ public GlideString[] toArgs() { | |||
keys.add(entry.getLeft()); | |||
weights.add(entry.getRight()); | |||
} | |||
argumentsList.add(GlideString.of(keys.size())); | |||
|
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.
You can use ArgsBuilder
- this will reduce the code overhead you have here
* | ||
* @return GlideString[] | ||
*/ | ||
public GlideString[] toArgsBinary() { |
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.
Function public GlideString[] toArgsBinary()
could be implemented using this one-liner:
public GlideString[] toArgsBinary() { return new ArgsBuilder().add(toArgs()).toArray(); }
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/RangeOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/ZAddOptions.java
Outdated
Show resolved
Hide resolved
c58ae4c
to
2eb51e2
Compare
Add Java client support for GlideString (binary safe string) in the commands: zrevrank, zrevrankWithScore,zremrangebyscore, zremrangebylex, zrange, zrangestore, zrandmember, zlexcounter, zinterstore, zinter, zdiff, zcount, zadd.