redis.clients.jedis.resps.FunctionStats Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jedis_preview Show documentation
Show all versions of jedis_preview Show documentation
Jedis is a blazingly small and sane Redis java client.
The newest version!
package redis.clients.jedis.resps;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import redis.clients.jedis.Builder;
import redis.clients.jedis.BuilderFactory;
import redis.clients.jedis.util.KeyValue;
public class FunctionStats {
private final Map runningScript;
private final Map> engines;
public FunctionStats(Map script, Map> engines) {
this.runningScript = script;
this.engines = engines;
}
public Map getRunningScript() {
return runningScript;
}
public Map> getEngines() {
return engines;
}
public static final Builder FUNCTION_STATS_BUILDER = new Builder() {
@Override
public FunctionStats build(Object data) {
if (data == null) return null;
List list = (List) data;
if (list.isEmpty()) return null;
if (list.get(0) instanceof KeyValue) {
Map runningScriptMap = null;
Map> enginesMap = null;
for (KeyValue kv : (List) list) {
switch (BuilderFactory.STRING.build(kv.getKey())) {
case "running_script":
runningScriptMap = BuilderFactory.ENCODED_OBJECT_MAP.build(kv.getValue());
break;
case "engines":
List ilist = (List) kv.getValue();
enginesMap = new LinkedHashMap<>(ilist.size());
for (KeyValue ikv : (List) kv.getValue()) {
enginesMap.put(BuilderFactory.STRING.build(ikv.getKey()),
BuilderFactory.ENCODED_OBJECT_MAP.build(ikv.getValue()));
}
break;
}
}
return new FunctionStats(runningScriptMap, enginesMap);
}
Map runningScriptMap = list.get(1) == null ? null
: BuilderFactory.ENCODED_OBJECT_MAP.build(list.get(1));
List