use of org.redisson.api.geo.GeoSearchNode in project redisson by redisson.
the class RedissonGeo method storeSortedSearchToAsync.
@Override
public RFuture<Long> storeSortedSearchToAsync(String destName, GeoSearchArgs args) {
GeoSearchNode node = (GeoSearchNode) args;
Map<GeoSearchNode.Params, Object> params = node.getParams();
List<Object> commandParams = new ArrayList<>();
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
commandParams.add(destName);
}
commandParams.add(getRawName());
RedisCommand command = null;
if (params.get(GeoSearchNode.Params.LATITUDE) != null && params.get(GeoSearchNode.Params.LONGITUDE) != null) {
command = RedisCommands.GEORADIUS_STORE;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = RedisCommands.GEOSEARCHSTORE_STORE;
commandParams.add("FROMLONLAT");
}
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LONGITUDE)));
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LATITUDE)));
}
if (params.get(GeoSearchNode.Params.MEMBER) != null) {
command = RedisCommands.GEORADIUSBYMEMBER_STORE;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = RedisCommands.GEOSEARCHSTORE_STORE;
commandParams.add("FROMMEMBER");
}
commandParams.add(encode(params.get(GeoSearchNode.Params.MEMBER)));
}
if (params.get(GeoSearchNode.Params.RADIUS) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add(params.get(GeoSearchNode.Params.RADIUS));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
}
if (params.get(GeoSearchNode.Params.HEIGHT) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add("BYBOX");
commandParams.add(params.get(GeoSearchNode.Params.WIDTH));
commandParams.add(params.get(GeoSearchNode.Params.HEIGHT));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
if (params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
}
if (params.get(GeoSearchNode.Params.COUNT) != null) {
commandParams.add("COUNT");
commandParams.add(params.get(GeoSearchNode.Params.COUNT));
if (params.get(GeoSearchNode.Params.COUNT_ANY) != null) {
commandParams.add("ANY");
}
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null && params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
commandParams.add("STOREDIST");
if (params.get(GeoSearchNode.Params.HEIGHT) == null) {
commandParams.add(destName);
}
return commandExecutor.writeAsync(getRawName(), LongCodec.INSTANCE, command, commandParams.toArray());
}
use of org.redisson.api.geo.GeoSearchNode in project redisson by redisson.
the class RedissonGeo method searchWithPositionAsync.
@Override
public RFuture<Map<V, GeoPosition>> searchWithPositionAsync(GeoSearchArgs args) {
GeoSearchNode node = (GeoSearchNode) args;
Map<GeoSearchNode.Params, Object> params = node.getParams();
List<Object> commandParams = new ArrayList<>();
commandParams.add(getRawName());
RedisCommand command = null;
if (params.get(GeoSearchNode.Params.LATITUDE) != null && params.get(GeoSearchNode.Params.LONGITUDE) != null) {
command = GEORADIUS_RO_POS;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = GEOSEARCH_POS;
commandParams.add("FROMLONLAT");
}
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LONGITUDE)));
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LATITUDE)));
}
if (params.get(GeoSearchNode.Params.MEMBER) != null) {
command = GEORADIUSBYMEMBER_RO_POS;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = GEOSEARCH_POS;
commandParams.add("FROMMEMBER");
}
commandParams.add(encode(params.get(GeoSearchNode.Params.MEMBER)));
}
if (params.get(GeoSearchNode.Params.RADIUS) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add(params.get(GeoSearchNode.Params.RADIUS));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
}
if (params.get(GeoSearchNode.Params.HEIGHT) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add("BYBOX");
commandParams.add(params.get(GeoSearchNode.Params.WIDTH));
commandParams.add(params.get(GeoSearchNode.Params.HEIGHT));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
if (params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null) {
commandParams.add("WITHCOORD");
}
if (params.get(GeoSearchNode.Params.COUNT) != null) {
commandParams.add("COUNT");
commandParams.add(params.get(GeoSearchNode.Params.COUNT));
if (params.get(GeoSearchNode.Params.COUNT_ANY) != null) {
commandParams.add("ANY");
}
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null && params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
commandParams.add("WITHCOORD");
}
return commandExecutor.readAsync(getRawName(), codec, command, commandParams.toArray());
}
use of org.redisson.api.geo.GeoSearchNode in project redisson by redisson.
the class RedissonGeo method searchAsync.
@Override
public RFuture<List<V>> searchAsync(GeoSearchArgs args) {
GeoSearchNode node = (GeoSearchNode) args;
Map<GeoSearchNode.Params, Object> params = node.getParams();
List<Object> commandParams = new ArrayList<>();
commandParams.add(getRawName());
RedisCommand command = null;
if (params.get(GeoSearchNode.Params.LATITUDE) != null && params.get(GeoSearchNode.Params.LONGITUDE) != null) {
command = RedisCommands.GEORADIUS_RO;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = RedisCommands.GEOSEARCH;
commandParams.add("FROMLONLAT");
}
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LONGITUDE)));
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LATITUDE)));
}
if (params.get(GeoSearchNode.Params.MEMBER) != null) {
command = RedisCommands.GEORADIUSBYMEMBER_RO;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = RedisCommands.GEOSEARCH;
commandParams.add("FROMMEMBER");
}
commandParams.add(encode(params.get(GeoSearchNode.Params.MEMBER)));
}
if (params.get(GeoSearchNode.Params.RADIUS) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add(params.get(GeoSearchNode.Params.RADIUS));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
}
if (params.get(GeoSearchNode.Params.HEIGHT) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add("BYBOX");
commandParams.add(params.get(GeoSearchNode.Params.WIDTH));
commandParams.add(params.get(GeoSearchNode.Params.HEIGHT));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
if (params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
}
if (params.get(GeoSearchNode.Params.COUNT) != null) {
commandParams.add("COUNT");
commandParams.add(params.get(GeoSearchNode.Params.COUNT));
if (params.get(GeoSearchNode.Params.COUNT_ANY) != null) {
commandParams.add("ANY");
}
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null && params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
return commandExecutor.readAsync(getRawName(), codec, command, commandParams.toArray());
}
use of org.redisson.api.geo.GeoSearchNode in project redisson by redisson.
the class RedissonGeo method storeSearchToAsync.
@Override
public RFuture<Long> storeSearchToAsync(String destName, GeoSearchArgs args) {
GeoSearchNode node = (GeoSearchNode) args;
Map<GeoSearchNode.Params, Object> params = node.getParams();
List<Object> commandParams = new ArrayList<>();
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
commandParams.add(destName);
}
commandParams.add(getRawName());
RedisCommand command = null;
if (params.get(GeoSearchNode.Params.LATITUDE) != null && params.get(GeoSearchNode.Params.LONGITUDE) != null) {
command = RedisCommands.GEORADIUS_STORE;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = RedisCommands.GEOSEARCHSTORE_STORE;
commandParams.add("FROMLONLAT");
}
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LONGITUDE)));
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LATITUDE)));
}
if (params.get(GeoSearchNode.Params.MEMBER) != null) {
command = RedisCommands.GEORADIUSBYMEMBER_STORE;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = RedisCommands.GEOSEARCHSTORE_STORE;
commandParams.add("FROMMEMBER");
}
commandParams.add(encode(params.get(GeoSearchNode.Params.MEMBER)));
}
if (params.get(GeoSearchNode.Params.RADIUS) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add(params.get(GeoSearchNode.Params.RADIUS));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
}
if (params.get(GeoSearchNode.Params.HEIGHT) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add("BYBOX");
commandParams.add(params.get(GeoSearchNode.Params.WIDTH));
commandParams.add(params.get(GeoSearchNode.Params.HEIGHT));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
if (params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
}
if (params.get(GeoSearchNode.Params.COUNT) != null) {
commandParams.add("COUNT");
commandParams.add(params.get(GeoSearchNode.Params.COUNT));
if (params.get(GeoSearchNode.Params.COUNT_ANY) != null) {
commandParams.add("ANY");
}
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null && params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null) {
commandParams.add("STORE");
commandParams.add(destName);
}
return commandExecutor.writeAsync(getRawName(), LongCodec.INSTANCE, command, commandParams.toArray());
}
use of org.redisson.api.geo.GeoSearchNode in project redisson by redisson.
the class RedissonGeo method searchWithDistanceAsync.
@Override
public RFuture<Map<V, Double>> searchWithDistanceAsync(GeoSearchArgs args) {
GeoSearchNode node = (GeoSearchNode) args;
Map<GeoSearchNode.Params, Object> params = node.getParams();
List<Object> commandParams = new ArrayList<>();
commandParams.add(getRawName());
RedisCommand command = null;
if (params.get(GeoSearchNode.Params.LATITUDE) != null && params.get(GeoSearchNode.Params.LONGITUDE) != null) {
command = GEORADIUS_RO_DISTANCE;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = GEOSEARCH_DISTANCE;
commandParams.add("FROMLONLAT");
}
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LONGITUDE)));
commandParams.add(convert((double) params.get(GeoSearchNode.Params.LATITUDE)));
}
if (params.get(GeoSearchNode.Params.MEMBER) != null) {
command = GEORADIUSBYMEMBER_RO_DISTANCE;
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
command = GEOSEARCH_DISTANCE;
commandParams.add("FROMMEMBER");
}
commandParams.add(encode(params.get(GeoSearchNode.Params.MEMBER)));
}
if (params.get(GeoSearchNode.Params.RADIUS) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add(params.get(GeoSearchNode.Params.RADIUS));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
}
if (params.get(GeoSearchNode.Params.HEIGHT) != null && params.get(GeoSearchNode.Params.UNIT) != null) {
commandParams.add("BYBOX");
commandParams.add(params.get(GeoSearchNode.Params.WIDTH));
commandParams.add(params.get(GeoSearchNode.Params.HEIGHT));
commandParams.add(params.get(GeoSearchNode.Params.UNIT));
if (params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null) {
commandParams.add("WITHDIST");
}
if (params.get(GeoSearchNode.Params.COUNT) != null) {
commandParams.add("COUNT");
commandParams.add(params.get(GeoSearchNode.Params.COUNT));
if (params.get(GeoSearchNode.Params.COUNT_ANY) != null) {
commandParams.add("ANY");
}
}
if (params.get(GeoSearchNode.Params.HEIGHT) == null && params.get(GeoSearchNode.Params.ORDER) != null) {
commandParams.add(params.get(GeoSearchNode.Params.ORDER));
}
if (params.get(GeoSearchNode.Params.HEIGHT) != null) {
commandParams.add("WITHDIST");
}
return commandExecutor.readAsync(getRawName(), codec, command, commandParams.toArray());
}
Aggregations