Skip to content

Commit

Permalink
Cover HGETF and HSETF commands' binary and pipeline all variants (wit…
Browse files Browse the repository at this point in the history
…hout tests)
  • Loading branch information
sazzad16 committed May 14, 2024
1 parent dae3081 commit e1cecbd
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -1296,10 +1296,27 @@ public final CommandObject<List<Long>> hsetf(String key, HSetFParams params, Map
.add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<String>> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, Map<String, String> fieldValues) {
public final CommandObject<List<String>> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption,
Map<String, String> fieldValues) {
return new CommandObject<>(addFlatMapArgs(commandArguments(HSETF).key(key).addParams(params).add(getOption)
.add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.STRING_LIST);
}

public final CommandObject<List<byte[]>> hgetf(byte[] key, HGetFParams params, byte[]... fields) {
return new CommandObject<>(commandArguments(HGETF).key(key).addParams(params)
.add(FIELDS).add(fields.length).addObjects((Object[]) fields), BuilderFactory.BINARY_LIST);
}

public final CommandObject<List<Long>> hsetf(byte[] key, HSetFParams params, Map<byte[], byte[]> fieldValues) {
return new CommandObject<>(addFlatMapArgs(commandArguments(HSETF).key(key).addParams(params)
.add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.LONG_LIST);
}

public final CommandObject<List<byte[]>> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption,
Map<byte[], byte[]> fieldValues) {
return new CommandObject<>(addFlatMapArgs(commandArguments(HSETF).key(key).addParams(params).add(getOption)
.add(FVS).add(fieldValues.size()), fieldValues), BuilderFactory.BINARY_LIST);
}
// Hash commands

// Set commands
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4734,6 +4734,24 @@ public List<Long> hpersist(byte[] key, byte[]... fields) {
return connection.executeCommand(commandObjects.hpersist(key, fields));
}

@Override
public List<byte[]> hgetf(byte[] key, HGetFParams params, byte[]... fields) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hgetf(key, params, fields));
}

@Override
public List<Long> hsetf(byte[] key, HSetFParams params, Map<byte[], byte[]> fieldValues) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hsetf(key, params, fieldValues));
}

@Override
public List<byte[]> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map<byte[], byte[]> fieldValues) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues));
}

@Override
public List<Object> xread(XReadParams xReadParams, Entry<byte[], byte[]>... streams) {
checkIsInMultiOrPipeline();
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/redis/clients/jedis/PipeliningBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,22 @@ public Response<List<Long>> hpersist(String key, String... fields) {
return appendCommand(commandObjects.hpersist(key, fields));
}

@Override
public Response<List<String>> hgetf(String key, HGetFParams params, String... fields) {
return appendCommand(commandObjects.hgetf(key, params, fields));
}

@Override
public Response<List<Long>> hsetf(String key, HSetFParams params, Map<String, String> fieldValues) {
return appendCommand(commandObjects.hsetf(key, params, fieldValues));
}

@Override
public Response<List<String>> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption,
Map<String, String> fieldValues) {
return appendCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues));
}

@Override
public Response<Long> sadd(String key, String... members) {
return appendCommand(commandObjects.sadd(key, members));
Expand Down Expand Up @@ -2136,6 +2152,22 @@ public Response<List<Long>> hpersist(byte[] key, byte[]... fields) {
return appendCommand(commandObjects.hpersist(key, fields));
}

@Override
public Response<List<byte[]>> hgetf(byte[] key, HGetFParams params, byte[]... fields) {
return appendCommand(commandObjects.hgetf(key, params, fields));
}

@Override
public Response<List<Long>> hsetf(byte[] key, HSetFParams params, Map<byte[], byte[]> fieldValues) {
return appendCommand(commandObjects.hsetf(key, params, fieldValues));
}

@Override
public Response<List<byte[]>> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption,
Map<byte[], byte[]> fieldValues) {
return appendCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues));
}

