Skip to content

Commit

Permalink
Java: Allow uncovered slots ClusterScan (#2859)
Browse files Browse the repository at this point in the history
Java: Allow uncovered slots ClusterScan

---------

Signed-off-by: James Xin <[email protected]>
Co-authored-by: tjzhang-BQ <[email protected]>
  • Loading branch information
jamesx-improving and tjzhang-BQ authored Dec 24, 2024
1 parent 1304513 commit 9767ead
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#### Changes
* Node, Python: Add allow uncovered slots scanning flag option in cluster scan ([#2814](https://github.com/valkey-io/valkey-glide/pull/2814), [#2815](https://github.com/valkey-io/valkey-glide/pull/2815))
* Node, Python, Java: Add allow uncovered slots scanning flag option in cluster scan ([#2814](https://github.com/valkey-io/valkey-glide/pull/2814), [#2815](https://github.com/valkey-io/valkey-glide/pull/2815), [#2860](https://github.com/valkey-io/valkey-glide/pull/2860))
* Go: Add HINCRBY command ([#2847](https://github.com/valkey-io/valkey-glide/pull/2847))
* Go: Add HINCRBYFLOAT command ([#2846](https://github.com/valkey-io/valkey-glide/pull/2846))
* Go: Add SUNIONSTORE command ([#2805](https://github.com/valkey-io/valkey-glide/pull/2805))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import glide.api.models.GlideString;
import glide.ffi.resolvers.ObjectTypeResolver;
import glide.utils.ArrayTransformUtils;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;

Expand All @@ -28,6 +29,13 @@ public class ScanOptions extends BaseScanOptions {
*/
private final ObjectType type;

/**
* If set to true, the scan will perform even if some slots are not covered by any node. It's
* important to note that when set to true, the scan has no guarantee to cover all keys in the
* cluster, and the method loses its way to validate the progress of the scan. Defaults to false.
*/
@Builder.Default private final Boolean allowNonCoveredSlots = false;

/** Defines the complex data types available for a <code>SCAN</code> request. */
public enum ObjectType {
STRING(ObjectTypeResolver.OBJECT_TYPE_STRING_NATIVE_NAME),
Expand Down Expand Up @@ -86,4 +94,11 @@ public Long getCount() {
public ObjectType getType() {
return type;
}

/**
* @return whether non-covered slots are allowed.
*/
public Boolean getAllowNonCoveredSlots() {
return allowNonCoveredSlots;
}
}
4 changes: 4 additions & 0 deletions java/client/src/main/java/glide/managers/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ protected CommandRequest.Builder prepareCursorRequest(
clusterScanBuilder.setObjectType(options.getType().getNativeName());
}

if (options.getAllowNonCoveredSlots() != null) {
clusterScanBuilder.setAllowNonCoveredSlots(options.getAllowNonCoveredSlots());
}

return CommandRequest.newBuilder().setClusterScan(clusterScanBuilder.build());
}

Expand Down

0 comments on commit 9767ead

Please sign in to comment.