Change zadd parameter order to allow duplicated scoremembers but not members
This commit is contained in:
@@ -376,23 +376,22 @@ public class BinaryClient extends Connection {
|
||||
public void zadd(final byte[] key, final double score, final byte[] member) {
|
||||
sendCommand(ZADD, key, toByteArray(score), member);
|
||||
}
|
||||
|
||||
public void zaddBinary(final byte[] key, final Map< byte[], Double> scoreMembers) {
|
||||
|
||||
ArrayList<byte[]> args = new ArrayList<byte[]>(scoreMembers.size() * 2 + 1);
|
||||
args.add(key);
|
||||
|
||||
public void zaddBinary(final byte[] key, Map<Double, byte[]> scoreMembers) {
|
||||
ArrayList<byte[]> args = new ArrayList<byte[]>(
|
||||
scoreMembers.size() * 2 + 1);
|
||||
for (Map.Entry<byte[],Double > entry : scoreMembers.entrySet()) {
|
||||
args.add(toByteArray(entry.getValue()));
|
||||
args.add(entry.getKey());
|
||||
}
|
||||
|
||||
args.add(key);
|
||||
byte[][] argsArray = new byte[args.size()][];
|
||||
args.toArray(argsArray);
|
||||
|
||||
for (Map.Entry<Double, byte[]> entry : scoreMembers.entrySet()) {
|
||||
args.add(toByteArray(entry.getKey()));
|
||||
args.add(entry.getValue());
|
||||
}
|
||||
|
||||
byte[][] argsArray = new byte[args.size()][];
|
||||
args.toArray(argsArray);
|
||||
|
||||
sendCommand(ZADD, argsArray);
|
||||
}
|
||||
sendCommand(ZADD, argsArray);
|
||||
}
|
||||
|
||||
public void zrange(final byte[] key, final long start, final long end) {
|
||||
sendCommand(ZRANGE, key, toByteArray(start), toByteArray(end));
|
||||
|
||||
@@ -1502,7 +1502,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Long zadd(final byte[] key, final Map<Double, byte[]> scoreMembers) {
|
||||
public Long zadd(final byte[] key, final Map<byte[], Double> scoreMembers) {
|
||||
checkIsInMulti();
|
||||
client.zaddBinary(key, scoreMembers);
|
||||
return client.getIntegerReply();
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
|
||||
/**
|
||||
* Common interface for sharded and non-sharded BinaryJedis
|
||||
*/
|
||||
@@ -114,8 +116,8 @@ public interface BinaryJedisCommands {
|
||||
Long strlen(byte[] key);
|
||||
|
||||
Long zadd(byte[] key, double score, byte[] member);
|
||||
|
||||
Long zadd(byte[] key, Map<Double, byte[]> scoreMembers);
|
||||
|
||||
Long zadd(byte[] key, Map<byte[], Double> scoreMembers);
|
||||
|
||||
Set<byte[]> zrange(byte[] key, long start, long end);
|
||||
|
||||
@@ -157,45 +159,45 @@ public interface BinaryJedisCommands {
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min);
|
||||
|
||||
Set<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max, int offset,
|
||||
int count);
|
||||
int count);
|
||||
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, double max, double min,
|
||||
int offset, int count);
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max,
|
||||
int offset, int count);
|
||||
|
||||
int offset, int count);
|
||||
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min,
|
||||
int offset, int count);
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max);
|
||||
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max,
|
||||
int offset, int count);
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min,
|
||||
int offset, int count);
|
||||
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min,
|
||||
int offset, int count);
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByRank(byte[] key, long start, long end);
|
||||
|
||||
Long zremrangeByScore(byte[] key, double start, double end);
|
||||
|
||||
|
||||
Long zremrangeByScore(byte[] key, byte[] start, byte[] end);
|
||||
|
||||
Long linsert(byte[] key, Client.LIST_POSITION where, byte[] pivot,
|
||||
byte[] value);
|
||||
|
||||
byte[] value);
|
||||
|
||||
Long lpushx(byte[] key, byte[]... arg);
|
||||
|
||||
|
||||
Long rpushx(byte[] key, byte[]... arg);
|
||||
|
||||
List<byte[]> blpop(byte[] arg);
|
||||
|
||||
@@ -295,7 +295,7 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
|
||||
return j.zadd(key, score, member);
|
||||
}
|
||||
|
||||
public Long zadd(byte[] key, Map<Double, byte[]> scoreMembers) {
|
||||
public Long zadd(byte[] key, Map<byte[], Double> scoreMembers) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, scoreMembers);
|
||||
}
|
||||
|
||||
@@ -709,17 +709,19 @@ public class Client extends BinaryClient implements Commands {
|
||||
public void scriptLoad(String script) {
|
||||
scriptLoad(SafeEncoder.encode(script));
|
||||
}
|
||||
|
||||
public void zadd(String key, Map<String, Double> scoreMembers) {
|
||||
|
||||
HashMap<byte[], Double> binaryScoreMembers = new HashMap<byte[], Double>();
|
||||
|
||||
public void zadd(String key, Map<Double, String> scoreMembers) {
|
||||
HashMap<Double, byte[]> binaryScoreMembers = new HashMap<Double, byte[]>();
|
||||
|
||||
for (Map.Entry<Double, String> entry : scoreMembers.entrySet()) {
|
||||
binaryScoreMembers.put(entry.getKey(),
|
||||
SafeEncoder.encode(entry.getValue()));
|
||||
for (Map.Entry<String, Double> entry : scoreMembers.entrySet()) {
|
||||
|
||||
binaryScoreMembers.put(SafeEncoder.encode(entry.getKey()), entry.getValue());
|
||||
}
|
||||
|
||||
zaddBinary(SafeEncoder.encode(key), binaryScoreMembers);
|
||||
}
|
||||
|
||||
zaddBinary(SafeEncoder.encode(key), binaryScoreMembers);
|
||||
}
|
||||
|
||||
public void objectRefcount(String key) {
|
||||
objectRefcount(SafeEncoder.encode(key));
|
||||
|
||||
@@ -143,8 +143,8 @@ public interface Commands {
|
||||
public void srandmember(final String key);
|
||||
|
||||
public void zadd(final String key, final double score, final String member);
|
||||
|
||||
public void zadd(final String key, final Map<Double, String> scoreMembers);
|
||||
|
||||
public void zadd(final String key, final Map<String, Double > scoreMembers);
|
||||
|
||||
public void zrange(final String key, final long start, final long end);
|
||||
|
||||
|
||||
@@ -1415,10 +1415,10 @@ public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommand
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Long zadd(final String key, final Map<Double, String> scoreMembers) {
|
||||
checkIsInMulti();
|
||||
client.zadd(key, scoreMembers);
|
||||
return client.getIntegerReply();
|
||||
public Long zadd(final String key, final Map<String, Double> scoreMembers) {
|
||||
checkIsInMulti();
|
||||
client.zadd(key, scoreMembers);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Set<String> zrange(final String key, final long start, final long end) {
|
||||
|
||||
@@ -635,7 +635,7 @@ public class JedisCluster implements JedisCommands, BasicCommands {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zadd(final String key, final Map<Double, String> scoreMembers) {
|
||||
public Long zadd(final String key, final Map<String, Double> scoreMembers) {
|
||||
return new JedisClusterCommand<Long>(connectionHandler, timeout,
|
||||
maxRedirections) {
|
||||
@Override
|
||||
|
||||
@@ -115,7 +115,7 @@ public interface
|
||||
|
||||
Long zadd(String key, double score, String member);
|
||||
|
||||
Long zadd(String key, Map<Double, String> scoreMembers);
|
||||
Long zadd(String key, Map<String, Double > scoreMembers);
|
||||
|
||||
Set<String> zrange(String key, long start, long end);
|
||||
|
||||
|
||||
@@ -654,7 +654,7 @@ abstract class PipelineBase extends Queable implements
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zadd(String key, Map<Double, String> scoreMembers) {
|
||||
public Response<Long> zadd(String key, Map<String, Double> scoreMembers) {
|
||||
getClient(key).zadd(key, scoreMembers);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
@@ -326,10 +326,10 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, score, member);
|
||||
}
|
||||
|
||||
public Long zadd(String key, Map<Double, String> scoreMembers) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, scoreMembers);
|
||||
|
||||
public Long zadd(String key, Map<String, Double> scoreMembers) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, scoreMembers);
|
||||
}
|
||||
|
||||
public Set<String> zrange(String key, long start, long end) {
|
||||
|
||||
Reference in New Issue
Block a user