Geospatial items holder @author Nikita Koksharov @param value
| 37 | * @param <V> value |
| 38 | */ |
| 39 | public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V> { |
| 40 | |
| 41 | private static final MultiDecoder<Map<Object, Object>> POSTITION_DECODER = new ListMultiDecoder2( |
| 42 | new ObjectMapReplayDecoder2(), |
| 43 | new CodecDecoder(), |
| 44 | new GeoPositionDecoder()); |
| 45 | |
| 46 | private static final MultiDecoder<Map<Object, Object>> DISTANCE_DECODER = new ListMultiDecoder2( |
| 47 | new ObjectMapReplayDecoder2(), |
| 48 | new GeoDistanceDecoder()); |
| 49 | |
| 50 | private static final RedisCommand<Map<Object, Object>> GEORADIUS_RO_DISTANCE = new RedisCommand<Map<Object, Object>>( |
| 51 | "GEORADIUS_RO", DISTANCE_DECODER); |
| 52 | private static final RedisCommand<Map<Object, Object>> GEOSEARCH_DISTANCE = new RedisCommand<Map<Object, Object>>( |
| 53 | "GEOSEARCH", DISTANCE_DECODER); |
| 54 | private static final RedisCommand<Map<Object, Object>> GEOSEARCH_POS = new RedisCommand<Map<Object, Object>>( |
| 55 | "GEOSEARCH", POSTITION_DECODER); |
| 56 | private static final RedisCommand<Map<Object, Object>> GEORADIUS_RO_POS = new RedisCommand<Map<Object, Object>>( |
| 57 | "GEORADIUS_RO", POSTITION_DECODER); |
| 58 | private static final RedisCommand<Map<Object, Object>> GEORADIUSBYMEMBER_RO_DISTANCE = new RedisCommand<Map<Object, Object>>( |
| 59 | "GEORADIUSBYMEMBER_RO", DISTANCE_DECODER); |
| 60 | private static final RedisCommand<Map<Object, Object>> GEORADIUSBYMEMBER_RO_POS = new RedisCommand<Map<Object, Object>>( |
| 61 | "GEORADIUSBYMEMBER_RO", POSTITION_DECODER); |
| 62 | |
| 63 | public RedissonGeo(CommandAsyncExecutor connectionManager, String name, RedissonClient redisson) { |
| 64 | super(connectionManager, name, redisson); |
| 65 | } |
| 66 | |
| 67 | public RedissonGeo(Codec codec, CommandAsyncExecutor connectionManager, String name, RedissonClient redisson) { |
| 68 | super(codec, connectionManager, name, redisson); |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public RFuture<Long> addAsync(double longitude, double latitude, V member) { |
| 73 | return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.GEOADD, getRawName(), convert(longitude), |
| 74 | convert(latitude), encode(member)); |
| 75 | } |
| 76 | |
| 77 | private String convert(double longitude) { |
| 78 | return BigDecimal.valueOf(longitude).toPlainString(); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public long add(double longitude, double latitude, V member) { |
| 83 | return get(addAsync(longitude, latitude, member)); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public long add(GeoEntry... entries) { |
| 88 | return get(addAsync(entries)); |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public RFuture<Long> addAsync(GeoEntry... entries) { |
| 93 | return addAsync("", entries); |
| 94 | } |
| 95 | |
| 96 | private RFuture<Long> addAsync(String subCommand, GeoEntry... entries) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…