Skip to content

Commit

Permalink
Merge branch 'main' into node/integ_yipin_object_freq
Browse files Browse the repository at this point in the history
  • Loading branch information
yipin-chen authored Jun 10, 2024
2 parents 3a45bf9 + 9caf33d commit 2dad39d
Show file tree
Hide file tree
Showing 36 changed files with 1,449 additions and 93 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#### Changes
* Node: Added ZINTERSTORE command ([#1513](https://github.com/aws/glide-for-redis/pull/1513))
* Python: Added OBJECT ENCODING command ([#1471](https://github.com/aws/glide-for-redis/pull/1471))
* Python: Added OBJECT FREQ command ([#1472](https://github.com/aws/glide-for-redis/pull/1472))
* Python: Added OBJECT IDLETIME command ([#1474](https://github.com/aws/glide-for-redis/pull/1474))
Expand All @@ -15,6 +16,7 @@
* Python: Added SINTERCARD command ([#1511](https://github.com/aws/glide-for-redis/pull/1511))
* Python: Added SORT command ([#1439](https://github.com/aws/glide-for-redis/pull/1439))
* Node: Added OBJECT ENCODING command ([#1518](https://github.com/aws/glide-for-redis/pull/1518))
* Python: Added LMOVE and BLMOVE commands ([#1536](https://github.com/aws/glide-for-redis/pull/1536))
* Node: Added OBJECT FREQ command ([#1542](https://github.com/aws/glide-for-redis/pull/1542))

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion glide-core/src/client/value_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option<ExpectedReturnType> {
}),
b"INCRBYFLOAT" | b"HINCRBYFLOAT" | b"ZINCRBY" => Some(ExpectedReturnType::Double),
b"HEXISTS" | b"HSETNX" | b"EXPIRE" | b"EXPIREAT" | b"PEXPIRE" | b"PEXPIREAT"
| b"SISMEMBER" | b"PERSIST" | b"SMOVE" | b"RENAMENX" | b"MOVE" => {
| b"SISMEMBER" | b"PERSIST" | b"SMOVE" | b"RENAMENX" | b"MOVE" | b"COPY" => {
Some(ExpectedReturnType::Boolean)
}
b"SMISMEMBER" => Some(ExpectedReturnType::ArrayOfBools),
Expand Down
2 changes: 2 additions & 0 deletions glide-core/src/protobuf/redis_request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ enum RequestType {
FunctionLoad = 150;
FunctionList = 151;
FunctionDelete = 152;
FunctionFlush = 153;
LMPop = 155;
ExpireTime = 156;
PExpireTime = 157;
Expand All @@ -209,6 +210,7 @@ enum RequestType {
BitFieldReadOnly = 173;
Move = 174;
SInterCard = 175;
Copy = 178;
}

message Command {
Expand Down
6 changes: 6 additions & 0 deletions glide-core/src/request_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pub enum RequestType {
FunctionLoad = 150,
FunctionList = 151,
FunctionDelete = 152,
FunctionFlush = 153,
LMPop = 155,
ExpireTime = 156,
PExpireTime = 157,
Expand All @@ -179,6 +180,7 @@ pub enum RequestType {
BitFieldReadOnly = 173,
Move = 174,
SInterCard = 175,
Copy = 178,
}

fn get_two_word_command(first: &str, second: &str) -> Cmd {
Expand Down Expand Up @@ -343,6 +345,7 @@ impl From<::protobuf::EnumOrUnknown<ProtobufRequestType>> for RequestType {
ProtobufRequestType::FunctionLoad => RequestType::FunctionLoad,
ProtobufRequestType::FunctionList => RequestType::FunctionList,
ProtobufRequestType::FunctionDelete => RequestType::FunctionDelete,
ProtobufRequestType::FunctionFlush => RequestType::FunctionFlush,
ProtobufRequestType::BitPos => RequestType::BitPos,
ProtobufRequestType::BitOp => RequestType::BitOp,
ProtobufRequestType::HStrlen => RequestType::HStrlen,
Expand All @@ -360,6 +363,7 @@ impl From<::protobuf::EnumOrUnknown<ProtobufRequestType>> for RequestType {
ProtobufRequestType::BitFieldReadOnly => RequestType::BitFieldReadOnly,
ProtobufRequestType::Move => RequestType::Move,
ProtobufRequestType::SInterCard => RequestType::SInterCard,
ProtobufRequestType::Copy => RequestType::Copy,
ProtobufRequestType::Sort => RequestType::Sort,
}
}
Expand Down Expand Up @@ -521,6 +525,7 @@ impl RequestType {
RequestType::FunctionLoad => Some(get_two_word_command("FUNCTION", "LOAD")),
RequestType::FunctionList => Some(get_two_word_command("FUNCTION", "LIST")),
RequestType::FunctionDelete => Some(get_two_word_command("FUNCTION", "DELETE")),
RequestType::FunctionFlush => Some(get_two_word_command("FUNCTION", "FLUSH")),
RequestType::BitPos => Some(cmd("BITPOS")),
RequestType::BitOp => Some(cmd("BITOP")),
RequestType::HStrlen => Some(cmd("HSTRLEN")),
Expand All @@ -538,6 +543,7 @@ impl RequestType {
RequestType::BitFieldReadOnly => Some(cmd("BITFIELD_RO")),
RequestType::Move => Some(cmd("MOVE")),
RequestType::SInterCard => Some(cmd("SINTERCARD")),
RequestType::Copy => Some(cmd("COPY")),
RequestType::Sort => Some(cmd("SORT")),
}
}
Expand Down
17 changes: 17 additions & 0 deletions java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static redis_request.RedisRequestOuterClass.RequestType.BitFieldReadOnly;
import static redis_request.RedisRequestOuterClass.RequestType.BitOp;
import static redis_request.RedisRequestOuterClass.RequestType.BitPos;
import static redis_request.RedisRequestOuterClass.RequestType.Copy;
import static redis_request.RedisRequestOuterClass.RequestType.Decr;
import static redis_request.RedisRequestOuterClass.RequestType.DecrBy;
import static redis_request.RedisRequestOuterClass.RequestType.Del;
Expand Down Expand Up @@ -1733,4 +1734,20 @@ public CompletableFuture<Long> sintercard(@NonNull String[] keys, long limit) {
new String[] {SET_LIMIT_REDIS_API, Long.toString(limit)});
return commandManager.submitNewCommand(SInterCard, arguments, this::handleLongResponse);
}

@Override
public CompletableFuture<Boolean> copy(
@NonNull String source, @NonNull String destination, boolean replace) {
String[] arguments = new String[] {source, destination};
if (replace) {
arguments = ArrayUtils.add(arguments, REPLACE_REDIS_API);
}
return commandManager.submitNewCommand(Copy, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> copy(@NonNull String source, @NonNull String destination) {
String[] arguments = new String[] {source, destination};
return commandManager.submitNewCommand(Copy, arguments, this::handleBooleanResponse);
}
}
34 changes: 34 additions & 0 deletions java/client/src/main/java/glide/api/RedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import static redis_request.RedisRequestOuterClass.RequestType.ConfigResetStat;
import static redis_request.RedisRequestOuterClass.RequestType.ConfigRewrite;
import static redis_request.RedisRequestOuterClass.RequestType.ConfigSet;
import static redis_request.RedisRequestOuterClass.RequestType.Copy;
import static redis_request.RedisRequestOuterClass.RequestType.CustomCommand;
import static redis_request.RedisRequestOuterClass.RequestType.DBSize;
import static redis_request.RedisRequestOuterClass.RequestType.Echo;
import static redis_request.RedisRequestOuterClass.RequestType.FlushAll;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionDelete;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionFlush;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionList;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionLoad;
import static redis_request.RedisRequestOuterClass.RequestType.Info;
Expand All @@ -42,6 +44,7 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import lombok.NonNull;
import org.apache.commons.lang3.ArrayUtils;

/**
* Async (non-blocking) client for Redis in Standalone mode. Use {@link #CreateClient} to request a
Expand Down Expand Up @@ -233,9 +236,40 @@ public CompletableFuture<Map<String, Object>[]> functionList(
response -> handleFunctionListResponse(handleArrayResponse(response)));
}

@Override
public CompletableFuture<String> functionFlush() {
return commandManager.submitNewCommand(
FunctionFlush, new String[0], this::handleStringResponse);
}

@Override
public CompletableFuture<String> functionFlush(@NonNull FlushMode mode) {
return commandManager.submitNewCommand(
FunctionFlush, new String[] {mode.toString()}, this::handleStringResponse);
}

@Override
public CompletableFuture<String> functionDelete(@NonNull String libName) {
return commandManager.submitNewCommand(
FunctionDelete, new String[] {libName}, this::handleStringResponse);
}

@Override
public CompletableFuture<Boolean> copy(
@NonNull String source, @NonNull String destination, long destinationDB) {
String[] arguments =
new String[] {source, destination, DB_REDIS_API, Long.toString(destinationDB)};
return commandManager.submitNewCommand(Copy, arguments, this::handleBooleanResponse);
}

@Override
public CompletableFuture<Boolean> copy(
@NonNull String source, @NonNull String destination, long destinationDB, boolean replace) {
String[] arguments =
new String[] {source, destination, DB_REDIS_API, Long.toString(destinationDB)};
if (replace) {
arguments = ArrayUtils.add(arguments, REPLACE_REDIS_API);
}
return commandManager.submitNewCommand(Copy, arguments, this::handleBooleanResponse);
}
}
25 changes: 25 additions & 0 deletions java/client/src/main/java/glide/api/RedisClusterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static redis_request.RedisRequestOuterClass.RequestType.Echo;
import static redis_request.RedisRequestOuterClass.RequestType.FlushAll;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionDelete;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionFlush;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionList;
import static redis_request.RedisRequestOuterClass.RequestType.FunctionLoad;
import static redis_request.RedisRequestOuterClass.RequestType.Info;
Expand Down Expand Up @@ -507,6 +508,30 @@ public CompletableFuture<ClusterValue<Map<String, Object>[]>> functionList(
response -> handleFunctionListResponse(response, route));
}

@Override
public CompletableFuture<String> functionFlush() {
return commandManager.submitNewCommand(
FunctionFlush, new String[0], this::handleStringResponse);
}

@Override
public CompletableFuture<String> functionFlush(@NonNull FlushMode mode) {
return commandManager.submitNewCommand(
FunctionFlush, new String[] {mode.toString()}, this::handleStringResponse);
}

@Override
public CompletableFuture<String> functionFlush(@NonNull Route route) {
return commandManager.submitNewCommand(
FunctionFlush, new String[0], route, this::handleStringResponse);
}

@Override
public CompletableFuture<String> functionFlush(@NonNull FlushMode mode, @NonNull Route route) {
return commandManager.submitNewCommand(
FunctionFlush, new String[] {mode.toString()}, route, this::handleStringResponse);
}

@Override
public CompletableFuture<String> functionDelete(@NonNull String libName) {
return commandManager.submitNewCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import glide.api.models.commands.bitmap.BitFieldOptions.OffsetMultiplier;
import glide.api.models.commands.bitmap.BitmapIndexType;
import glide.api.models.commands.bitmap.BitwiseOperation;
import glide.api.models.configuration.ReadFrom;
import java.util.concurrent.CompletableFuture;

/**
Expand All @@ -24,7 +25,7 @@ public interface BitmapBaseCommands {
/**
* Counts the number of set bits (population counting) in a string stored at <code>key</code>.
*
* @see <a href="https://redis.io/commands/bitcount/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitcount/">valkey.io</a> for details.
* @param key The key for the string to count the set bits of.
* @return The number of set bits in the string. Returns zero if the key is missing as it is
* treated as an empty string.
Expand All @@ -44,7 +45,7 @@ public interface BitmapBaseCommands {
* <code>-1</code> being the last element of the list, <code>-2</code> being the penultimate, and
* so on.
*
* @see <a href="https://redis.io/commands/bitcount/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitcount/">valkey.io</a> for details.
* @param key The key for the string to count the set bits of.
* @param start The starting offset byte index.
* @param end The ending offset byte index.
Expand All @@ -67,7 +68,7 @@ public interface BitmapBaseCommands {
* so on.
*
* @since Redis 7.0 and above
* @see <a href="https://redis.io/commands/bitcount/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitcount/">valkey.io</a> for details.
* @param key The key for the string to count the set bits of.
* @param start The starting offset.
* @param end The ending offset.
Expand All @@ -92,7 +93,7 @@ public interface BitmapBaseCommands {
* non-existent then the bit at <code>offset</code> is set to <code>value</code> and the preceding
* bits are set to <code>0</code>.
*
* @see <a href="https://redis.io/commands/setbit/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/setbit/">valkey.io</a> for details.
* @param key The key of the string.
* @param offset The index of the bit to be set.
* @param value The bit value to set at <code>offset</code>. The value must be <code>0</code> or
Expand All @@ -110,7 +111,7 @@ public interface BitmapBaseCommands {
* Returns the bit value at <code>offset</code> in the string value stored at <code>key</code>.
* <code>offset</code> should be greater than or equal to zero.
*
* @see <a href="https://redis.io/commands/getbit/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/getbit/">valkey.io</a> for details.
* @param key The key of the string.
* @param offset The index of the bit to return.
* @return The bit at offset of the string. Returns zero if the key is empty or if the positive
Expand All @@ -127,7 +128,7 @@ public interface BitmapBaseCommands {
/**
* Returns the position of the first bit matching the given <code>bit</code> value.
*
* @see <a href="https://redis.io/commands/bitpos/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitpos/">valkey.io</a> for details.
* @param key The key of the string.
* @param bit The bit value to match. The value must be <code>0</code> or <code>1</code>.
* @return The position of the first occurrence matching <code>bit</code> in the binary value of
Expand All @@ -150,7 +151,7 @@ public interface BitmapBaseCommands {
* indicating offsets starting at the end of the list, with <code>-1</code> being the last byte of
* the list, <code>-2</code> being the penultimate, and so on.
*
* @see <a href="https://redis.io/commands/bitpos/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitpos/">valkey.io</a> for details.
* @param key The key of the string.
* @param bit The bit value to match. The value must be <code>0</code> or <code>1</code>.
* @param start The starting offset.
Expand All @@ -174,7 +175,7 @@ public interface BitmapBaseCommands {
* negative numbers indicating offsets starting at the end of the list, with <code>-1</code> being
* the last byte of the list, <code>-2</code> being the penultimate, and so on.
*
* @see <a href="https://redis.io/commands/bitpos/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitpos/">valkey.io</a> for details.
* @param key The key of the string.
* @param bit The bit value to match. The value must be <code>0</code> or <code>1</code>.
* @param start The starting offset.
Expand Down Expand Up @@ -203,7 +204,7 @@ public interface BitmapBaseCommands {
* list, <code>-2</code> being the penultimate, and so on.
*
* @since Redis 7.0 and above.
* @see <a href="https://redis.io/commands/bitpos/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitpos/">valkey.io</a> for details.
* @param key The key of the string.
* @param bit The bit value to match. The value must be <code>0</code> or <code>1</code>.
* @param start The starting offset.
Expand All @@ -230,7 +231,7 @@ CompletableFuture<Long> bitpos(
*
* @apiNote When in cluster mode, <code>destination</code> and all <code>keys</code> must map to
* the same hash slot.
* @see <a href="https://redis.io/commands/bitop/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitop/">valkey.io</a> for details.
* @param bitwiseOperation The bitwise operation to perform.
* @param destination The key that will store the resulting string.
* @param keys The list of keys to perform the bitwise operation on.
Expand All @@ -251,7 +252,7 @@ CompletableFuture<Long> bitop(
* Reads or modifies the array of bits representing the string that is held at <code>key</code>
* based on the specified <code>subCommands</code>.
*
* @see <a href="https://redis.io/commands/bitfield/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitfield/">valkey.io</a> for details.
* @param key The key of the string.
* @param subCommands The subCommands to be performed on the binary value of the string at <code>
* key</code>, which could be any of the following:
Expand Down Expand Up @@ -289,10 +290,11 @@ CompletableFuture<Long> bitop(

/**
* Reads the array of bits representing the string that is held at <code>key</code> based on the
* specified <code>subCommands</code>.
* specified <code>subCommands</code>.<br>
* This command is routed depending on the client's {@link ReadFrom} strategy.
*
* @since Redis 6.0 and above
* @see <a href="https://redis.io/docs/latest/commands/bitfield_ro/">redis.io</a> for details.
* @see <a href="https://valkey.io/commands/bitfield_ro/">valkey.io</a> for details.
* @param key The key of the string.
* @param subCommands The <code>GET</code> subCommands to be performed.
* @return An array of results from the <code>GET</code> subcommands.
Expand Down
Loading

0 comments on commit 2dad39d

Please sign in to comment.