RScoredSortedSet.valueRangeReversed methods added. #406

pull/411/head
Nikita 9 years ago
parent dba305f00d
commit 2c8ad49088

@ -411,6 +411,21 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGEBYSCORE, getName(), startValue, endValue); return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGEBYSCORE, getName(), startValue, endValue);
} }
@Override
public Collection<V> valueRangeReversed(double startScore, boolean startScoreInclusive, double endScore,
boolean endScoreInclusive) {
return get(valueRangeReversedAsync(startScore, startScoreInclusive, endScore, endScoreInclusive));
}
@Override
public Future<Collection<V>> valueRangeReversedAsync(double startScore, boolean startScoreInclusive, double endScore,
boolean endScoreInclusive) {
String startValue = value(BigDecimal.valueOf(startScore).toPlainString(), startScoreInclusive);
String endValue = value(BigDecimal.valueOf(endScore).toPlainString(), endScoreInclusive);
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZREVRANGEBYSCORE, getName(), endValue, startValue);
}
@Override @Override
public Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive) { public Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive) {
return get(entryRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive)); return get(entryRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive));
@ -435,6 +450,18 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGEBYSCORE, getName(), startValue, endValue, "LIMIT", offset, count); return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGEBYSCORE, getName(), startValue, endValue, "LIMIT", offset, count);
} }
@Override
public Collection<V> valueRangeReversed(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count) {
return get(valueRangeReversedAsync(startScore, startScoreInclusive, endScore, endScoreInclusive, offset, count));
}
@Override
public Future<Collection<V>> valueRangeReversedAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count) {
String startValue = value(BigDecimal.valueOf(startScore).toPlainString(), startScoreInclusive);
String endValue = value(BigDecimal.valueOf(endScore).toPlainString(), endScoreInclusive);
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZREVRANGEBYSCORE, getName(), endValue, startValue, "LIMIT", offset, count);
}
@Override @Override
public Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count) { public Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count) {
return get(entryRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive, offset, count)); return get(entryRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive, offset, count));

@ -91,6 +91,7 @@ public interface RedisCommands {
RedisStrictCommand<Integer> ZREMRANGEBYLEX = new RedisStrictCommand<Integer>("ZREMRANGEBYLEX", new IntegerReplayConvertor()); RedisStrictCommand<Integer> ZREMRANGEBYLEX = new RedisStrictCommand<Integer>("ZREMRANGEBYLEX", new IntegerReplayConvertor());
RedisCommand<List<Object>> ZRANGEBYLEX = new RedisCommand<List<Object>>("ZRANGEBYLEX", new ObjectListReplayDecoder<Object>()); RedisCommand<List<Object>> ZRANGEBYLEX = new RedisCommand<List<Object>>("ZRANGEBYLEX", new ObjectListReplayDecoder<Object>());
RedisCommand<List<Object>> ZRANGEBYSCORE = new RedisCommand<List<Object>>("ZRANGEBYSCORE", new ObjectListReplayDecoder<Object>()); RedisCommand<List<Object>> ZRANGEBYSCORE = new RedisCommand<List<Object>>("ZRANGEBYSCORE", new ObjectListReplayDecoder<Object>());
RedisCommand<List<Object>> ZREVRANGEBYSCORE = new RedisCommand<List<Object>>("ZREVRANGEBYSCORE", new ObjectListReplayDecoder<Object>());
RedisCommand<List<ScoredEntry<Object>>> ZRANGE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZRANGE", new ScoredSortedSetReplayDecoder<Object>()); RedisCommand<List<ScoredEntry<Object>>> ZRANGE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZRANGE", new ScoredSortedSetReplayDecoder<Object>());
RedisCommand<List<ScoredEntry<Object>>> ZRANGEBYSCORE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZRANGEBYSCORE", new ScoredSortedSetReplayDecoder<Object>()); RedisCommand<List<ScoredEntry<Object>>> ZRANGEBYSCORE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZRANGEBYSCORE", new ScoredSortedSetReplayDecoder<Object>());
RedisCommand<ListScanResult<Object>> ZSCAN = new RedisCommand<ListScanResult<Object>>("ZSCAN", new NestedMultiDecoder(new ScoredSortedSetScanDecoder<Object>(), new ScoredSortedSetScanReplayDecoder()), ValueType.OBJECT); RedisCommand<ListScanResult<Object>> ZSCAN = new RedisCommand<ListScanResult<Object>>("ZSCAN", new NestedMultiDecoder(new ScoredSortedSetScanDecoder<Object>(), new ScoredSortedSetScanReplayDecoder()), ValueType.OBJECT);