@Override
public Response<Long> pfadd(byte[] key, byte[]... elements) {
return appendCommand(commandObjects.pfadd(key, elements));
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,21 @@ public List<Long> hsetf(String key, HSetFParams params, Map<String, String> fiel
public List<String> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, Map<String, String> fieldValues) {
return executeCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues));
}

@Override
public List<byte[]> hgetf(byte[] key, HGetFParams params, byte[]... fields) {
return executeCommand(commandObjects.hgetf(key, params, fields));
}

@Override
public List<Long> hsetf(byte[] key, HSetFParams params, Map<byte[], byte[]> fieldValues) {
return executeCommand(commandObjects.hsetf(key, params, fieldValues));
}

@Override
public List<byte[]> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map<byte[], byte[]> fieldValues) {
return executeCommand(commandObjects.hsetfGet(key, params, getOption, fieldValues));
}
// Hash commands

// Set commands
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/redis/clients/jedis/commands/HashBinaryCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.util.Set;

import redis.clients.jedis.args.ExpiryOption;
import redis.clients.jedis.args.HSetFGetOption;
import redis.clients.jedis.params.HGetFParams;
import redis.clients.jedis.params.HSetFParams;
import redis.clients.jedis.params.ScanParams;
import redis.clients.jedis.resps.ScanResult;

Expand Down Expand Up @@ -191,4 +194,18 @@ default ScanResult<byte[]> hscanNoValues(byte[] key, byte[] cursor) {
* or -1 if the field exists but has no associated expire or -2 if the field does not exist.
*/
List<Long> hpersist(byte[] key, byte[]... fields);

/**
* For each specified field, returns its value and optionally set the field's remaining expiration
* time in seconds / milliseconds.
* @param key hash
* @param params
* @param fields
* @return values of fields
*/
List<byte[]> hgetf(byte[] key, HGetFParams params, byte[]... fields);

List<Long> hsetf(byte[] key, HSetFParams params, Map<byte[], byte[]> fieldValues);

List<byte[]> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map<byte[], byte[]> fieldValues);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import redis.clients.jedis.Response;
import redis.clients.jedis.args.ExpiryOption;
import redis.clients.jedis.args.HSetFGetOption;
import redis.clients.jedis.params.HGetFParams;
import redis.clients.jedis.params.HSetFParams;
import redis.clients.jedis.params.ScanParams;
import redis.clients.jedis.resps.ScanResult;

Expand Down Expand Up @@ -84,4 +87,10 @@ default Response<ScanResult<byte[]>> hscanNoValues(byte[] key, byte[] cursor) {
Response<List<Long>> hpttl(byte[] key, byte[]... fields);

Response<List<Long>> hpersist(byte[] key, byte[]... fields);

Response<List<byte[]>> hgetf(byte[] key, HGetFParams params, byte[]... fields);

Response<List<Long>> hsetf(byte[] key, HSetFParams params, Map<byte[], byte[]> fieldValues);

Response<List<byte[]>> hsetfGet(byte[] key, HSetFParams params, HSetFGetOption getOption, Map<byte[], byte[]> fieldValues);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import redis.clients.jedis.Response;
import redis.clients.jedis.args.ExpiryOption;
import redis.clients.jedis.args.HSetFGetOption;
import redis.clients.jedis.params.HGetFParams;
import redis.clients.jedis.params.HSetFParams;
import redis.clients.jedis.params.ScanParams;
import redis.clients.jedis.resps.ScanResult;

Expand Down Expand Up @@ -84,4 +87,10 @@ default Response<ScanResult<String>> hscanNoValues(String key, String cursor) {
Response<List<Long>> hpttl(String key, String... fields);

Response<List<Long>> hpersist(String key, String... fields);

Response<List<String>> hgetf(String key, HGetFParams params, String... fields);

Response<List<Long>> hsetf(String key, HSetFParams params, Map<String, String> fieldValues);

Response<List<String>> hsetfGet(String key, HSetFParams params, HSetFGetOption getOption, Map<String, String> fieldValues);
}

0 comments on commit e1cecbd

Please sign in to comment.