DATAREDIS-352 - Enhance range options for ZSET.
We now allow usage of Range and Limit types (newly introduced for ZRANGEBYLEX) on mostly all ZSET range operations. Extracted constants for plus/minus and -inf/+inf expressions. Original pull request: #138.
This commit is contained in:
committed by
Thomas Darimont
parent
3d4f62f5b7
commit
283a9638f2
@@ -831,5 +831,55 @@ public class RedisConnectionUnitTests {
|
||||
public Set<byte[]> zRangeByLex(byte[] key, Range range, Limit limit) {
|
||||
return delegate.zRangeByLex(key, range, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
|
||||
return delegate.zRangeByScoreWithScores(key, range, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRevRangeByScore(byte[] key, Range range) {
|
||||
return delegate.zRevRangeByScore(key, range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRevRangeByScore(byte[] key, Range range, Limit limit) {
|
||||
return delegate.zRevRangeByScore(key, range, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
|
||||
return delegate.zRevRangeByScoreWithScores(key, range, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCount(byte[] key, Range range) {
|
||||
return delegate.zCount(key, range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRangeByScore(byte[] key, Range range) {
|
||||
return delegate.zRemRangeByScore(key, range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, Range range) {
|
||||
return delegate.zRangeByScore(key, range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, Range range, Limit limit) {
|
||||
return delegate.zRangeByScore(key, range, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range) {
|
||||
return delegate.zRangeByScoreWithScores(key, range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range) {
|
||||
return delegate.zRevRangeByScoreWithScores(key, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,77 @@ public class JedisConvertersUnitTests {
|
||||
JedisConverters.boundaryToBytesForZRangeByLex(Range.range().gt(new Date()).getMin(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-352
|
||||
*/
|
||||
@Test
|
||||
public void boundaryToBytesForZRangeByShouldReturnDefaultValueWhenBoundaryIsNull() {
|
||||
|
||||
byte[] defaultValue = "tyrion".getBytes();
|
||||
|
||||
assertThat(JedisConverters.boundaryToBytesForZRange(null, defaultValue), is(defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-352
|
||||
*/
|
||||
@Test
|
||||
public void boundaryToBytesForZRangeByShouldReturnDefaultValueWhenBoundaryValueIsNull() {
|
||||
|
||||
byte[] defaultValue = "tyrion".getBytes();
|
||||
|
||||
assertThat(JedisConverters.boundaryToBytesForZRange(Range.unbounded().getMax(), defaultValue), is(defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-352
|
||||
*/
|
||||
@Test
|
||||
public void boundaryToBytesForZRangeByShouldReturnValueCorrectlyWhenBoundaryIsIncluing() {
|
||||
|
||||
assertThat(
|
||||
JedisConverters.boundaryToBytesForZRange(Range.range().gte(JedisConverters.toBytes("a")).getMin(), null),
|
||||
is(JedisConverters.toBytes("a")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-352
|
||||
*/
|
||||
@Test
|
||||
public void boundaryToBytesForZRangeByShouldReturnValueCorrectlyWhenBoundaryIsExcluding() {
|
||||
|
||||
assertThat(JedisConverters.boundaryToBytesForZRange(Range.range().gt(JedisConverters.toBytes("a")).getMin(), null),
|
||||
is(JedisConverters.toBytes("(a")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-352
|
||||
*/
|
||||
@Test
|
||||
public void boundaryToBytesForZRangeByShouldReturnValueCorrectlyWhenBoundaryIsAString() {
|
||||
|
||||
assertThat(JedisConverters.boundaryToBytesForZRange(Range.range().gt("a").getMin(), null),
|
||||
is(JedisConverters.toBytes("(a")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-352
|
||||
*/
|
||||
@Test
|
||||
public void boundaryToBytesForZRangeByShouldReturnValueCorrectlyWhenBoundaryIsANumber() {
|
||||
|
||||
assertThat(JedisConverters.boundaryToBytesForZRange(Range.range().gt(1L).getMin(), null),
|
||||
is(JedisConverters.toBytes("(1")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-352
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void boundaryToBytesForZRangeByShouldThrowExceptionWhenBoundaryHoldsUnknownType() {
|
||||
JedisConverters.boundaryToBytesForZRange(Range.range().gt(new Date()).getMin(), null);
|
||||
}
|
||||
|
||||
private void verifyRedisServerInfo(RedisServer server, Map<String, String> values) {
|
||||
|
||||
for (Map.Entry<String, String> entry : values.entrySet()) {
|
||||
|
||||
Reference in New Issue
Block a user