map and list scanners implemented

pull/243/head
Nikita 10 years ago
parent 0b7e3c70bf
commit a5832a2631

@ -1,30 +0,0 @@
package com.lambdaworks.redis.output;
import java.util.LinkedHashMap;
import java.util.Map;
public class MapScanResult<K, V> {
private Long pos;
private K lastKey;
private Map<K, V> values = new LinkedHashMap<K, V>();
public void setPos(Long pos) {
this.pos = pos;
}
public Long getPos() {
return pos;
}
public void addKey(K key) {
lastKey = key;
}
public void addValue(V value) {
values.put(lastKey, value);
}
public Map<K, V> getMap() {
return values;
}
}

@ -0,0 +1,23 @@
package org.redisson.client.protocol.decoder;
import java.util.List;
public class ListScanResult<V> {
private final Long pos;
private final List<V> values;
public ListScanResult(Long pos, List<V> values) {
this.pos = pos;
this.values = values;
}
public Long getPos() {
return pos;
}
public List<V> getValues() {
return values;
}
}

@ -0,0 +1,25 @@
package org.redisson.client.protocol.decoder;
import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
public class ListScanResultReplayDecoder implements MultiDecoder<ListScanResult<Object>> {
@Override
public Object decode(ByteBuf buf) {
return Long.valueOf(buf.toString(CharsetUtil.UTF_8));
}
@Override
public ListScanResult<Object> decode(List<Object> parts) {
return new ListScanResult<Object>((Long)parts.get(0), (List<Object>)parts.get(1));
}
@Override
public boolean isApplicable(int paramNum) {
return paramNum == 0;
}
}

@ -0,0 +1,24 @@
package org.redisson.client.protocol.decoder;
import java.util.Map;
public class MapScanResult<K, V> {
private final Long pos;
private final Map<K, V> values;
public MapScanResult(Long pos, Map<K, V> values) {
super();
this.pos = pos;
this.values = values;
}
public Long getPos() {
return pos;
}
public Map<K, V> getMap() {
return values;
}
}

@ -3,8 +3,6 @@ package org.redisson.client.protocol.decoder;
import java.util.List;
import java.util.Map;
import com.lambdaworks.redis.output.MapScanResult;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;

Loading…
Cancel
Save