From 4ab983353646a9e32495176c7d1402b3d3781a8c Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Sun, 15 Nov 2015 10:16:49 +0300 Subject: [PATCH] Revert "lexRange related methods with limit options and zrangebyscore support" --- .../org/redisson/RedissonLexSortedSet.java | 35 -------------- .../org/redisson/RedissonScoredSortedSet.java | 48 ------------------- .../client/protocol/RedisCommands.java | 2 - .../connection/SentinelConnectionManager.java | 13 +++-- .../java/org/redisson/core/RLexSortedSet.java | 6 --- .../org/redisson/core/RLexSortedSetAsync.java | 6 --- .../org/redisson/core/RScoredSortedSet.java | 8 ---- .../redisson/core/RScoredSortedSetAsync.java | 8 ---- .../redisson/RedissonScoredSortedSetTest.java | 48 ------------------- 9 files changed, 6 insertions(+), 168 deletions(-) diff --git a/src/main/java/org/redisson/RedissonLexSortedSet.java b/src/main/java/org/redisson/RedissonLexSortedSet.java index 38313f650..19c2428ac 100644 --- a/src/main/java/org/redisson/RedissonLexSortedSet.java +++ b/src/main/java/org/redisson/RedissonLexSortedSet.java @@ -103,41 +103,6 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet implem return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, toValue); } - @Override - public Collection lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count) { - return get(lexRangeAsync(fromElement, fromInclusive, toElement, toInclusive, offset, count)); - } - - @Override - public Collection lexRangeHead(String toElement, boolean toInclusive, int offset, int count) { - return get(lexRangeHeadAsync(toElement, toInclusive, offset, count)); - } - - @Override - public Future> lexRangeHeadAsync(String toElement, boolean toInclusive, int offset, int count) { - String toValue = value(toElement, toInclusive); - return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), "-", toValue, "LIMIT", offset, count); - } - - @Override - public Collection lexRangeTail(String fromElement, boolean fromInclusive, int offset, int count) { - return get(lexRangeTailAsync(fromElement, fromInclusive, offset, count)); - } - - @Override - public Future> lexRangeTailAsync(String fromElement, boolean fromInclusive, int offset, int count) { - String fromValue = value(fromElement, fromInclusive); - return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, "+", "LIMIT", offset, count); - } - - @Override - public Future> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count) { - String fromValue = value(fromElement, fromInclusive); - String toValue = value(toElement, toInclusive); - - return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, toValue, "LIMIT", offset, count); - } - @Override public int lexCountTail(String fromElement, boolean fromInclusive) { return get(lexCountTailAsync(fromElement, fromInclusive)); diff --git a/src/main/java/org/redisson/RedissonScoredSortedSet.java b/src/main/java/org/redisson/RedissonScoredSortedSet.java index 71d541e9d..ca810aaf7 100644 --- a/src/main/java/org/redisson/RedissonScoredSortedSet.java +++ b/src/main/java/org/redisson/RedissonScoredSortedSet.java @@ -321,52 +321,4 @@ public class RedissonScoredSortedSet extends RedissonExpirable implements RSc return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGE_ENTRY, getName(), startIndex, endIndex, "WITHSCORES"); } - @Override - public Collection valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive) { - return get(valueRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive)); - } - - @Override - public Future> valueRangeAsync(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.ZRANGEBYSCORE, getName(), startValue, endValue); - } - - @Override - public Collection> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive) { - return get(entryRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive)); - } - - @Override - public Future>> entryRangeAsync(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.ZRANGEBYSCORE_ENTRY, getName(), startValue, endValue, "WITHSCORES"); - } - - @Override - public Collection valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count) { - return get(valueRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive, offset, count)); - } - - @Override - public Future> valueRangeAsync(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.ZRANGEBYSCORE, getName(), startValue, endValue, "LIMIT", offset, count); - } - - @Override - public Collection> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count) { - return get(entryRangeAsync(startScore, startScoreInclusive, endScore, endScoreInclusive, offset, count)); - } - - @Override - public Future>> entryRangeAsync(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.ZRANGEBYSCORE_ENTRY, getName(), startValue, endValue, "WITHSCORES", "LIMIT", offset, count); - } - } diff --git a/src/main/java/org/redisson/client/protocol/RedisCommands.java b/src/main/java/org/redisson/client/protocol/RedisCommands.java index ab49a2d10..fa4064646 100644 --- a/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -72,9 +72,7 @@ public interface RedisCommands { RedisStrictCommand ZREMRANGEBYSCORE = new RedisStrictCommand("ZREMRANGEBYSCORE", new IntegerReplayConvertor()); RedisStrictCommand ZREMRANGEBYLEX = new RedisStrictCommand("ZREMRANGEBYLEX", new IntegerReplayConvertor()); RedisCommand> ZRANGEBYLEX = new RedisCommand>("ZRANGEBYLEX", new ObjectListReplayDecoder()); - RedisCommand> ZRANGEBYSCORE = new RedisCommand>("ZRANGEBYSCORE", new ObjectListReplayDecoder()); RedisCommand>> ZRANGE_ENTRY = new RedisCommand>>("ZRANGE", new ScoredSortedSetReplayDecoder()); - RedisCommand>> ZRANGEBYSCORE_ENTRY = new RedisCommand>>("ZRANGEBYSCORE", new ScoredSortedSetReplayDecoder()); RedisCommand> ZSCAN = new RedisCommand>("ZSCAN", new NestedMultiDecoder(new ObjectListReplayDecoder(), new ScoredSortedSetScanReplayDecoder()), ValueType.OBJECT); RedisStrictCommand ZINCRBY = new RedisStrictCommand("ZINCRBY", new DoubleReplayConvertor()); diff --git a/src/main/java/org/redisson/connection/SentinelConnectionManager.java b/src/main/java/org/redisson/connection/SentinelConnectionManager.java index c9d11e1f8..478f73b42 100755 --- a/src/main/java/org/redisson/connection/SentinelConnectionManager.java +++ b/src/main/java/org/redisson/connection/SentinelConnectionManager.java @@ -95,15 +95,14 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager { String port = map.get("port"); String flags = map.get("flags"); - String host = ip + ":" + port; + String host = ip + ":" + port; - c.addSlaveAddress(host); - slaves.put(host, true); - log.info("slave: {} added, params: {}", host, map); + c.addSlaveAddress(host); + slaves.put(host, true); + log.info("slave: {} added, params: {}", host, map); - if (flags.contains("s_down") || flags.contains("disconnected")) { - disconnectedSlaves.add(host); - } + if (flags.contains("s_down") || flags.contains("disconnected")) { + disconnectedSlaves.add(host); } } break; diff --git a/src/main/java/org/redisson/core/RLexSortedSet.java b/src/main/java/org/redisson/core/RLexSortedSet.java index 1f68f6180..b79424042 100644 --- a/src/main/java/org/redisson/core/RLexSortedSet.java +++ b/src/main/java/org/redisson/core/RLexSortedSet.java @@ -36,12 +36,6 @@ public interface RLexSortedSet extends RLexSortedSetAsync, Set, RExpirab Collection lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive); - Collection lexRangeTail(String fromElement, boolean fromInclusive, int offset, int count); - - Collection lexRangeHead(String toElement, boolean toInclusive, int offset, int count); - - Collection lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count); - int lexCount(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive); int rank(String o); diff --git a/src/main/java/org/redisson/core/RLexSortedSetAsync.java b/src/main/java/org/redisson/core/RLexSortedSetAsync.java index abdb18cb4..e83d058cb 100644 --- a/src/main/java/org/redisson/core/RLexSortedSetAsync.java +++ b/src/main/java/org/redisson/core/RLexSortedSetAsync.java @@ -37,12 +37,6 @@ public interface RLexSortedSetAsync extends RCollectionAsync { Future> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive); - Future> lexRangeTailAsync(String fromElement, boolean fromInclusive, int offset, int count); - - Future> lexRangeHeadAsync(String toElement, boolean toInclusive, int offset, int count); - - Future> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count); - Future lexCountAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive); Future rankAsync(String o); diff --git a/src/main/java/org/redisson/core/RScoredSortedSet.java b/src/main/java/org/redisson/core/RScoredSortedSet.java index 8f215b328..3f51debde 100644 --- a/src/main/java/org/redisson/core/RScoredSortedSet.java +++ b/src/main/java/org/redisson/core/RScoredSortedSet.java @@ -61,12 +61,4 @@ public interface RScoredSortedSet extends RScoredSortedSetAsync, Iterable< Collection> entryRange(int startIndex, int endIndex); - Collection valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); - - Collection> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); - - Collection valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); - - Collection> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); - } diff --git a/src/main/java/org/redisson/core/RScoredSortedSetAsync.java b/src/main/java/org/redisson/core/RScoredSortedSetAsync.java index 0bf2f9990..067dc1dd3 100644 --- a/src/main/java/org/redisson/core/RScoredSortedSetAsync.java +++ b/src/main/java/org/redisson/core/RScoredSortedSetAsync.java @@ -53,12 +53,4 @@ public interface RScoredSortedSetAsync extends RExpirableAsync { Future>> entryRangeAsync(int startIndex, int endIndex); - Future> valueRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); - - Future>> entryRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); - - Future> valueRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); - - Future>> entryRangeAsync(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); - } diff --git a/src/test/java/org/redisson/RedissonScoredSortedSetTest.java b/src/test/java/org/redisson/RedissonScoredSortedSetTest.java index 916b7d469..9ee92e651 100644 --- a/src/test/java/org/redisson/RedissonScoredSortedSetTest.java +++ b/src/test/java/org/redisson/RedissonScoredSortedSetTest.java @@ -14,7 +14,6 @@ import org.hamcrest.Matchers; import org.junit.Assert; import org.junit.Test; import org.redisson.client.protocol.ScoredEntry; -import org.redisson.core.RLexSortedSet; import org.redisson.core.RScoredSortedSet; import org.redisson.core.RSortedSet; @@ -439,53 +438,6 @@ public class RedissonScoredSortedSetTest extends BaseTest { new ScoredEntry(50D, 5))); } - @Test - public void testLexSortedSet() { - RLexSortedSet set = redisson.getLexSortedSet("simple"); - - set.add("a"); - set.add("b"); - set.add("c"); - set.add("d"); - set.add("e"); - - Collection r = set.lexRange("b", true, "e", false, 1, 2); - String[] a = r.toArray(new String[0]); - Assert.assertArrayEquals(new String[]{"c", "d"}, a); - } - - @Test - public void testScoredSortedSetValueRange() { - RScoredSortedSet 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 r = set.valueRange(1, true, 4, false, 1, 2); - String[] a = r.toArray(new String[0]); - Assert.assertArrayEquals(new String[]{"c", "d"}, a); - } - - @Test - public void testScoredSortedSetEntryRange() { - RScoredSortedSet 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> r = set.entryRange(1, true, 4, false, 1, 2); - ScoredEntry[] a = r.toArray(new ScoredEntry[0]); - Assert.assertEquals(2d, a[0].getScore(), 0); - Assert.assertEquals(3d, a[1].getScore(), 0); - Assert.assertEquals("c", a[0].getValue()); - Assert.assertEquals("d", a[1].getValue()); - } @Test public void testAddAndGet() throws InterruptedException {