Fix Lettuce and RJC zRevRangeByScore incorrect parameter ordering

DATAREDIS-167

- Fix min/max parameter ordering

- Fix Lettuce NPEs during transactions

- Fix LettuceConnection not passing offset/count to zRevRangeByScoreWithScores
This commit is contained in:
Jennifer Hickey
2013-04-09 17:07:51 -07:00
parent a01db2b732
commit f6c44dba78
6 changed files with 169 additions and 17 deletions

View File

@@ -1476,10 +1476,11 @@ public class LettuceConnection implements RedisConnection {
public Set<byte[]> zRevRangeByScore(byte[] key, double min, double max, long offset, long count) {
try {
if (isPipelined()) {
pipeline(asyncConn.zrevrangebyscore(key, min, max, offset, count));
pipeline(asyncConn.zrevrangebyscore(key, max, min, offset, count));
return null;
}
return new LinkedHashSet<byte[]>(con.zrevrangebyscore(key, min, max, offset, count));
final List<byte[]> results = con.zrevrangebyscore(key, max, min, offset, count);
return results != null ? new LinkedHashSet<byte[]>(results) : null;
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
@@ -1489,10 +1490,11 @@ public class LettuceConnection implements RedisConnection {
public Set<byte[]> zRevRangeByScore(byte[] key, double min, double max) {
try {
if (isPipelined()) {
pipeline(asyncConn.zrevrangebyscore(key, min, max));
pipeline(asyncConn.zrevrangebyscore(key, max, min));
return null;
}
return new LinkedHashSet<byte[]>(con.zrevrangebyscore(key, min, max));
final List<byte[]> results = con.zrevrangebyscore(key, max, min);
return results != null ? new LinkedHashSet<byte[]>(results) : null;
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
@@ -1502,10 +1504,10 @@ public class LettuceConnection implements RedisConnection {
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) {
try {
if (isPipelined()) {
pipeline(asyncConn.zrevrangebyscoreWithScores(key, min, max));
pipeline(asyncConn.zrevrangebyscoreWithScores(key, max, min, offset, count));
return null;
}
return LettuceUtils.convertTuple(con.zrevrangebyscoreWithScores(key, min, max));
return LettuceUtils.convertTuple(con.zrevrangebyscoreWithScores(key, max, min, offset, count));
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
@@ -1515,10 +1517,10 @@ public class LettuceConnection implements RedisConnection {
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, double min, double max) {
try {
if (isPipelined()) {
pipeline(asyncConn.zrevrangebyscoreWithScores(key, min, max));
pipeline(asyncConn.zrevrangebyscoreWithScores(key, max, min));
return null;
}
return LettuceUtils.convertTuple(con.zrevrangebyscoreWithScores(key, min, max));
return LettuceUtils.convertTuple(con.zrevrangebyscoreWithScores(key, max, min));
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}

View File

@@ -1625,10 +1625,10 @@ public class RjcConnection implements RedisConnection {
try {
if (isPipelined()) {
pipeline.zrevrangeByScore(stringKey, minString, maxString, (int) offset, (int) count);
pipeline.zrevrangeByScore(stringKey, maxString, minString, (int) offset, (int) count);
return null;
}
return RjcUtils.convertToSet(session.zrevrangeByScore(stringKey, minString, maxString, (int) offset,
return RjcUtils.convertToSet(session.zrevrangeByScore(stringKey, maxString, minString, (int) offset,
(int) count));
} catch (Exception ex) {
throw convertRjcAccessException(ex);
@@ -1643,10 +1643,10 @@ public class RjcConnection implements RedisConnection {
try {
if (isPipelined()) {
pipeline.zrevrangeByScore(stringKey, minString, maxString);
pipeline.zrevrangeByScore(stringKey, maxString, minString);
return null;
}
return RjcUtils.convertToSet(session.zrevrangeByScore(stringKey, minString, maxString));
return RjcUtils.convertToSet(session.zrevrangeByScore(stringKey, maxString, minString));
} catch (Exception ex) {
throw convertRjcAccessException(ex);
}
@@ -1713,10 +1713,10 @@ public class RjcConnection implements RedisConnection {
try {
if (isPipelined()) {
pipeline.zrevrangeByScoreWithScores(stringKey, minString, maxString, (int) offset, (int) count);
pipeline.zrevrangeByScoreWithScores(stringKey, maxString, minString, (int) offset, (int) count);
return null;
}
return RjcUtils.convertElementScore(session.zrevrangeByScoreWithScores(stringKey, minString, maxString,
return RjcUtils.convertElementScore(session.zrevrangeByScoreWithScores(stringKey, maxString, minString,
(int) offset, (int) count));
} catch (Exception ex) {
throw convertRjcAccessException(ex);
@@ -1732,10 +1732,10 @@ public class RjcConnection implements RedisConnection {
try {
if (isPipelined()) {
pipeline.zrevrangeByScoreWithScores(stringKey, minString, maxString);
pipeline.zrevrangeByScoreWithScores(stringKey, maxString, minString);
return null;
}
return RjcUtils.convertElementScore(session.zrevrangeByScoreWithScores(stringKey, minString, maxString));
return RjcUtils.convertElementScore(session.zrevrangeByScoreWithScores(stringKey, maxString, minString));
} catch (Exception ex) {
throw convertRjcAccessException(ex);
}