Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shoham Elias <shohame@amazon.com>
  • Loading branch information
shohamazon committed Sep 5, 2024
1 parent b1cdc0b commit fdefbc4
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import glide.api.models.GlideString;
import glide.api.models.commands.scan.HScanOptions;
import glide.api.models.commands.scan.HScanOptions.HScanOptionsBuilder;
import glide.api.models.commands.scan.HScanOptionsBinary;
import glide.api.models.commands.scan.HScanOptionsBinary.HScanOptionsBinaryBuilder;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -695,8 +697,9 @@ public interface HashBaseCommands {
* cursor</code> for the next iteration of results. <code>"0"</code> will be the <code>cursor
* </code> returned on the last iteration of the result. The second element is always an
* <code>Array</code> of the subset of the hash held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the key is
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
* second element is a flattened series of <code>String</code> pairs, where the key is at even
* indices and the value is at odd indices. If {@link HScanOptionsBuilder#noValues} is set to
* <code>true
* </code>, the second element will only contain the fields without the values.
* @example
* <pre>{@code
Expand Down Expand Up @@ -732,8 +735,9 @@ public interface HashBaseCommands {
* cursor</code> for the next iteration of results. <code>"0"</code> will be the <code>cursor
* </code> returned on the last iteration of the result. The second element is always an
* <code>Array</code> of the subset of the hash held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the key is
* at even indices and the value is at odd indices. If options.noValues is set to <code>true
* second element is a flattened series of <code>String</code> pairs, where the key is at even
* indices and the value is at odd indices. If {@link HScanOptionsBinaryBuilder#noValues} is
* set to <code>true
* </code>, the second element will only contain the fields without the values.
* @example
* <pre>{@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import glide.api.models.commands.WeightAggregateOptions.WeightedKeys;
import glide.api.models.commands.ZAddOptions;
import glide.api.models.commands.scan.ZScanOptions;
import glide.api.models.commands.scan.ZScanOptions.ZScanOptionsBuilder;
import glide.api.models.commands.scan.ZScanOptionsBinary;
import glide.api.models.commands.scan.ZScanOptionsBinary.ZScanOptionsBinaryBuilder;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -2789,8 +2791,9 @@ CompletableFuture<Map<GlideString, Double>> zinterWithScores(
* </code> returned on the last iteration of the sorted set. The second element is always an
* <code>
* Array</code> of the subset of the sorted set held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the value
* is at even indices and the score is at odd indices. If options.noScores is to <code>true
* second element is a flattened series of <code>String</code> pairs, where the value is at
* even indices and the score is at odd indices. If {@link ZScanOptionsBuilder#noScores} is to
* <code>true
* </code>, the second element will only contain the members without scores.
* @example
* <pre>{@code
Expand Down Expand Up @@ -2827,8 +2830,9 @@ CompletableFuture<Map<GlideString, Double>> zinterWithScores(
* </code> returned on the last iteration of the sorted set. The second element is always an
* <code>
* Array</code> of the subset of the sorted set held in <code>key</code>. The array in the
* second element is always a flattened series of <code>String</code> pairs, where the value
* is at even indices and the score is at odd indices. If options.noScores is to <code>true
* second element is a flattened series of <code>String</code> pairs, where the value is at
* even indices and the score is at odd indices. If {@link ZScanOptionsBinaryBuilder#noScores}
* is to <code>true
* </code>, the second element will only contain the members without scores.
* @example
* <pre>{@code
Expand Down
15 changes: 9 additions & 6 deletions java/client/src/main/java/glide/api/models/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@
import glide.api.models.commands.geospatial.GeoUnit;
import glide.api.models.commands.geospatial.GeospatialData;
import glide.api.models.commands.scan.HScanOptions;
import glide.api.models.commands.scan.HScanOptions.HScanOptionsBuilder;
import glide.api.models.commands.scan.SScanOptions;
import glide.api.models.commands.scan.ZScanOptions;
import glide.api.models.commands.scan.ZScanOptions.ZScanOptionsBuilder;
import glide.api.models.commands.stream.StreamAddOptions;
import glide.api.models.commands.stream.StreamAddOptions.StreamAddOptionsBuilder;
import glide.api.models.commands.stream.StreamClaimOptions;
Expand Down Expand Up @@ -7054,10 +7056,10 @@ public <ArgType> T zscan(@NonNull ArgType key, @NonNull ArgType cursor) {
* always the <code>cursor</code> for the next iteration of results. <code>"0"</code> will be
* the <code>cursor</code> returned on the last iteration of the sorted set. The second
* element is always an <code>Array</code> of the subset of the sorted set held in <code>key
* </code>. The array in the second element is always a flattened series of <code>String
* </code>. The array in the second element is a flattened series of <code>String
* </code> pairs, where the value is at even indices and the score is at odd indices. If
* options.noScores is to <code>true</code>, the second element will only contain the members
* without scores.
* {@link ZScanOptionsBuilder#noScores} is to <code>true</code>, the second element will only
* contain the members without scores.
*/
public <ArgType> T zscan(
@NonNull ArgType key, @NonNull ArgType cursor, @NonNull ZScanOptions zScanOptions) {
Expand Down Expand Up @@ -7103,9 +7105,10 @@ public <ArgType> T hscan(@NonNull ArgType key, @NonNull ArgType cursor) {
* always the <code>cursor</code> for the next iteration of results. <code>"0"</code> will be
* the <code>cursor</code> returned on the last iteration of the result. The second element is
* always an <code>Array</code> of the subset of the hash held in <code>key</code>. The array
* in the second element is always a flattened series of <code>String</code> pairs, where the
* key is at even indices and the value is at odd indices. If options.noValues is set to
* <code>true</code>, the second element will only contain the fields without the values.
* in the second element is a flattened series of <code>String</code> pairs, where the key is
* at even indices and the value is at odd indices. If {@link HScanOptionsBuilder#noValues} is
* set to <code>true</code>, the second element will only contain the fields without the
* values.
*/
public <ArgType> T hscan(
@NonNull ArgType key, @NonNull ArgType cursor, @NonNull HScanOptions hScanOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import glide.api.commands.HashBaseCommands;
import glide.api.models.GlideString;
import glide.api.models.commands.scan.BaseScanOptions.BaseScanOptionsBuilder;
import glide.utils.ArgsBuilder;
import java.util.Arrays;
import java.util.Objects;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;

/**
Expand All @@ -15,14 +16,15 @@
* @see <a href="https://valkey.io/commands/hscan/">valkey.io</a>
*/
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class HScanOptions extends BaseScanOptions {

/** Option string to include in the HSCAN command when values are not included. */
public static final String NO_VALUES_API = "NOVALUES";

/**
* When set to true, the command will not include values in the results. This option is available
* from Redis version 8.0.0 and above.
* from Valkey version 8.0.0 and above.
*/
@Builder.Default protected boolean noValues = false;

Expand Down Expand Up @@ -54,12 +56,16 @@ public GlideString[] toGlideStringArgs() {
return builder.toArray();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof HScanOptions)) return false;
if (!super.equals(o)) return false;
HScanOptions that = (HScanOptions) o;
return Objects.equals(noValues, that.noValues);
public abstract static class HScanOptionsBuilder<
C extends HScanOptions, B extends HScanOptionsBuilder<C, B>>
extends BaseScanOptionsBuilder<C, B> {

protected boolean noValues = false;

/** Option string to include in the HSCAN command when values are not included. */
public B noValues() {
this.noValues = true;
return self();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import glide.api.commands.HashBaseCommands;
import glide.api.models.GlideString;
import glide.api.models.commands.scan.BaseScanOptionsBinary.BaseScanOptionsBinaryBuilder;
import glide.utils.ArgsBuilder;
import java.util.Arrays;
import java.util.Objects;
import lombok.Builder;
import lombok.experimental.SuperBuilder;

Expand All @@ -24,7 +24,7 @@ public class HScanOptionsBinary extends BaseScanOptionsBinary {

/**
* When set to true, the command will not include values in the results. This option is available
* from Redis version 8.0.0 and above.
* from Valkey version 8.0.0 and above.
*/
@Builder.Default protected boolean noValues = false;

Expand All @@ -51,12 +51,16 @@ public String[] toArgs() {
return Arrays.stream(builder.toArray()).map(GlideString::getString).toArray(String[]::new);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ZScanOptionsBinary)) return false;
if (!super.equals(o)) return false;
HScanOptionsBinary that = (HScanOptionsBinary) o;
return Objects.equals(noValues, that.noValues);
public abstract static class HScanOptionsBinaryBuilder<
C extends HScanOptionsBinary, B extends HScanOptionsBinaryBuilder<C, B>>
extends BaseScanOptionsBinaryBuilder<C, B> {

protected boolean noValues = false;

/** Option string to include in the HSCAN command when values are not included. */
public B noValues() {
this.noValues = true;
return self();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import glide.api.commands.SortedSetBaseCommands;
import glide.api.models.GlideString;
import glide.api.models.commands.scan.BaseScanOptions.BaseScanOptionsBuilder;
import glide.utils.ArgsBuilder;
import java.util.Arrays;
import java.util.Objects;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;

/**
Expand All @@ -15,14 +16,15 @@
* @see <a href="https://valkey.io/commands/zscan/">valkey.io</a>
*/
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class ZScanOptions extends BaseScanOptions {

/** Option string to include in the ZSCAN command when scores are not included. */
public static final String NO_SCORES_API = "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.
* from Valkey version 8.0.0 and above.
*/
@Builder.Default protected boolean noScores = false;

Expand Down Expand Up @@ -54,12 +56,15 @@ public GlideString[] toGlideStringArgs() {
return builder.toArray();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ZScanOptions)) return false;
if (!super.equals(o)) return false;
ZScanOptions that = (ZScanOptions) o;
return Objects.equals(noScores, that.noScores);
public abstract static class ZScanOptionsBuilder<
C extends ZScanOptions, B extends ZScanOptionsBuilder<C, B>>
extends BaseScanOptionsBuilder<C, B> {
protected boolean noScores = false;

/** Option string to include in the ZSCAN command when scores are not included. */
public B noScores() {
this.noScores = true;
return self();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

import glide.api.commands.SortedSetBaseCommands;
import glide.api.models.GlideString;
import glide.api.models.commands.scan.BaseScanOptionsBinary.BaseScanOptionsBinaryBuilder;
import glide.utils.ArgsBuilder;
import java.util.Arrays;
import java.util.Objects;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;

/**
Expand All @@ -18,6 +19,7 @@
* @see <a href="https://valkey.io/commands/zscan/">valkey.io</a>
*/
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class ZScanOptionsBinary extends BaseScanOptionsBinary {
/** Option string to include in the ZSCAN command when scores are not included. */
public static final GlideString NO_SCORES_API = gs("NOSCORES");
Expand Down Expand Up @@ -51,12 +53,15 @@ public String[] toArgs() {
return Arrays.stream(builder.toArray()).map(GlideString::getString).toArray(String[]::new);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ZScanOptionsBinary)) return false;
if (!super.equals(o)) return false;
ZScanOptionsBinary that = (ZScanOptionsBinary) o;
return Objects.equals(noScores, that.noScores);
public abstract static class ZScanOptionsBinaryBuilder<
C extends ZScanOptionsBinary, B extends ZScanOptionsBinaryBuilder<C, B>>
extends BaseScanOptionsBinaryBuilder<C, B> {
protected boolean noScores = false;

/** Option string to include in the ZSCAN command when scores are not included. */
public B noScores() {
this.noScores = true;
return self();
}
}
}
6 changes: 2 additions & 4 deletions java/integTest/src/test/java/glide/SharedCommandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -14195,8 +14195,7 @@ public void zscan(BaseClient client) {
assertTrue(ArrayUtils.getLength(result[resultCollectionIndex]) >= 0);

if (SERVER_VERSION.isGreaterThanOrEqualTo("7.9.0")) {
result =
client.zscan(key1, initialCursor, ZScanOptions.builder().noScores(true).build()).get();
result = client.zscan(key1, initialCursor, ZScanOptions.builder().noScores().build()).get();
assertTrue(Long.parseLong(result[resultCursorIndex].toString()) >= 0);
// Cast the result collection to a String array
Object[] fieldsArray = (Object[]) result[resultCollectionIndex];
Expand Down Expand Up @@ -14589,8 +14588,7 @@ public void hscan(BaseClient client) {
assertTrue(ArrayUtils.getLength(result[resultCollectionIndex]) >= 0);

if (SERVER_VERSION.isGreaterThanOrEqualTo("7.9.0")) {
result =
client.hscan(key1, initialCursor, HScanOptions.builder().noValues(true).build()).get();
result = client.hscan(key1, initialCursor, HScanOptions.builder().noValues().build()).get();
assertTrue(Long.parseLong(result[resultCursorIndex].toString()) >= 0);
// Cast the result collection to a String array
Object[] fieldsArray = (Object[]) result[resultCollectionIndex];
Expand Down
4 changes: 4 additions & 0 deletions node/npm/glide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function initialize() {
const {
AggregationType,
BaseScanOptions,
ZScanOptions,
HScanOptions,
BitEncoding,
BitFieldGet,
BitFieldIncrBy,
Expand Down Expand Up @@ -185,6 +187,8 @@ function initialize() {
module.exports = {
AggregationType,
BaseScanOptions,
HScanOptions,
ZScanOptions,
BitEncoding,
BitFieldGet,
BitFieldIncrBy,
Expand Down
Loading

0 comments on commit fdefbc4

Please sign in to comment.