@Override public List<Point> geoPos(byte[] key, byte[]... members) { List<Object> params = new ArrayList<Object>(members.length + 1); params.add(key); params.addAll(Arrays.asList(members)); MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder(new PointDecoder(), new ObjectListReplayDecoder2(ListMultiDecoder.RESET)); RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOPOS", decoder); return read(key, StringCodec.INSTANCE, command, params.toArray()); }
@Override public Decoder<Object> getDecoder(int paramNum, State state) { if (paramNum == 0) { NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); NestedDecoderState s = getDecoder(state); s.setIndex(1); int ind = s.getIndex();
@Override public List<Point> geoPos(byte[] key, byte[]... members) { List<Object> params = new ArrayList<Object>(members.length + 1); params.add(key); params.addAll(Arrays.asList(members)); MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder(new PointDecoder(), new ObjectListReplayDecoder2(ListMultiDecoder.RESET)); RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOPOS", decoder); return read(key, StringCodec.INSTANCE, command, params.toArray()); }
@Override public Decoder<Object> getDecoder(int paramNum, State state) { if (paramNum == 0) { NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); NestedDecoderState s = getDecoder(state); s.setIndex(1); int ind = s.getIndex();
@Override public RFuture<Map<V, GeoPosition>> posAsync(V... members) { List<Object> params = new ArrayList<Object>(members.length + 1); params.add(getName()); for (Object member : members) { params.add(encode(member)); } MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder(0, new GeoPositionDecoder(), // new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoPositionMapDecoder((List<Object>)Arrays.asList(members))); RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOPOS", decoder); return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, command, params.toArray()); }
@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
@Override public RFuture<Map<V, GeoPosition>> posAsync(V... members) { List<Object> params = new ArrayList<Object>(members.length + 1); params.add(getName()); for (Object member : members) { params.add(encode(member)); } MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder(0, new GeoPositionDecoder(), // new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoPositionMapDecoder((List<Object>)Arrays.asList(members))); RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOPOS", decoder); return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, command, params.toArray()); }
@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
@Override public GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, Distance radius, GeoRadiusCommandArgs args) { List<Object> params = new ArrayList<Object>(); params.add(key); params.add(member); params.add(radius.getValue()); params.add(radius.getMetric().getAbbreviation()); RedisCommand<GeoResults<GeoLocation<byte[]>>> command; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER", postitionDecoder); params.add("WITHCOORD"); } else { MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(radius.getMetric())); command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER", distanceDecoder); params.add("WITHDIST"); } if (args.getLimit() != null) { params.add("COUNT"); params.add(args.getLimit()); } if (args.getSortDirection() != null) { params.add(args.getSortDirection().name()); } return read(key, ByteArrayCodec.INSTANCE, command, params.toArray()); }
@Override public Decoder<Object> getDecoder(int paramNum, State state) { if (paramNum == 0) { NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); NestedDecoderState s = getDecoder(state); s.setIndex(1); int ind = s.getIndex();
@Override public GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, Distance radius, GeoRadiusCommandArgs args) { List<Object> params = new ArrayList<Object>(); params.add(key); params.add(member); params.add(radius.getValue()); params.add(radius.getMetric().getAbbreviation()); RedisCommand<GeoResults<GeoLocation<byte[]>>> command; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER", postitionDecoder); params.add("WITHCOORD"); } else { MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(radius.getMetric())); command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUSBYMEMBER", distanceDecoder); params.add("WITHDIST"); } if (args.getLimit() != null) { params.add("COUNT"); params.add(args.getLimit()); } if (args.getSortDirection() != null) { params.add(args.getSortDirection().name()); } return read(key, ByteArrayCodec.INSTANCE, command, params.toArray()); }
@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
@Override public GeoResults<GeoLocation<byte[]>> geoRadius(byte[] key, Circle within, GeoRadiusCommandArgs args) { List<Object> params = new ArrayList<Object>(); params.add(key); params.add(convert(within.getCenter().getX())); params.add(convert(within.getCenter().getY())); params.add(within.getRadius().getValue()); params.add(within.getRadius().getMetric().getAbbreviation()); RedisCommand<GeoResults<GeoLocation<byte[]>>> command; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS", postitionDecoder); params.add("WITHCOORD"); } else { MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(within.getRadius().getMetric())); command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS", distanceDecoder); params.add("WITHDIST"); } if (args.getLimit() != null) { params.add("COUNT"); params.add(args.getLimit()); } if (args.getSortDirection() != null) { params.add(args.getSortDirection().name()); } return read(key, ByteArrayCodec.INSTANCE, command, params.toArray()); }
@Override public GeoResults<GeoLocation<byte[]>> geoRadius(byte[] key, Circle within, GeoRadiusCommandArgs args) { List<Object> params = new ArrayList<Object>(); params.add(key); params.add(convert(within.getCenter().getX())); params.add(convert(within.getCenter().getY())); params.add(within.getRadius().getValue()); params.add(within.getRadius().getMetric().getAbbreviation()); RedisCommand<GeoResults<GeoLocation<byte[]>>> command; if (args.getFlags().contains(GeoRadiusCommandArgs.Flag.WITHCOORD)) { command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS", postitionDecoder); params.add("WITHCOORD"); } else { MultiDecoder<GeoResults<GeoLocation<byte[]>>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(within.getRadius().getMetric())); command = new RedisCommand<GeoResults<GeoLocation<byte[]>>>("GEORADIUS", distanceDecoder); params.add("WITHDIST"); } if (args.getLimit() != null) { params.add("COUNT"); params.add(args.getLimit()); } if (args.getSortDirection() != null) { params.add(args.getSortDirection().name()); } return read(key, ByteArrayCodec.INSTANCE, command, params.toArray()); }
new ListMultiDecoder(new LongMultiDecoder(), new ObjectMapDecoder(codec), new ObjectListDecoder(codec), new MapCacheScanResultReplayDecoder()), ValueType.MAP); RFuture<MapCacheScanResult<Object, Object>> f = commandExecutor.evalReadAsync(client, name, codec, EVAL_HSCAN, "local result = {}; "
new ListMultiDecoder(new LongMultiDecoder(), new ObjectMapDecoder(codec), new ObjectListDecoder(codec), new MapCacheScanResultReplayDecoder()), ValueType.MAP); RFuture<MapCacheScanResult<Object, Object>> f = commandExecutor.evalReadAsync(client, name, codec, EVAL_HSCAN, "local result = {}; "
@Override public RFuture<Map<V, GeoPosition>> posAsync(V... members) { List<Object> params = new ArrayList<Object>(members.length + 1); params.add(getName()); for (Object member : members) { params.add(encode(member)); } MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder(0, new GeoPositionDecoder(), // new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoPositionMapDecoder((List<Object>)Arrays.asList(members))); RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOPOS", decoder); return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, command, params.toArray()); }
new ListMultiDecoder(new LongMultiDecoder(), new ObjectMapDecoder(codec), new ObjectListDecoder(codec), new MapCacheScanResultReplayDecoder()), ValueType.MAP); RFuture<MapCacheScanResult<Object, Object>> f = commandExecutor.evalReadAsync(client, name, codec, EVAL_HSCAN, "local result = {}; "