@Override public DecoderState copy() { return new NestedDecoderState(index); }
@Override public Decoder<Object> getDecoder(int paramNum, State state) { if (paramNum == 0) { NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); } else { s.incIndex(); s.resetPartsIndex(); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; Decoder<Object> decoder = decoders[index].getDecoder(paramNum, state); if (decoder == RESET) { NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state); NestedDecoderState s = getDecoder(state); s.setIndex(1); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state);
@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 ListScanResult<Object> decode(List<Object> parts, State state) { return new ListScanResult<Object>((Long)parts.get(0), (List<Object>)parts.get(1)); }
@Override public Decoder<Object> getDecoder(int paramNum, State state) { if (paramNum % 2 != 0) { return DoubleCodec.INSTANCE.getValueDecoder(); } return super.getDecoder(paramNum, state); }
@Override public MapCacheScanResult<Object, Object> decode(List<Object> parts, State state) { Long pos = (Long)parts.get(0); Map<Object, Object> values = (Map<Object, Object>)parts.get(1); List<Object> idleKeys = (List<Object>) parts.get(2); return new MapCacheScanResult<Object, Object>(pos, values, idleKeys); }
@Override public MapScanResult<Object, Object> decode(List<Object> parts, State state) { return new MapScanResult<Object, Object>((Long)parts.get(0), (Map<Object, Object>)parts.get(1)); }
@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 Decoder<Object> getDecoder(int paramNum, State state) { if (paramNum == 0) { NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); } else { s.incIndex(); s.resetPartsIndex(); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; Decoder<Object> decoder = decoders[index].getDecoder(paramNum, state); if (decoder == RESET) { NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state); NestedDecoderState s = getDecoder(state); s.setIndex(1); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state);
@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 DecoderState copy() { return new NestedDecoderState(index); }
@Override public ListScanResult<Object> decode(List<Object> parts, State state) { return new ListScanResult<Object>((Long)parts.get(0), (List<Object>)parts.get(1)); }
@Override public Decoder<Object> getDecoder(int paramNum, State state) { if (paramNum % 2 != 0) { return DoubleCodec.INSTANCE.getValueDecoder(); } return super.getDecoder(paramNum, state); }
@Override public MapCacheScanResult<Object, Object> decode(List<Object> parts, State state) { Long pos = (Long)parts.get(0); Map<Object, Object> values = (Map<Object, Object>)parts.get(1); List<Object> idleKeys = (List<Object>) parts.get(2); return new MapCacheScanResult<Object, Object>(pos, values, idleKeys); }
@Override public MapScanResult<Object, Object> decode(List<Object> parts, State state) { return new MapScanResult<Object, Object>((Long)parts.get(0), (Map<Object, Object>)parts.get(1)); }
protected final NestedDecoderState getDecoder(State state) { NestedDecoderState ds = state.getDecoderState(); if (ds == null) { ds = new NestedDecoderState(); state.setDecoderState(ds); } return ds; }
@Override public ListScanResult<Object> decode(List<Object> parts, State state) { List<Object> values = (List<Object>)parts.get(1); for (int i = 1; i < values.size(); i++) { values.remove(i); } return new ListScanResult<Object>((Long)parts.get(0), values); }
protected final NestedDecoderState getDecoder(State state) { NestedDecoderState ds = state.getDecoderState(); if (ds == null) { ds = new NestedDecoderState(); state.setDecoderState(ds); } return ds; }
@Override public ListScanResult<Object> decode(List<Object> parts, State state) { List<Object> values = (List<Object>)parts.get(1); for (int i = 1; i < values.size(); i++) { values.remove(i); } return new ListScanResult<Object>((Long)parts.get(0), values); }