Fixed - Spring Data Redis implementation doesn't implement geoSearch and geoSearchStore methods.

pull/4428/head
Nikita Koksharov
parent bd4db6fec8
commit c0a52668de

@ -15,6 +15,7 @@
*/
package org.redisson.spring.data.connection;
import io.netty.buffer.ByteBuf;
import org.redisson.Redisson;
import org.redisson.api.BatchOptions;
import org.redisson.api.BatchOptions.ExecutionMode;
@ -41,6 +42,10 @@ import org.springframework.data.redis.connection.*;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.data.redis.core.types.RedisClientInfo;
import org.springframework.data.redis.domain.geo.BoxShape;
import org.springframework.data.redis.domain.geo.GeoReference;
import org.springframework.data.redis.domain.geo.GeoShape;
import org.springframework.data.redis.domain.geo.RadiusShape;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
@ -2115,7 +2120,128 @@ public class RedissonConnection extends AbstractRedisConnection {
public Long geoRemove(byte[] key, byte[]... members) {
return zRem(key, members);
}
@Override
public GeoResults<GeoLocation<byte[]>> geoSearch(byte[] key, GeoReference<byte[]> reference, GeoShape predicate, GeoSearchCommandArgs args) {
Assert.notNull(args, "Args must not be null!");
Assert.notNull(key, "Key must not be null!");
Assert.notNull(predicate, "Shape must not be null!");
Assert.notNull(reference, "Reference must not be null!");
List<Object> commandParams = new ArrayList<>();
commandParams.add(key);
if (reference instanceof GeoReference.GeoCoordinateReference) {
GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference;
commandParams.add("FROMLONLAT");
commandParams.add(convert(ref.getLongitude()));
commandParams.add(convert(ref.getLatitude()));
} else if (reference instanceof GeoReference.GeoMemberReference) {
GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference;
commandParams.add("FROMMEMBER");
commandParams.add(encode(ref.getMember()));
}
if (predicate instanceof RadiusShape) {
commandParams.add("BYRADIUS");
RadiusShape shape = (RadiusShape) predicate;
commandParams.add(shape.getRadius().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (predicate instanceof BoxShape) {
BoxShape shape = (BoxShape) predicate;
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
if (args.hasSortDirection()) {
commandParams.add(args.getSortDirection());
}
if (args.getLimit() != null) {
commandParams.add("COUNT");
commandParams.add(args.getLimit());
if (args.hasAnyLimit()) {
commandParams.add("ANY");
}
}
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder);
commandParams.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(predicate.getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder);
commandParams.add("WITHDIST");
}
return read(key, ByteArrayCodec.INSTANCE, cmd, commandParams.toArray());
}
@Override
public Long geoSearchStore(byte[] destKey, byte[] key, GeoReference<byte[]> reference, GeoShape predicate, GeoSearchStoreCommandArgs args) {
Assert.notNull(args, "Args must not be null!");
Assert.notNull(key, "Key must not be null!");
Assert.notNull(destKey, "DestKey must not be null!");
Assert.notNull(predicate, "Shape must not be null!");
Assert.notNull(reference, "Reference must not be null!");
List<Object> commandParams = new ArrayList<>();
commandParams.add(destKey);
commandParams.add(key);
if (reference instanceof GeoReference.GeoCoordinateReference) {
GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference;
commandParams.add("FROMLONLAT");
commandParams.add(convert(ref.getLongitude()));
commandParams.add(convert(ref.getLatitude()));
} else if (reference instanceof GeoReference.GeoMemberReference) {
GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference;
commandParams.add("FROMMEMBER");
commandParams.add(encode(ref.getMember()));
}
if (predicate instanceof RadiusShape) {
RadiusShape shape = (RadiusShape) predicate;
commandParams.add("BYRADIUS");
commandParams.add(shape.getRadius().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (predicate instanceof BoxShape) {
BoxShape shape = (BoxShape) predicate;
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
if (args.hasSortDirection()) {
commandParams.add(args.getSortDirection());
}
if (args.getLimit() != null) {
commandParams.add("COUNT");
commandParams.add(args.getLimit());
if (args.hasAnyLimit()) {
commandParams.add("ANY");
}
}
if (args.isStoreDistance()) {
commandParams.add("STOREDIST");
}
return write(key, LongCodec.INSTANCE, RedisCommands.GEOSEARCHSTORE_STORE, commandParams.toArray());
}
private Metric convert(Metric metric) {
if (metric == Metrics.NEUTRAL) {
return DistanceUnit.METERS;
}
return metric;
}
private ByteBuf encode(Object value) {
return executorService.encode(ByteArrayCodec.INSTANCE, value);
}
private static final RedisCommand<Long> PFADD = new RedisCommand<Long>("PFADD");
@Override

@ -143,7 +143,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
});
}
private final MultiDecoder<GeoResults<GeoLocation<byte[]>>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder());
private final MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> postitionDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder());
@Override
public Flux<CommandResponse<GeoRadiusCommand, Flux<GeoResult<GeoLocation<ByteBuffer>>>>> geoRadius(
@ -164,13 +164,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
params.add(command.getDistance().getValue());
params.add(command.getDistance().getMetric().getAbbreviation());
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
RedisCommand<GeoResults<GeoLocation<ByteBuffer>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS_RO", postitionDecoder);
cmd = new RedisCommand<>("GEORADIUS_RO", postitionDecoder);
params.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS_RO", distanceDecoder);
MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEORADIUS_RO", distanceDecoder);
params.add("WITHDIST");
}
@ -206,13 +206,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
params.add(command.getDistance().getValue());
params.add(command.getDistance().getMetric().getAbbreviation());
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
RedisCommand<GeoResults<GeoLocation<ByteBuffer>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER_RO", postitionDecoder);
cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", postitionDecoder);
params.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER_RO", distanceDecoder);
MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", distanceDecoder);
params.add("WITHDIST");
}
@ -265,13 +265,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
commandParams.add("BYRADIUS");
RadiusShape shape = (RadiusShape) command.getShape();
commandParams.add(shape.getRadius().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (command.getShape() instanceof BoxShape) {
BoxShape shape = (BoxShape) command.getShape();
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
RedisGeoCommands.GeoSearchCommandArgs args = command.getArgs()
@ -286,12 +286,12 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
commandParams.add("ANY");
}
}
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
RedisCommand<GeoResults<GeoLocation<ByteBuffer>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder);
commandParams.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder());
MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder);
commandParams.add("WITHDIST");
}
@ -332,13 +332,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
RadiusShape shape = (RadiusShape) command.getShape();
commandParams.add("BYRADIUS");
commandParams.add(shape.getRadius().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (command.getShape() instanceof BoxShape) {
BoxShape shape = (BoxShape) command.getShape();
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
RedisGeoCommands.GeoSearchStoreCommandArgs args = command.getArgs()
@ -362,4 +362,11 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
});
}
private Metric convert(Metric metric) {
if (metric == Metrics.NEUTRAL) {
return RedisGeoCommands.DistanceUnit.METERS;
}
return metric;
}
}

