diff --git a/src/main/java/redis/clients/jedis/BinaryClient.java b/src/main/java/redis/clients/jedis/BinaryClient.java index 1544f53..5101206 100644 --- a/src/main/java/redis/clients/jedis/BinaryClient.java +++ b/src/main/java/redis/clients/jedis/BinaryClient.java @@ -495,23 +495,41 @@ public class BinaryClient extends Connection { final double max) { sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max)); } + public void zrevrangeByScore(final byte[] key, final double max, + final double min) { + sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min)); + } public void zrangeByScore(final byte[] key, final byte[] min, final byte[] max) { sendCommand(ZRANGEBYSCORE, key, min, max); } + public void zrevrangeByScore(final byte[] key, final byte[] max, + final byte[] min) { + sendCommand(ZREVRANGEBYSCORE, key, max, min); + } public void zrangeByScore(final byte[] key, final double min, final double max, final int offset, int count) { sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max), LIMIT.raw, toByteArray(offset), toByteArray(count)); } + public void zrevrangeByScore(final byte[] key, final double max, + final double min, final int offset, int count) { + sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), + LIMIT.raw, toByteArray(offset), toByteArray(count)); + } public void zrangeByScoreWithScores(final byte[] key, final double min, final double max) { sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max), WITHSCORES.raw); } + public void zrevrangeByScoreWithScores(final byte[] key, final double max, + final double min) { + sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), + WITHSCORES.raw); + } public void zrangeByScoreWithScores(final byte[] key, final double min, final double max, final int offset, final int count) { @@ -519,6 +537,12 @@ public class BinaryClient extends Connection { LIMIT.raw, toByteArray(offset), toByteArray(count), WITHSCORES.raw); } + public void zrevrangeByScoreWithScores(final byte[] key, final double max, + final double min, final int offset, final int count) { + sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), + LIMIT.raw, toByteArray(offset), toByteArray(count), + WITHSCORES.raw); + } public void zremrangeByRank(final byte[] key, final int start, final int end) { sendCommand(ZREMRANGEBYRANK, key, toByteArray(start), toByteArray(end)); @@ -670,4 +694,4 @@ public class BinaryClient extends Connection { public void getrange(byte[] key, long startOffset, long endOffset) { sendCommand(GETRANGE, key, toByteArray(startOffset), toByteArray(endOffset)); } -} \ No newline at end of file +} diff --git a/src/main/java/redis/clients/jedis/BinaryJedis.java b/src/main/java/redis/clients/jedis/BinaryJedis.java index d47f9ca..4e96edc 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedis.java +++ b/src/main/java/redis/clients/jedis/BinaryJedis.java @@ -2326,6 +2326,44 @@ public class BinaryJedis implements BinaryJedisCommands { return set; } + public Set zrevrangeByScore(final byte[] key, final double max, + final double min) { + checkIsInMulti(); + client.zrevrangeByScore(key, max, min); + return new LinkedHashSet(client.getBinaryMultiBulkReply()); + } + + public Set zrevrangeByScore(final byte[] key, final byte[] max, + final byte[] min) { + checkIsInMulti(); + client.zrevrangeByScore(key, max, min); + return new LinkedHashSet(client.getBinaryMultiBulkReply()); + } + + public Set zrevrangeByScore(final byte[] key, final double max, + final double min, final int offset, final int count) { + checkIsInMulti(); + client.zrevrangeByScore(key, max, min, offset, count); + return new LinkedHashSet(client.getBinaryMultiBulkReply()); + } + + public Set zrevrangeByScoreWithScores(final byte[] key, + final double max, final double min) { + checkIsInMulti(); + client.zrevrangeByScoreWithScores(key, max, min); + Set set = getBinaryTupledSet(); + return set; + } + + public Set zrevrangeByScoreWithScores(final byte[] key, + final double max, final double min, final int offset, + final int count) { + checkIsInMulti(); + client.zrevrangeByScoreWithScores(key, max, min, offset, count); + Set set = getBinaryTupledSet(); + return set; + } + /** * Remove all elements in the sorted set at key with rank between start and * end. Start and end are 0-based with rank 0 being the element with the diff --git a/src/main/java/redis/clients/jedis/BinaryJedisCommands.java b/src/main/java/redis/clients/jedis/BinaryJedisCommands.java index 241734f..ef8aebd 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedisCommands.java +++ b/src/main/java/redis/clients/jedis/BinaryJedisCommands.java @@ -139,6 +139,16 @@ public interface BinaryJedisCommands { Set zrangeByScoreWithScores(byte[] key, double min, double max, int offset, int count); + Set zrevrangeByScore(byte[] key, double max, double min); + + Set zrevrangeByScore(byte[] key, double max, double min, int offset, + int count); + + Set zrevrangeByScoreWithScores(byte[] key, double max, double min); + + Set zrevrangeByScoreWithScores(byte[] key, double max, double min, + int offset, int count); + Long zremrangeByRank(byte[] key, int start, int end); Long zremrangeByScore(byte[] key, double start, double end); diff --git a/src/main/java/redis/clients/jedis/BinaryShardedJedis.java b/src/main/java/redis/clients/jedis/BinaryShardedJedis.java index 1143121..113511b 100644 --- a/src/main/java/redis/clients/jedis/BinaryShardedJedis.java +++ b/src/main/java/redis/clients/jedis/BinaryShardedJedis.java @@ -357,6 +357,28 @@ public class BinaryShardedJedis extends Sharded return j.zrangeByScoreWithScores(key, min, max, offset, count); } + public Set zrevrangeByScore(byte[] key, double max, double min) { + Jedis j = getShard(key); + return j.zrevrangeByScore(key, max, min); + } + + public Set zrevrangeByScore(byte[] key, double max, double min, + int offset, int count) { + Jedis j = getShard(key); + return j.zrevrangeByScore(key, max, min, offset, count); + } + + public Set zrevrangeByScoreWithScores(byte[] key, double max, double min) { + Jedis j = getShard(key); + return j.zrevrangeByScoreWithScores(key, max, min); + } + + public Set zrevrangeByScoreWithScores(byte[] key, double max, + double min, int offset, int count) { + Jedis j = getShard(key); + return j.zrevrangeByScoreWithScores(key, max, min, offset, count); + } + public Long zremrangeByRank(byte[] key, int start, int end) { Jedis j = getShard(key); return j.zremrangeByRank(key, start, end); diff --git a/src/main/java/redis/clients/jedis/Client.java b/src/main/java/redis/clients/jedis/Client.java index 493ef44..3bcc072 100644 --- a/src/main/java/redis/clients/jedis/Client.java +++ b/src/main/java/redis/clients/jedis/Client.java @@ -435,6 +435,33 @@ public class Client extends BinaryClient implements Commands { count); } + public void zrevrangeByScore(final String key, final double max, + final double min) { + zrevrangeByScore(SafeEncoder.encode(key), max, min); + } + + public void zrevrangeByScore(final String key, final String max, + final String min) { + zrevrangeByScore(SafeEncoder.encode(key), SafeEncoder.encode(max), + SafeEncoder.encode(min)); + } + + public void zrevrangeByScore(final String key, final double max, + final double min, final int offset, int count) { + zrevrangeByScore(SafeEncoder.encode(key), max, min, offset, count); + } + + public void zrevrangeByScoreWithScores(final String key, final double max, + final double min) { + zrevrangeByScoreWithScores(SafeEncoder.encode(key), max, min); + } + + public void zrevrangeByScoreWithScores(final String key, final double max, + final double min, final int offset, final int count) { + zrevrangeByScoreWithScores(SafeEncoder.encode(key), max, min, offset, + count); + } + public void zremrangeByRank(final String key, final int start, final int end) { zremrangeByRank(SafeEncoder.encode(key), start, end); } @@ -560,4 +587,4 @@ public class Client extends BinaryClient implements Commands { } subscribe(cs); } -} \ No newline at end of file +} diff --git a/src/main/java/redis/clients/jedis/Commands.java b/src/main/java/redis/clients/jedis/Commands.java index 36db6c0..977f8d0 100644 --- a/src/main/java/redis/clients/jedis/Commands.java +++ b/src/main/java/redis/clients/jedis/Commands.java @@ -197,6 +197,21 @@ public interface Commands { public void zrangeByScoreWithScores(final String key, final double min, final double max, final int offset, final int count); + public void zrevrangeByScore(final String key, final double max, + final double min); + + public void zrevrangeByScore(final String key, final String max, + final String min); + + public void zrevrangeByScore(final String key, final double max, + final double min, final int offset, int count); + + public void zrevrangeByScoreWithScores(final String key, final double max, + final double min); + + public void zrevrangeByScoreWithScores(final String key, final double max, + final double min, final int offset, final int count); + public void zremrangeByRank(final String key, final int start, final int end); public void zremrangeByScore(final String key, final double start, diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index 4e232f2..7845d49 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -2270,6 +2270,44 @@ public class Jedis extends BinaryJedis implements JedisCommands { return set; } + public Set zrevrangeByScore(final String key, final double max, + final double min) { + checkIsInMulti(); + client.zrevrangeByScore(key, max, min); + return new LinkedHashSet(client.getMultiBulkReply()); + } + + public Set zrevrangeByScore(final String key, final String max, + final String min) { + checkIsInMulti(); + client.zrevrangeByScore(key, max, min); + return new LinkedHashSet(client.getMultiBulkReply()); + } + + public Set zrevrangeByScore(final String key, final double max, + final double min, final int offset, final int count) { + checkIsInMulti(); + client.zrevrangeByScore(key, max, min, offset, count); + return new LinkedHashSet(client.getMultiBulkReply()); + } + + public Set zrevrangeByScoreWithScores(final String key, + final double max, final double min) { + checkIsInMulti(); + client.zrevrangeByScoreWithScores(key, max, min); + Set set = getTupledSet(); + return set; + } + + public Set zrevrangeByScoreWithScores(final String key, + final double max, final double min, final int offset, + final int count) { + checkIsInMulti(); + client.zrevrangeByScoreWithScores(key, max, min, offset, count); + Set set = getTupledSet(); + return set; + } + /** * Remove all elements in the sorted set at key with rank between start and * end. Start and end are 0-based with rank 0 being the element with the @@ -2582,4 +2620,4 @@ public class Jedis extends BinaryJedis implements JedisCommands { client.getrange(key, startOffset, endOffset); return client.getBulkReply(); } -} \ No newline at end of file +} diff --git a/src/main/java/redis/clients/jedis/JedisCommands.java b/src/main/java/redis/clients/jedis/JedisCommands.java index 004b6ac..d758679 100644 --- a/src/main/java/redis/clients/jedis/JedisCommands.java +++ b/src/main/java/redis/clients/jedis/JedisCommands.java @@ -136,14 +136,20 @@ public interface JedisCommands { Long zcount(String key, double min, double max); Set zrangeByScore(String key, double min, double max); + Set zrevrangeByScore(String key, double max, double min); Set zrangeByScore(String key, double min, double max, int offset, int count); + Set zrevrangeByScore(String key, double max, double min, int offset, + int count); Set zrangeByScoreWithScores(String key, double min, double max); + Set zrevrangeByScoreWithScores(String key, double max, double min); Set zrangeByScoreWithScores(String key, double min, double max, int offset, int count); + Set zrevrangeByScoreWithScores(String key, double max, double min, + int offset, int count); Long zremrangeByRank(String key, int start, int end); diff --git a/src/main/java/redis/clients/jedis/Pipeline.java b/src/main/java/redis/clients/jedis/Pipeline.java index 432ec5f..72b267c 100644 --- a/src/main/java/redis/clients/jedis/Pipeline.java +++ b/src/main/java/redis/clients/jedis/Pipeline.java @@ -922,6 +922,66 @@ public class Pipeline extends Queable { return getResponse(BuilderFactory.TUPLE_ZSET); } + public Response> zrevrangeByScore(String key, double max, + double min) { + client.zrevrangeByScore(key, max, min); + return getResponse(BuilderFactory.STRING_ZSET); + } + + public Response> zrevrangeByScore(byte[] key, double max, + double min) { + client.zrevrangeByScore(key, max, min); + return getResponse(BuilderFactory.STRING_ZSET); + } + + public Response> zrevrangeByScore(String key, String max, + String min) { + client.zrevrangeByScore(key, max, min); + return getResponse(BuilderFactory.STRING_ZSET); + } + + public Response> zrevrangeByScore(byte[] key, byte[] max, + byte[] min) { + client.zrevrangeByScore(key, max, min); + return getResponse(BuilderFactory.STRING_ZSET); + } + + public Response> zrevrangeByScore(String key, double max, + double min, int offset, int count) { + client.zrevrangeByScore(key, max, min, offset, count); + return getResponse(BuilderFactory.STRING_ZSET); + } + + public Response> zrevrangeByScore(byte[] key, double max, + double min, int offset, int count) { + client.zrevrangeByScore(key, max, min, offset, count); + return getResponse(BuilderFactory.STRING_ZSET); + } + + public Response> zrevrangeByScoreWithScores(String key, + double max, double min) { + client.zrevrangeByScoreWithScores(key, max, min); + return getResponse(BuilderFactory.TUPLE_ZSET); + } + + public Response> zrevrangeByScoreWithScores(byte[] key, + double max, double min) { + client.zrevrangeByScoreWithScores(key, max, min); + return getResponse(BuilderFactory.TUPLE_ZSET); + } + + public Response> zrevrangeByScoreWithScores(String key, + double max, double min, int offset, int count) { + client.zrevrangeByScoreWithScores(key, max, min, offset, count); + return getResponse(BuilderFactory.TUPLE_ZSET); + } + + public Response> zrevrangeByScoreWithScores(byte[] key, + double max, double min, int offset, int count) { + client.zrevrangeByScoreWithScores(key, max, min, offset, count); + return getResponse(BuilderFactory.TUPLE_ZSET); + } + public Response> zrangeWithScores(String key, int start, int end) { client.zrangeWithScores(key, start, end); return getResponse(BuilderFactory.TUPLE_ZSET); @@ -1095,4 +1155,4 @@ public class Pipeline extends Queable { public void multi() { client.multi(); } -} \ No newline at end of file +} diff --git a/src/main/java/redis/clients/jedis/Protocol.java b/src/main/java/redis/clients/jedis/Protocol.java index d92b785..c2ad2b5 100644 --- a/src/main/java/redis/clients/jedis/Protocol.java +++ b/src/main/java/redis/clients/jedis/Protocol.java @@ -135,7 +135,7 @@ public final class Protocol { } public static enum Command { - PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE; + PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE; public final byte[] raw; @@ -153,4 +153,4 @@ public final class Protocol { } } -} \ No newline at end of file +} diff --git a/src/main/java/redis/clients/jedis/ShardedJedis.java b/src/main/java/redis/clients/jedis/ShardedJedis.java index 6db8635..1993077 100644 --- a/src/main/java/redis/clients/jedis/ShardedJedis.java +++ b/src/main/java/redis/clients/jedis/ShardedJedis.java @@ -353,23 +353,41 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands { Jedis j = getShard(key); return j.zrangeByScore(key, min, max); } + public Set zrevrangeByScore(String key, double max, double min) { + Jedis j = getShard(key); + return j.zrevrangeByScore(key, max, min); + } public Set zrangeByScore(String key, double min, double max, int offset, int count) { Jedis j = getShard(key); return j.zrangeByScore(key, min, max, offset, count); } + public Set zrevrangeByScore(String key, double max, double min, + int offset, int count) { + Jedis j = getShard(key); + return j.zrevrangeByScore(key, max, min, offset, count); + } public Set zrangeByScoreWithScores(String key, double min, double max) { Jedis j = getShard(key); return j.zrangeByScoreWithScores(key, min, max); } + public Set zrevrangeByScoreWithScores(String key, double max, double min) { + Jedis j = getShard(key); + return j.zrevrangeByScoreWithScores(key, max, min); + } public Set zrangeByScoreWithScores(String key, double min, double max, int offset, int count) { Jedis j = getShard(key); return j.zrangeByScoreWithScores(key, min, max, offset, count); } + public Set zrevrangeByScoreWithScores(String key, double max, + double min, int offset, int count) { + Jedis j = getShard(key); + return j.zrevrangeByScoreWithScores(key, max, min, offset, count); + } public Long zremrangeByRank(String key, int start, int end) { Jedis j = getShard(key); @@ -386,4 +404,4 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands { Jedis j = getShard(key); return j.linsert(key, where, pivot, value); } -} \ No newline at end of file +} diff --git a/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java b/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java index 2c07bd9..aa1a88e 100644 --- a/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java +++ b/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java @@ -449,6 +449,83 @@ public class SortedSetCommandsTest extends JedisCommandTestBase { } + @Test + public void zrevrangebyscore() { + jedis.zadd("foo", 1.0d, "a"); + jedis.zadd("foo", 2.0d, "b"); + jedis.zadd("foo", 3.0d, "c"); + jedis.zadd("foo", 4.0d, "d"); + jedis.zadd("foo", 5.0d, "e"); + + Set range = jedis.zrevrangeByScore("foo", 3d, Double.NEGATIVE_INFINITY, 0, 1); + Set expected = new LinkedHashSet(); + expected.add("c"); + + assertEquals(expected, range); + + range = jedis.zrevrangeByScore("foo", 3.5d, Double.NEGATIVE_INFINITY, 0, 2); + expected = new LinkedHashSet(); + expected.add("c"); + expected.add("b"); + + assertEquals(expected, range); + + range = jedis.zrevrangeByScore("foo", 3.5d, Double.NEGATIVE_INFINITY, 1, 1); + expected = new LinkedHashSet(); + expected.add("b"); + + assertEquals(expected, range); + + range = jedis.zrevrangeByScore("foo", 4d, 2d); + expected = new LinkedHashSet(); + expected.add("d"); + expected.add("c"); + expected.add("b"); + + assertEquals(expected, range); + + range = jedis.zrevrangeByScore("foo", "+inf", "(4"); + expected = new LinkedHashSet(); + expected.add("e"); + + assertEquals(expected, range); + + // Binary + jedis.zadd(bfoo, 1d, ba); + jedis.zadd(bfoo, 10d, bb); + jedis.zadd(bfoo, 0.1d, bc); + jedis.zadd(bfoo, 2d, ba); + + Set brange = jedis.zrevrangeByScore(bfoo, 2d, 0d); + + Set bexpected = new LinkedHashSet(); + bexpected.add(bc); + bexpected.add(ba); + + assertEquals(bexpected, brange); + + brange = jedis.zrevrangeByScore(bfoo, 2d, 0d, 0, 1); + + bexpected = new LinkedHashSet(); + bexpected.add(ba); + + assertEquals(bexpected, brange); + + Set brange2 = jedis.zrevrangeByScore(bfoo, SafeEncoder + .encode("+inf"), SafeEncoder.encode("(2")); + + bexpected = new LinkedHashSet(); + bexpected.add(bb); + + assertEquals(bexpected, brange2); + + brange = jedis.zrevrangeByScore(bfoo, 2d, 0d, 1, 1); + bexpected = new LinkedHashSet(); + bexpected.add(bc); + + assertEquals(bexpected, brange); + } + @Test public void zrangebyscoreWithScores() { jedis.zadd("foo", 1d, "a"); @@ -509,6 +586,70 @@ public class SortedSetCommandsTest extends JedisCommandTestBase { } + @Test + public void zrevrangebyscoreWithScores() { + jedis.zadd("foo", 1.0d, "a"); + jedis.zadd("foo", 2.0d, "b"); + jedis.zadd("foo", 3.0d, "c"); + jedis.zadd("foo", 4.0d, "d"); + jedis.zadd("foo", 5.0d, "e"); + + Set range = jedis.zrevrangeByScoreWithScores("foo", 3d, Double.NEGATIVE_INFINITY, 0, 1); + Set expected = new LinkedHashSet(); + expected.add(new Tuple("c", 3.0d)); + + assertEquals(expected, range); + + range = jedis.zrevrangeByScoreWithScores("foo", 3.5d, Double.NEGATIVE_INFINITY, 0, 2); + expected = new LinkedHashSet(); + expected.add(new Tuple("c", 3.0d)); + expected.add(new Tuple("b", 2.0d)); + + assertEquals(expected, range); + + range = jedis.zrevrangeByScoreWithScores("foo", 3.5d, Double.NEGATIVE_INFINITY, 1, 1); + expected = new LinkedHashSet(); + expected.add(new Tuple("b", 2.0d)); + + assertEquals(expected, range); + + range = jedis.zrevrangeByScoreWithScores("foo", 4d, 2d); + expected = new LinkedHashSet(); + expected.add(new Tuple("d", 4.0d)); + expected.add(new Tuple("c", 3.0d)); + expected.add(new Tuple("b", 2.0d)); + + assertEquals(expected, range); + + // Binary + jedis.zadd(bfoo, 1d, ba); + jedis.zadd(bfoo, 10d, bb); + jedis.zadd(bfoo, 0.1d, bc); + jedis.zadd(bfoo, 2d, ba); + + Set brange = jedis.zrevrangeByScoreWithScores(bfoo, 2d, 0d); + + Set bexpected = new LinkedHashSet(); + bexpected.add(new Tuple(bc, 0.1d)); + bexpected.add(new Tuple(ba, 2d)); + + assertEquals(bexpected, brange); + + brange = jedis.zrevrangeByScoreWithScores(bfoo, 2d, 0d, 0, 1); + + bexpected = new LinkedHashSet(); + bexpected.add(new Tuple(ba, 2d)); + + assertEquals(bexpected, brange); + + brange = jedis.zrevrangeByScoreWithScores(bfoo, 2d, 0d, 1, 1); + + bexpected = new LinkedHashSet(); + bexpected.add(new Tuple(bc, 0.1d)); + + assertEquals(bexpected, brange); + } + @Test public void zremrangeByRank() { jedis.zadd("foo", 1d, "a");