RScoredSortedSet.valueRangeReversed and entryRangeReversed methods added. #629

pull/653/head
Nikita 8 years ago
parent 9807338a99
commit 0bf7e29baa

@ -372,6 +372,16 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGE, getName(), startIndex, endIndex);
}
@Override
public Collection<V> valueRangeReversed(int startIndex, int endIndex) {
return get(valueRangeReversedAsync(startIndex, endIndex));
}
@Override
public RFuture<Collection<V>> valueRangeReversedAsync(int startIndex, int endIndex) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZREVRANGE, getName(), startIndex, endIndex);
}
@Override
public Collection<ScoredEntry<V>> entryRange(int startIndex, int endIndex) {
return get(entryRangeAsync(startIndex, endIndex));
@ -382,6 +392,16 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGE_ENTRY, getName(), startIndex, endIndex, "WITHSCORES");
}
@Override
public Collection<ScoredEntry<V>> entryRangeReversed(int startIndex, int endIndex) {
return get(entryRangeReversedAsync(startIndex, endIndex));
}
@Override
public RFuture<Collection<ScoredEntry<V>>> entryRangeReversedAsync(int startIndex, int endIndex) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZREVRANGE_ENTRY, getName(), startIndex, endIndex, "WITHSCORES");
}
@Override
public Collection<V> valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive) {
return get(valueRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive));
@ -479,10 +499,12 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return get(revRankAsync(o));
}
@Override
public Long count(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive) {
return get(countAsync(startScore, startScoreInclusive, endScore, endScoreInclusive));
}
@Override
public RFuture<Long> countAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive) {
String startValue = value(startScore, startScoreInclusive);
String endValue = value(endScore, endScoreInclusive);

@ -103,8 +103,12 @@ public interface RScoredSortedSet<V> extends RScoredSortedSetAsync<V>, Iterable<
Double addScore(V object, Number value);
Collection<V> valueRange(int startIndex, int endIndex);
Collection<V> valueRangeReversed(int startIndex, int endIndex);
Collection<ScoredEntry<V>> entryRange(int startIndex, int endIndex);
Collection<ScoredEntry<V>> entryRangeReversed(int startIndex, int endIndex);
Collection<V> valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);

@ -78,8 +78,12 @@ public interface RScoredSortedSetAsync<V> extends RExpirableAsync {
RFuture<Double> addScoreAsync(V object, Number value);
RFuture<Collection<V>> valueRangeAsync(int startIndex, int endIndex);
RFuture<Collection<V>> valueRangeReversedAsync(int startIndex, int endIndex);
RFuture<Collection<ScoredEntry<V>>> entryRangeAsync(int startIndex, int endIndex);
RFuture<Collection<ScoredEntry<V>>> entryRangeReversedAsync(int startIndex, int endIndex);
RFuture<Collection<V>> valueRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive);

@ -111,7 +111,9 @@ public interface RedisCommands {
RedisCommand<List<Object>> ZRANGEBYLEX = new RedisCommand<List<Object>>("ZRANGEBYLEX", new ObjectListReplayDecoder<Object>());
RedisCommand<Set<Object>> ZRANGEBYSCORE = new RedisCommand<Set<Object>>("ZRANGEBYSCORE", new ObjectSetReplayDecoder<Object>());
RedisCommand<List<Object>> ZRANGEBYSCORE_LIST = new RedisCommand<List<Object>>("ZRANGEBYSCORE", new ObjectListReplayDecoder<Object>());
RedisCommand<List<Object>> ZREVRANGE = new RedisCommand<List<Object>>("ZREVRANGE", new ObjectListReplayDecoder<Object>());
RedisCommand<List<Object>> ZREVRANGEBYSCORE = new RedisCommand<List<Object>>("ZREVRANGEBYSCORE", new ObjectListReplayDecoder<Object>());
RedisCommand<List<ScoredEntry<Object>>> ZREVRANGE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZREVRANGE", new ScoredSortedSetReplayDecoder<Object>());
RedisCommand<List<ScoredEntry<Object>>> ZREVRANGEBYSCORE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZREVRANGEBYSCORE", 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>());

@ -542,6 +542,21 @@ public class RedissonScoredSortedSetTest extends BaseTest {
Collection<Integer> vals = set.valueRange(0, -1);
assertThat(vals).containsExactly(1, 2, 3, 4, 5);
}
@Test
public void testValueRangeReversed() {
RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("simple");
set.add(0, 1);
set.add(1, 2);
set.add(2, 3);
set.add(3, 4);
set.add(4, 5);
set.add(4, 5);
Collection<Integer> vals = set.valueRangeReversed(0, -1);
assertThat(vals).containsExactly(5, 4, 3, 2, 1);
}
@Test
public void testEntryRange() {
@ -559,6 +574,26 @@ public class RedissonScoredSortedSetTest extends BaseTest {
new ScoredEntry<Integer>(40D, 4),
new ScoredEntry<Integer>(50D, 5));
}
@Test
public void testEntryRangeReversed() {
RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("simple");
set.add(10, 1);
set.add(20, 2);
set.add(30, 3);
set.add(40, 4);
set.add(50, 5);
Collection<ScoredEntry<Integer>> vals = set.entryRangeReversed(0, -1);
assertThat(vals).containsExactly(
new ScoredEntry<Integer>(50D, 5),
new ScoredEntry<Integer>(40D, 4),
new ScoredEntry<Integer>(30D, 3),
new ScoredEntry<Integer>(20D, 2),
new ScoredEntry<Integer>(10D, 1)
);
}
@Test
public void testLexSortedSet() {

Loading…
Cancel
Save