@ -73,6 +73,9 @@ public class RedissonConnectionTest extends BaseConnectionTest {
RedisGeoCommands.GeoRadiusCommandArgs args = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs().includeCoordinates();
GeoResults<RedisGeoCommands.GeoLocation<String>> res = redisTemplate.opsForGeo().radius(key, within, args);
assertThat(res.getContent().get(0).getContent().getName()).isEqualTo("a");
GeoResults<RedisGeoCommands.GeoLocation<String>> res2 = redisTemplate.opsForGeo().search(key, within);
assertThat(res2.getContent().size()).isEqualTo(1);
}
@Test

@ -15,6 +15,7 @@
*/
package org.redisson.spring.data.connection;
import io.netty.buffer.ByteBuf;
import org.redisson.Redisson;
import org.redisson.api.BatchOptions;
import org.redisson.api.BatchOptions.ExecutionMode;
@ -41,6 +42,10 @@ import org.springframework.data.redis.connection.*;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.data.redis.core.types.RedisClientInfo;
import org.springframework.data.redis.domain.geo.BoxShape;
import org.springframework.data.redis.domain.geo.GeoReference;
import org.springframework.data.redis.domain.geo.GeoShape;
import org.springframework.data.redis.domain.geo.RadiusShape;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
@ -2115,7 +2120,127 @@ public class RedissonConnection extends AbstractRedisConnection {
public Long geoRemove(byte[] key, byte[]... members) {
return zRem(key, members);
}
@Override
public GeoResults<GeoLocation<byte[]>> geoSearch(byte[] key, GeoReference<byte[]> reference, GeoShape predicate, GeoSearchCommandArgs args) {
Assert.notNull(args, "Args must not be null!");
Assert.notNull(key, "Key must not be null!");
Assert.notNull(predicate, "Shape must not be null!");
Assert.notNull(reference, "Reference must not be null!");
List<Object> commandParams = new ArrayList<>();
commandParams.add(key);
if (reference instanceof GeoReference.GeoCoordinateReference) {
GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference;
commandParams.add("FROMLONLAT");
commandParams.add(convert(ref.getLongitude()));
commandParams.add(convert(ref.getLatitude()));
} else if (reference instanceof GeoReference.GeoMemberReference) {
GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference;
commandParams.add("FROMMEMBER");
commandParams.add(encode(ref.getMember()));
}
if (predicate instanceof RadiusShape) {
commandParams.add("BYRADIUS");
RadiusShape shape = (RadiusShape) predicate;
commandParams.add(shape.getRadius().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (predicate instanceof BoxShape) {
BoxShape shape = (BoxShape) predicate;
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
if (args.hasSortDirection()) {
commandParams.add(args.getSortDirection());
}
if (args.getLimit() != null) {
commandParams.add("COUNT");
commandParams.add(args.getLimit());
if (args.hasAnyLimit()) {
commandParams.add("ANY");
}
}
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder);
commandParams.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(predicate.getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder);
commandParams.add("WITHDIST");
}
return read(key, ByteArrayCodec.INSTANCE, cmd, commandParams.toArray());
}
@Override
public Long geoSearchStore(byte[] destKey, byte[] key, GeoReference<byte[]> reference, GeoShape predicate, GeoSearchStoreCommandArgs args) {
Assert.notNull(args, "Args must not be null!");
Assert.notNull(key, "Key must not be null!");
Assert.notNull(destKey, "DestKey must not be null!");
Assert.notNull(predicate, "Shape must not be null!");
Assert.notNull(reference, "Reference must not be null!");
List<Object> commandParams = new ArrayList<>();
commandParams.add(destKey);
commandParams.add(key);
if (reference instanceof GeoReference.GeoCoordinateReference) {
GeoReference.GeoCoordinateReference ref = (GeoReference.GeoCoordinateReference) reference;
commandParams.add("FROMLONLAT");
commandParams.add(convert(ref.getLongitude()));
commandParams.add(convert(ref.getLatitude()));
} else if (reference instanceof GeoReference.GeoMemberReference) {
GeoReference.GeoMemberReference ref = (GeoReference.GeoMemberReference) reference;
commandParams.add("FROMMEMBER");
commandParams.add(encode(ref.getMember()));
}
if (predicate instanceof RadiusShape) {
RadiusShape shape = (RadiusShape) predicate;
commandParams.add("BYRADIUS");
commandParams.add(shape.getRadius().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (predicate instanceof BoxShape) {
BoxShape shape = (BoxShape) predicate;
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
if (args.hasSortDirection()) {
commandParams.add(args.getSortDirection());
}
if (args.getLimit() != null) {
commandParams.add("COUNT");
commandParams.add(args.getLimit());
if (args.hasAnyLimit()) {
commandParams.add("ANY");
}
}
if (args.isStoreDistance()) {
commandParams.add("STOREDIST");
}
return write(key, LongCodec.INSTANCE, RedisCommands.GEOSEARCHSTORE_STORE, commandParams.toArray());
}
private Metric convert(Metric metric) {
if (metric == Metrics.NEUTRAL) {
return DistanceUnit.METERS;
}
return metric;
}
private ByteBuf encode(Object value) {
return executorService.encode(ByteArrayCodec.INSTANCE, value);
}
private static final RedisCommand<Long> PFADD = new RedisCommand<Long>("PFADD");
@Override

@ -143,7 +143,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
});
}
private final MultiDecoder<GeoResults<GeoLocation<byte[]>>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder());
private final MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> postitionDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder());
@Override
public Flux<CommandResponse<GeoRadiusCommand, Flux<GeoResult<GeoLocation<ByteBuffer>>>>> geoRadius(
@ -164,13 +164,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
params.add(command.getDistance().getValue());
params.add(command.getDistance().getMetric().getAbbreviation());
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
RedisCommand<GeoResults<GeoLocation<ByteBuffer>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS_RO", postitionDecoder);
cmd = new RedisCommand<>("GEORADIUS_RO", postitionDecoder);
params.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS_RO", distanceDecoder);
MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEORADIUS_RO", distanceDecoder);
params.add("WITHDIST");
}
@ -206,13 +206,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
params.add(command.getDistance().getValue());
params.add(command.getDistance().getMetric().getAbbreviation());
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
RedisCommand<GeoResults<GeoLocation<ByteBuffer>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER_RO", postitionDecoder);
cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", postitionDecoder);
params.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER_RO", distanceDecoder);
MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEORADIUSBYMEMBER_RO", distanceDecoder);
params.add("WITHDIST");
}
@ -265,13 +265,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
commandParams.add("BYRADIUS");
RadiusShape shape = (RadiusShape) command.getShape();
commandParams.add(shape.getRadius().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (command.getShape() instanceof BoxShape) {
BoxShape shape = (BoxShape) command.getShape();
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
RedisGeoCommands.GeoSearchCommandArgs args = command.getArgs()
@ -286,12 +286,12 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
commandParams.add("ANY");
}
}
RedisCommand<GeoResults<GeoLocation<byte[]>>> cmd;
RedisCommand<GeoResults<GeoLocation<ByteBuffer>>> cmd;
if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) {
cmd = new RedisCommand<>("GEOSEARCH", postitionDecoder);
commandParams.add("WITHCOORD");
} else {
MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder());
MultiDecoder<GeoResults<GeoLocation<ByteBuffer>>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getShape().getMetric()), new GeoDistanceDecoder());
cmd = new RedisCommand<>("GEOSEARCH", distanceDecoder);
commandParams.add("WITHDIST");
}
@ -332,13 +332,13 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
RadiusShape shape = (RadiusShape) command.getShape();
commandParams.add("BYRADIUS");
commandParams.add(shape.getRadius().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
} else if (command.getShape() instanceof BoxShape) {
BoxShape shape = (BoxShape) command.getShape();
commandParams.add("BYBOX");
commandParams.add(shape.getBoundingBox().getWidth().getValue());
commandParams.add(shape.getBoundingBox().getHeight().getValue());
commandParams.add(shape.getMetric().getAbbreviation());
commandParams.add(convert(shape.getMetric()).getAbbreviation());
}
RedisGeoCommands.GeoSearchStoreCommandArgs args = command.getArgs()
@ -362,4 +362,11 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements
});
}
private Metric convert(Metric metric) {
if (metric == Metrics.NEUTRAL) {
return RedisGeoCommands.DistanceUnit.METERS;
}
return metric;
}
}

Loading…
Cancel
Save