RedissonSortedSet.tailSet fixed

pull/6/head
Nikita 11 years ago
parent 9711097627
commit bf0c4e1556

@ -433,6 +433,10 @@ public class RedissonSortedSet<V> extends RedissonObject implements RSortedSet<V
BinarySearchResult<V> res = binarySearch(value, connection);
if (res.getIndex() < 0) {
BinarySearchResult<V> element = getAtIndex(-res.getIndex() + indexDiff, connection);
if (element.getScore() == null && res.getScore() == null && tail) {
element = getAtIndex(-res.getIndex() - 2, connection);
return element.getScore();
}
return element.getScore();
}
int ind = res.getIndex();

@ -50,7 +50,7 @@ class RedissonSubSortedSet<V> implements SortedSet<V> {
private double getTailScore(RedisConnection<Object, V> connection) {
if (tailValue != null) {
return redissonSortedSet.score(tailValue, connection, 0, true);
return redissonSortedSet.score(tailValue, connection, 1, true);
}
return Double.MAX_VALUE;
}

@ -41,7 +41,7 @@ public class RedissonSortedSetTest extends BaseTest {
SortedSet<Integer> hs = set.headSet(6);
}
// @Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testTailSet() {
RSortedSet<Integer> set = redisson.getSortedSet("set");
@ -68,7 +68,7 @@ public class RedissonSortedSetTest extends BaseTest {
}
// @Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testHeadSet() {
RSortedSet<Integer> set = redisson.getSortedSet("set");
@ -89,6 +89,8 @@ public class RedissonSortedSetTest extends BaseTest {
set.remove(3);
MatcherAssert.assertThat(hs, Matchers.contains(0, 1));
hs.add(7);
}
@ -139,6 +141,8 @@ public class RedissonSortedSetTest extends BaseTest {
set.remove(3);
MatcherAssert.assertThat(hs, Matchers.contains(0, 1));
hs.add(7);
}

Loading…
Cancel
Save