Skip to content

Commit

Permalink
Fixed empty result handling for RGeo.radiusStoreTo methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita committed May 8, 2017
1 parent e544b8a commit f54c462
Show file tree
Hide file tree
Showing 37 changed files with 245 additions and 33 deletions.
36 changes: 18 additions & 18 deletions redisson/src/main/java/org/redisson/RedissonGeo.java
Expand Up @@ -407,63 +407,63 @@ public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double rad
} }


@Override @Override
public int radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit) { public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit)); return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit));
} }


@Override @Override
public RFuture<Integer> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit) { public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, getName(), convert(longitude), convert(latitude), radius, geoUnit, "STORE", destName); return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(), convert(longitude), convert(latitude), radius, geoUnit, "STORE", destName);
} }


@Override @Override
public int radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count) { public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, count)); return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, count));
} }


@Override @Override
public RFuture<Integer> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count) { public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, getName(), convert(longitude), convert(latitude), radius, geoUnit, "COUNT", count, "STORE", destName); return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(), convert(longitude), convert(latitude), radius, geoUnit, "COUNT", count, "STORE", destName);
} }


@Override @Override
public int radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) { public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, geoOrder, count)); return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, geoOrder, count));
} }


@Override @Override
public RFuture<Integer> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) { public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE_INT, getName(), convert(longitude), convert(latitude), radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName); return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(), convert(longitude), convert(latitude), radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName);
} }


@Override @Override
public int radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit) { public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit)); return get(radiusStoreToAsync(destName, member, radius, geoUnit));
} }


@Override @Override
public RFuture<Integer> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit) { public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, getName(), member, radius, geoUnit, "STORE", destName); return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(), member, radius, geoUnit, "STORE", destName);
} }


@Override @Override
public int radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, int count) { public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit, count)); return get(radiusStoreToAsync(destName, member, radius, geoUnit, count));
} }


@Override @Override
public RFuture<Integer> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, int count) { public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, getName(), member, radius, geoUnit, "COUNT", count, "STORE", destName); return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(), member, radius, geoUnit, "COUNT", count, "STORE", destName);
} }


@Override @Override
public int radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) { public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit, geoOrder, count)); return get(radiusStoreToAsync(destName, member, radius, geoUnit, geoOrder, count));
} }


@Override @Override
public RFuture<Integer> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) { public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE_INT, getName(), member, radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName); return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(), member, radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName);
} }


} }
12 changes: 6 additions & 6 deletions redisson/src/main/java/org/redisson/api/RGeo.java
Expand Up @@ -459,7 +459,7 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
* @param geoUnit - geo unit * @param geoUnit - geo unit
* @return length of result * @return length of result
*/ */
int radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit); long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -476,7 +476,7 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
int radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count); long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -495,7 +495,7 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
int radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count); long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -510,7 +510,7 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
* @param geoUnit - geo unit * @param geoUnit - geo unit
* @return length of result * @return length of result
*/ */
int radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit); long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -526,7 +526,7 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
int radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, int count); long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, int count);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -543,6 +543,6 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
int radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count); long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);


} }
12 changes: 6 additions & 6 deletions redisson/src/main/java/org/redisson/api/RGeoAsync.java
Expand Up @@ -457,7 +457,7 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @param geoUnit - geo unit * @param geoUnit - geo unit
* @return length of result * @return length of result
*/ */
RFuture<Integer> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit); RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -474,7 +474,7 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
RFuture<Integer> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count); RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -493,7 +493,7 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
RFuture<Integer> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count); RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -508,7 +508,7 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @param geoUnit - geo unit * @param geoUnit - geo unit
* @return length of result * @return length of result
*/ */
RFuture<Integer> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit); RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -524,7 +524,7 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
RFuture<Integer> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, int count); RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, int count);


