Fixed binary safe pipeline commands and added tests for pipelined hash functions

This commit is contained in:
shendley
2012-12-18 10:26:56 -05:00
parent 2058231a61
commit 45be143e23
3 changed files with 112 additions and 39 deletions

25
src/main/java/redis/clients/jedis/BuilderFactory.java Normal file → Executable file
View File

@@ -144,6 +144,13 @@ public class BuilderFactory {
}
List<byte[]> l = (List<byte[]>) data;
final Set<byte[]> result = new LinkedHashSet<byte[]>(l);
for (final byte[] barray : l) {
if (barray == null) {
result.add(null);
} else {
result.add(barray);
}
}
return result;
}
@@ -151,6 +158,24 @@ public class BuilderFactory {
return "ZSet<byte[]>";
}
};
public static final Builder<Map<byte[], byte[]>> BYTE_ARRAY_MAP = new Builder<Map<byte[], byte[]>>() {
@SuppressWarnings("unchecked")
public Map<byte[], byte[]> build(Object data) {
final List<byte[]> flatHash = (List<byte[]>) data;
final Map<byte[], byte[]> hash = new HashMap<byte[], byte[]>();
final Iterator<byte[]> iterator = flatHash.iterator();
while (iterator.hasNext()) {
hash.put(iterator.next(), iterator.next());
}
return hash;
}
public String toString() {
return "Map<byte[], byte[]>";
}
};
public static final Builder<Set<String>> STRING_ZSET = new Builder<Set<String>>() {
@SuppressWarnings("unchecked")