@ -88,10 +88,14 @@ public interface RScoredSortedSet<V> extends RScoredSortedSetAsync<V>, Iterable<
Collection<V> valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); Collection<V> valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);
Collection<V> valueRangeReversed(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);
Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);
Collection<V> valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); Collection<V> valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count);
Collection<V> valueRangeReversed(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count);
Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); Collection<ScoredEntry<V>> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count);
} }

@ -82,10 +82,14 @@ public interface RScoredSortedSetAsync<V> extends RExpirableAsync {
Future<Collection<V>> valueRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); Future<Collection<V>> valueRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);
Future<Collection<V>> valueRangeReversedAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);
Future<Collection<ScoredEntry<V>>> entryRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); Future<Collection<ScoredEntry<V>>> entryRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);
Future<Collection<V>> valueRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); Future<Collection<V>> valueRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count);
Future<Collection<V>> valueRangeReversedAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count);
Future<Collection<ScoredEntry<V>>> entryRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); Future<Collection<ScoredEntry<V>>> entryRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count);
} }

@ -508,8 +508,8 @@ public class RedissonScoredSortedSetTest extends BaseTest {
} }
@Test @Test
public void testScoredSortedSetValueRange() { public void testScoredSortedSetValueRangeLimit() {
RScoredSortedSet<String> set = redisson.<String>getScoredSortedSet("simple"); RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a"); set.add(0, "a");
set.add(1, "b"); set.add(1, "b");
@ -518,13 +518,54 @@ public class RedissonScoredSortedSetTest extends BaseTest {
set.add(4, "e"); set.add(4, "e");
Collection<String> r = set.valueRange(1, true, 4, false, 1, 2); Collection<String> r = set.valueRange(1, true, 4, false, 1, 2);
String[] a = r.toArray(new String[0]); assertThat(r).containsExactly("c", "d");
Assert.assertArrayEquals(new String[]{"c", "d"}, a); }
@Test
public void testScoredSortedSetValueRange() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a");
set.add(1, "b");
set.add(2, "c");
set.add(3, "d");
set.add(4, "e");
Collection<String> r = set.valueRange(1, true, 4, false);
assertThat(r).containsExactly("b", "c", "d");
}
@Test
public void testScoredSortedSetValueRangeReversedLimit() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a");
set.add(1, "b");
set.add(2, "c");
set.add(3, "d");
set.add(4, "e");
Collection<String> r = set.valueRangeReversed(1, true, 4, false, 1, 2);
assertThat(r).containsExactly("c", "b");
}
@Test
public void testScoredSortedSetValueRangeReversed() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a");
set.add(1, "b");
set.add(2, "c");
set.add(3, "d");
set.add(4, "e");
Collection<String> r = set.valueRangeReversed(1, true, 4, false);
assertThat(r).containsExactly("d", "c", "b");
} }
@Test @Test
public void testScoredSortedSetEntryRange() { public void testScoredSortedSetEntryRange() {
RScoredSortedSet<String> set = redisson.<String>getScoredSortedSet("simple"); RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a"); set.add(0, "a");
set.add(1, "b"); set.add(1, "b");

Loading…
Cancel
Save