-
Notifications
You must be signed in to change notification settings - Fork 69
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 NOSCORES option to ZSCAN & NOVALUES option to HSCAN #2174
Changes from all commits
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.models.commands.scan; | ||
|
||
import static glide.api.models.GlideString.gs; | ||
|
||
import glide.api.commands.HashBaseCommands; | ||
import glide.api.models.GlideString; | ||
import glide.utils.ArgsBuilder; | ||
import java.util.Arrays; | ||
import lombok.Builder; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
/** | ||
|
@@ -11,4 +17,36 @@ | |
* @see <a href="https://valkey.io/commands/hscan/">valkey.io</a> | ||
*/ | ||
@SuperBuilder | ||
public class HScanOptionsBinary extends BaseScanOptionsBinary {} | ||
public class HScanOptionsBinary extends BaseScanOptionsBinary { | ||
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 class add nothing new comparing to 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. I am leaving it for consistency, and it might change in the future |
||
/** Option string to include in the HSCAN command when values are not included. */ | ||
public static final GlideString NO_VALUES_API = gs("NOVALUES"); | ||
|
||
/** | ||
* When set to true, the command will not include values in the results. This option is available | ||
* from Valkey version 8.0.0 and above. | ||
*/ | ||
@Builder.Default protected boolean noValues = false; | ||
|
||
/** | ||
* Creates the arguments to be used in <code>ZSCAN</code> commands. | ||
* | ||
* @return a String array that holds the options and their arguments. | ||
*/ | ||
@Override | ||
public String[] toArgs() { | ||
ArgsBuilder builder = new ArgsBuilder(); | ||
|
||
// Add options from the superclass | ||
String[] superArgs = super.toArgs(); | ||
for (String arg : superArgs) { | ||
builder.add(arg); | ||
} | ||
|
||
// Add the noValues option if applicable | ||
if (noValues) { | ||
builder.add(NO_VALUES_API.toString()); | ||
} | ||
|
||
return Arrays.stream(builder.toArray()).map(GlideString::getString).toArray(String[]::new); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,14 @@ | ||||||
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ | ||||||
package glide.api.models.commands.scan; | ||||||
|
||||||
import static glide.api.models.GlideString.gs; | ||||||
|
||||||
import glide.api.commands.SortedSetBaseCommands; | ||||||
import glide.api.models.GlideString; | ||||||
import glide.utils.ArgsBuilder; | ||||||
import java.util.Arrays; | ||||||
import lombok.Builder; | ||||||
import lombok.EqualsAndHashCode; | ||||||
import lombok.experimental.SuperBuilder; | ||||||
|
||||||
/** | ||||||
|
@@ -11,4 +18,37 @@ | |||||
* @see <a href="https://valkey.io/commands/zscan/">valkey.io</a> | ||||||
*/ | ||||||
@SuperBuilder | ||||||
public class ZScanOptionsBinary extends BaseScanOptionsBinary {} | ||||||
@EqualsAndHashCode(callSuper = false) | ||||||
public class ZScanOptionsBinary extends BaseScanOptionsBinary { | ||||||
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. same here |
||||||
/** Option string to include in the ZSCAN command when scores are not included. */ | ||||||
public static final GlideString NO_SCORES_API = gs("NOSCORES"); | ||||||
|
||||||
/** | ||||||
* When set to true, the command will not include scores in the results. This option is available | ||||||
* from Redis version 8.0.0 and above. | ||||||
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.
Suggested change
|
||||||
*/ | ||||||
@Builder.Default protected boolean noScores = false; | ||||||
|
||||||
/** | ||||||
* Creates the arguments to be used in <code>ZSCAN</code> commands. | ||||||
* | ||||||
* @return a String array that holds the options and their arguments. | ||||||
*/ | ||||||
@Override | ||||||
public String[] toArgs() { | ||||||
ArgsBuilder builder = new ArgsBuilder(); | ||||||
|
||||||
// Add options from the superclass | ||||||
String[] superArgs = super.toArgs(); | ||||||
for (String arg : superArgs) { | ||||||
builder.add(arg); | ||||||
} | ||||||
|
||||||
// Add the noScores option if applicable | ||||||
if (noScores) { | ||||||
builder.add(NO_SCORES_API.toString()); | ||||||
} | ||||||
|
||||||
return Arrays.stream(builder.toArray()).map(GlideString::getString).toArray(String[]::new); | ||||||
} | ||||||
} |
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 this
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 same for zscan options
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.
Actually, you can do
noValuesOptions
(or so) class, which would be inherited by hscan opts and zscan opts, so you can avoid code duplicating