From fccab83a7a15c74bd4dbd4f1699fc833aa2e0148 Mon Sep 17 00:00:00 2001 From: Cory Sherman Date: Fri, 21 Apr 2017 11:13:26 -0700 Subject: [PATCH] WIP radiusStore() impl, only empty tests fail Failed Tests: 1. RedissonGeoTest.testRadiusStoreMemberEmpty org.redisson.client.RedisTimeoutException: Redis server response timeout (3000 ms) occured for command: (GEORADIUSBYMEMBER) with params: [test, Palermo, 200.0, km, STORE, test-store] at org.redisson.command.CommandAsyncService$10.run(CommandAsyncService.java:646) ... 2. RedissonGeoTest.testRadiusStoreEmpty org.redisson.client.RedisTimeoutException: Redis server response timeout (3000 ms) occured for command: (GEORADIUS) with params: [test, 15.0, 37.0, 200.0, km, STORE, test-store] at org.redisson.command.CommandAsyncService$10.run(CommandAsyncService.java:646) ... --- .../src/main/java/org/redisson/RedissonGeo.java | 14 +++++++------- .../redisson/client/protocol/RedisCommands.java | 4 ++-- .../redisson/RedissonScoredSortedSetTest.java | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonGeo.java b/redisson/src/main/java/org/redisson/RedissonGeo.java index 9c5f3605d..ae4c710eb 100644 --- a/redisson/src/main/java/org/redisson/RedissonGeo.java +++ b/redisson/src/main/java/org/redisson/RedissonGeo.java @@ -413,7 +413,7 @@ public class RedissonGeo extends RedissonScoredSortedSet implements RGeo radiusStoreAsync(String fromKey, double longitude, double latitude, double radius, GeoUnit geoUnit) { - return commandExecutor.writeAsync(fromKey, LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, fromKey, convert(longitude), convert(latitude), radius, geoUnit, "STORE", getName()); + return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, fromKey, convert(longitude), convert(latitude), radius, geoUnit, "STORE", getName()); } @Override @@ -423,7 +423,7 @@ public class RedissonGeo extends RedissonScoredSortedSet implements RGeo radiusStoreAsync(String fromKey, double longitude, double latitude, double radius, GeoUnit geoUnit, int count) { - return commandExecutor.writeAsync(fromKey, LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, fromKey, convert(longitude), convert(latitude), radius, geoUnit, "COUNT", count, "STORE", getName()); + return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, fromKey, convert(longitude), convert(latitude), radius, geoUnit, "COUNT", count, "STORE", getName()); } @Override @@ -433,7 +433,7 @@ public class RedissonGeo extends RedissonScoredSortedSet implements RGeo radiusStoreAsync(String fromKey, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) { - return commandExecutor.writeAsync(fromKey, LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, fromKey, convert(longitude), convert(latitude), radius, geoUnit, geoOrder, "COUNT", count, "STORE", getName()); + return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, fromKey, convert(longitude), convert(latitude), radius, geoUnit, geoOrder, "COUNT", count, "STORE", getName()); } @Override @@ -443,7 +443,7 @@ public class RedissonGeo extends RedissonScoredSortedSet implements RGeo radiusStoreAsync(String fromKey, V member, double radius, GeoUnit geoUnit) { - return commandExecutor.writeAsync(fromKey, codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, fromKey, member, radius, geoUnit, "STORE", getName()); + return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, fromKey, member, radius, geoUnit, "STORE", getName()); } @Override @@ -453,17 +453,17 @@ public class RedissonGeo extends RedissonScoredSortedSet implements RGeo radiusStoreAsync(String fromKey, V member, double radius, GeoUnit geoUnit, int count) { - return commandExecutor.writeAsync(fromKey, codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, fromKey, member, radius, geoUnit, "COUNT", count, "STORE", getName()); + return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, fromKey, member, radius, geoUnit, "COUNT", count, "STORE", getName()); } @Override public int radiusStore(String fromKey, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) { - return get(radiusStoreAsync(fromKey, member, radius, geoUnit, count)); + return get(radiusStoreAsync(fromKey, member, radius, geoUnit, geoOrder, count)); } @Override public RFuture radiusStoreAsync(String fromKey, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) { - return commandExecutor.writeAsync(fromKey, codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, fromKey, member, radius, geoUnit, geoOrder, "COUNT", count, "STORE", getName()); + return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, fromKey, member, radius, geoUnit, geoOrder, "COUNT", count, "STORE", getName()); } } diff --git a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java index 9eabd6509..c155aecc0 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -76,8 +76,8 @@ public interface RedisCommands { RedisCommand GEODIST = new RedisCommand("GEODIST", new DoubleReplayConvertor(), 2, Arrays.asList(ValueType.OBJECT, ValueType.OBJECT, ValueType.STRING)); RedisCommand> GEORADIUS = new RedisCommand>("GEORADIUS", new ObjectListReplayDecoder()); RedisCommand> GEORADIUSBYMEMBER = new RedisCommand>("GEORADIUSBYMEMBER", new ObjectListReplayDecoder(), 2); - RedisCommand GEORADIUS_STORE_INT = new RedisStrictCommand("GEORADIUS", new IntegerReplayConvertor()); - RedisCommand GEORADIUSBYMEMBER_STORE_INT = new RedisStrictCommand("GEORADIUSBYMEMBER", new IntegerReplayConvertor(), 2); + RedisStrictCommand GEORADIUS_STORE_INT = new RedisStrictCommand("GEORADIUS", new IntegerReplayConvertor()); + RedisStrictCommand GEORADIUSBYMEMBER_STORE_INT = new RedisStrictCommand("GEORADIUSBYMEMBER", new IntegerReplayConvertor(), 2); RedisStrictCommand KEYSLOT = new RedisStrictCommand("CLUSTER", "KEYSLOT", new IntegerReplayConvertor()); RedisStrictCommand TYPE = new RedisStrictCommand("TYPE", new TypeConvertor()); diff --git a/redisson/src/test/java/org/redisson/RedissonScoredSortedSetTest.java b/redisson/src/test/java/org/redisson/RedissonScoredSortedSetTest.java index 0d9317848..cf7d0d3c6 100644 --- a/redisson/src/test/java/org/redisson/RedissonScoredSortedSetTest.java +++ b/redisson/src/test/java/org/redisson/RedissonScoredSortedSetTest.java @@ -974,6 +974,22 @@ public class RedissonScoredSortedSetTest extends BaseTest { assertThat(out.getScore("two")).isEqualTo(4); } + @Test + public void testIntersectionEmpty() { + RScoredSortedSet set1 = redisson.getScoredSortedSet("simple1"); + set1.add(1, "one"); + set1.add(2, "two"); + + RScoredSortedSet set2 = redisson.getScoredSortedSet("simple2"); + set2.add(3, "three"); + set2.add(4, "four"); + + RScoredSortedSet out = redisson.getScoredSortedSet("out"); + assertThat(out.intersection(set1.getName(), set2.getName())).isEqualTo(0); + + assertThat(out.readAll()).isEmpty(); + } + @Test public void testIntersectionWithWeight() { RScoredSortedSet set1 = redisson.getScoredSortedSet("simple1");