/** /**
* Finds the members of a sorted set, which are within the * Finds the members of a sorted set, which are within the
Expand All @@ -541,6 +541,6 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @param count - result limit * @param count - result limit
* @return length of result * @return length of result
*/ */
RFuture<Integer> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count); RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);


} }
Expand Up @@ -45,6 +45,8 @@
import org.redisson.client.protocol.decoder.ListResultReplayDecoder; import org.redisson.client.protocol.decoder.ListResultReplayDecoder;
import org.redisson.client.protocol.decoder.ListScanResult; import org.redisson.client.protocol.decoder.ListScanResult;
import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder; import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder;
import org.redisson.client.protocol.decoder.Long2MultiDecoder;
import org.redisson.client.protocol.decoder.LongMultiDecoder;
import org.redisson.client.protocol.decoder.MapScanResult; import org.redisson.client.protocol.decoder.MapScanResult;
import org.redisson.client.protocol.decoder.MapScanResultReplayDecoder; import org.redisson.client.protocol.decoder.MapScanResultReplayDecoder;
import org.redisson.client.protocol.decoder.NestedMultiDecoder; import org.redisson.client.protocol.decoder.NestedMultiDecoder;
Expand Down Expand Up @@ -76,8 +78,8 @@ public interface RedisCommands {
RedisCommand<Double> GEODIST = new RedisCommand<Double>("GEODIST", new DoubleReplayConvertor(), 2, Arrays.asList(ValueType.OBJECT, ValueType.OBJECT, ValueType.STRING)); RedisCommand<Double> GEODIST = new RedisCommand<Double>("GEODIST", new DoubleReplayConvertor(), 2, Arrays.asList(ValueType.OBJECT, ValueType.OBJECT, ValueType.STRING));
RedisCommand<List<Object>> GEORADIUS = new RedisCommand<List<Object>>("GEORADIUS", new ObjectListReplayDecoder<Object>()); RedisCommand<List<Object>> GEORADIUS = new RedisCommand<List<Object>>("GEORADIUS", new ObjectListReplayDecoder<Object>());
RedisCommand<List<Object>> GEORADIUSBYMEMBER = new RedisCommand<List<Object>>("GEORADIUSBYMEMBER", new ObjectListReplayDecoder<Object>(), 2); RedisCommand<List<Object>> GEORADIUSBYMEMBER = new RedisCommand<List<Object>>("GEORADIUSBYMEMBER", new ObjectListReplayDecoder<Object>(), 2);
RedisStrictCommand<Integer> GEORADIUS_STORE_INT = new RedisStrictCommand<Integer>("GEORADIUS", new IntegerReplayConvertor()); RedisCommand<Object> GEORADIUS_STORE = new RedisCommand<Object>("GEORADIUS", new Long2MultiDecoder());
RedisStrictCommand<Integer> GEORADIUSBYMEMBER_STORE_INT = new RedisStrictCommand<Integer>("GEORADIUSBYMEMBER", new IntegerReplayConvertor(), 2); RedisCommand<Object> GEORADIUSBYMEMBER_STORE = new RedisCommand<Object>("GEORADIUSBYMEMBER", new Long2MultiDecoder(), 2);


RedisStrictCommand<Integer> KEYSLOT = new RedisStrictCommand<Integer>("CLUSTER", "KEYSLOT", new IntegerReplayConvertor()); RedisStrictCommand<Integer> KEYSLOT = new RedisStrictCommand<Integer>("CLUSTER", "KEYSLOT", new IntegerReplayConvertor());
RedisStrictCommand<RType> TYPE = new RedisStrictCommand<RType>("TYPE", new TypeConvertor()); RedisStrictCommand<RType> TYPE = new RedisStrictCommand<RType>("TYPE", new TypeConvertor());
Expand Down
Expand Up @@ -15,6 +15,11 @@
*/ */
package org.redisson.client.protocol.decoder; package org.redisson.client.protocol.decoder;


/**
*
* @author Nikita Koksharov
*
*/
public interface DecoderState { public interface DecoderState {


DecoderState copy(); DecoderState copy();
Expand Down
Expand Up @@ -23,8 +23,12 @@
import org.redisson.client.handler.State; import org.redisson.client.handler.State;


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;


/**
*
* @author Nikita Koksharov
*
*/
public class GeoDistanceDecoder implements MultiDecoder<List<Object>> { public class GeoDistanceDecoder implements MultiDecoder<List<Object>> {


private final ThreadLocal<Integer> pos = new ThreadLocal<Integer>(); private final ThreadLocal<Integer> pos = new ThreadLocal<Integer>();
Expand Down
Expand Up @@ -26,6 +26,11 @@


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;


/**
*
* @author Nikita Koksharov
*
*/
public class GeoDistanceMapDecoder implements MultiDecoder<Map<Object, Object>> { public class GeoDistanceMapDecoder implements MultiDecoder<Map<Object, Object>> {


private final ThreadLocal<Integer> pos = new ThreadLocal<Integer>(); private final ThreadLocal<Integer> pos = new ThreadLocal<Integer>();
Expand Down
Expand Up @@ -23,6 +23,11 @@


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;


/**
*
* @author Nikita Koksharov
*
*/
public class GeoMapReplayDecoder implements MultiDecoder<Map<Object, Object>> { public class GeoMapReplayDecoder implements MultiDecoder<Map<Object, Object>> {


@Override @Override
Expand Down
Expand Up @@ -24,6 +24,11 @@


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;


/**
*
* @author Nikita Koksharov
*
*/
public class GeoPositionDecoder implements MultiDecoder<GeoPosition> { public class GeoPositionDecoder implements MultiDecoder<GeoPosition> {


@Override @Override
Expand Down
Expand Up @@ -25,6 +25,11 @@


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;


/**
*
* @author Nikita Koksharov
*
*/
public class GeoPositionMapDecoder implements MultiDecoder<Map<Object, Object>> { public class GeoPositionMapDecoder implements MultiDecoder<Map<Object, Object>> {


private final List<Object> args; private final List<Object> args;
Expand Down
Expand Up @@ -15,6 +15,13 @@
*/ */
package org.redisson.client.protocol.decoder; package org.redisson.client.protocol.decoder;


/**
*
* @author Nikita Koksharov
*
* @param <K> key type
* @param <V> value type
*/
public class KeyValueMessage<K, V> { public class KeyValueMessage<K, V> {


private K key; private K key;
Expand Down
Expand Up @@ -22,6 +22,11 @@
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;


/**
*
* @author Nikita Koksharov
*
*/
public class KeyValueObjectDecoder implements MultiDecoder<Object> { public class KeyValueObjectDecoder implements MultiDecoder<Object> {


@Override @Override
Expand Down
Expand Up @@ -21,6 +21,11 @@


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;


/**
*
* @author Nikita Koksharov
*
*/
public class ListFirstObjectDecoder implements MultiDecoder<Object> { public class ListFirstObjectDecoder implements MultiDecoder<Object> {


@Override @Override
Expand Down
Expand Up @@ -21,6 +21,11 @@


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;


/**
*
* @author Nikita Koksharov
*
*/
public class ListIteratorReplayDecoder implements MultiDecoder<ListIteratorResult<Object>> { public class ListIteratorReplayDecoder implements MultiDecoder<ListIteratorResult<Object>> {


@Override @Override
Expand Down
Expand Up @@ -15,6 +15,12 @@
*/ */
package org.redisson.client.protocol.decoder; package org.redisson.client.protocol.decoder;


/**
*
* @author Nikita Koksharov
*
* @param <V> value type
*/
public class ListIteratorResult<V> { public class ListIteratorResult<V> {


private final V element; private final V element;
Expand Down
Expand Up @@ -22,6 +22,12 @@


import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;


/**
*
* @author Nikita Koksharov
*
* @param <T> type
*/
public class ListMultiDecoder<T> implements MultiDecoder<Object> { public class ListMultiDecoder<T> implements MultiDecoder<Object> {


private final MultiDecoder<?>[] decoders; private final MultiDecoder<?>[] decoders;
Expand Down
Expand Up @@ -24,6 +24,11 @@
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;


/**
*
* @author Nikita Koksharov
*
*/
public class ListResultReplayDecoder implements MultiDecoder<List<Map<Object, Object>>> { public class ListResultReplayDecoder implements MultiDecoder<List<Map<Object, Object>>> {


@Override @Override
Expand Down
Expand Up @@ -20,6 +20,12 @@


import org.redisson.RedisClientResult; import org.redisson.RedisClientResult;


/**
*
* @author Nikita Koksharov
*
* @param <V> value type
*/
public class ListScanResult<V> implements RedisClientResult { public class ListScanResult<V> implements RedisClientResult {


private final Long pos; private final Long pos;
Expand Down
Expand Up @@ -22,6 +22,11 @@
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;


/**
*
* @author Nikita Koksharov
*
*/
public class ListScanResultReplayDecoder implements MultiDecoder<ListScanResult<Object>> { public class ListScanResultReplayDecoder implements MultiDecoder<ListScanResult<Object>> {


@Override @Override
Expand Down

0 comments on commit f54c462

Please sign in to comment.