use of java.util.Map in project bazel by bazelbuild.
the class DigestUtils method fromMetadata.
/**
* @param mdMap A collection of (execPath, Metadata) pairs. Values may be null.
* @return an <b>order-independent</b> digest from the given "set" of (path, metadata) pairs.
*/
public static Md5Digest fromMetadata(Map<String, Metadata> mdMap) {
byte[] result = new byte[Md5Digest.MD5_SIZE];
// Profiling showed that MD5 engine instantiation was a hotspot, so create one instance for
// this computation to amortize its cost.
Fingerprint fp = new Fingerprint();
for (Map.Entry<String, Metadata> entry : mdMap.entrySet()) {
xorWith(result, getDigest(fp, entry.getKey(), entry.getValue()));
}
return new Md5Digest(result);
}
use of java.util.Map in project bazel by bazelbuild.
the class SkylarkDocumentationCollector method collectJavaObjects.
/**
* Collects and returns all the Java objects reachable in Skylark from (and including)
* firstClass with the corresponding SkylarkModule annotation.
*
* <p>Note that the {@link SkylarkModule} annotation for firstClass - firstModule -
* is also an input parameter, because some top level Skylark built-in objects and methods
* are not annotated on the class, but on a field referencing them.
*/
@VisibleForTesting
static void collectJavaObjects(SkylarkModule firstModule, Class<?> firstClass, Map<String, SkylarkModuleDoc> modules) {
Set<Class<?>> done = new HashSet<>();
Deque<Class<?>> toProcess = new LinkedList<>();
Map<Class<?>, SkylarkModule> annotations = new HashMap<>();
toProcess.addLast(firstClass);
annotations.put(firstClass, firstModule);
while (!toProcess.isEmpty()) {
Class<?> c = toProcess.removeFirst();
SkylarkModule annotation = annotations.get(c);
done.add(c);
if (!modules.containsKey(annotation.name())) {
modules.put(annotation.name(), new SkylarkModuleDoc(annotation, c));
}
SkylarkModuleDoc module = modules.get(annotation.name());
if (module.javaMethodsNotCollected()) {
ImmutableMap<Method, SkylarkCallable> methods = FuncallExpression.collectSkylarkMethodsWithAnnotation(c);
for (Map.Entry<Method, SkylarkCallable> entry : methods.entrySet()) {
module.addMethod(new SkylarkJavaMethodDoc(module, entry.getKey(), entry.getValue()));
}
for (Map.Entry<Method, SkylarkCallable> method : methods.entrySet()) {
Class<?> returnClass = method.getKey().getReturnType();
if (returnClass.isAnnotationPresent(SkylarkModule.class) && !done.contains(returnClass)) {
toProcess.addLast(returnClass);
annotations.put(returnClass, returnClass.getAnnotation(SkylarkModule.class));
}
}
}
}
}
use of java.util.Map in project jadx by skylot.
the class TernaryMod method checkLineStats.
/**
* Return 'true' if there are several args with same source lines
*/
private static boolean checkLineStats(InsnNode t, InsnNode e) {
if (t.getResult() == null || e.getResult() == null) {
return false;
}
PhiInsn tPhi = t.getResult().getSVar().getUsedInPhi();
PhiInsn ePhi = e.getResult().getSVar().getUsedInPhi();
if (tPhi == null || ePhi == null || tPhi != ePhi) {
return false;
}
Map<Integer, Integer> map = new HashMap<Integer, Integer>(tPhi.getArgsCount());
for (InsnArg arg : tPhi.getArguments()) {
if (!arg.isRegister()) {
continue;
}
InsnNode assignInsn = ((RegisterArg) arg).getAssignInsn();
if (assignInsn == null) {
continue;
}
int sourceLine = assignInsn.getSourceLine();
if (sourceLine != 0) {
Integer count = map.get(sourceLine);
if (count != null) {
map.put(sourceLine, count + 1);
} else {
map.put(sourceLine, 1);
}
}
}
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
if (entry.getValue() >= 2) {
return true;
}
}
return false;
}
use of java.util.Map in project jadx by skylot.
the class ResXmlGen method makeResourcesXml.
public List<ResContainer> makeResourcesXml() {
Map<String, CodeWriter> contMap = new HashMap<String, CodeWriter>();
for (ResourceEntry ri : resStorage.getResources()) {
if (SKIP_RES_TYPES.contains(ri.getTypeName())) {
continue;
}
String fn = getFileName(ri);
CodeWriter cw = contMap.get(fn);
if (cw == null) {
cw = new CodeWriter();
cw.add("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
cw.startLine("<resources>");
cw.incIndent();
contMap.put(fn, cw);
}
addValue(cw, ri);
}
List<ResContainer> files = new ArrayList<ResContainer>(contMap.size());
for (Map.Entry<String, CodeWriter> entry : contMap.entrySet()) {
String fileName = entry.getKey();
CodeWriter content = entry.getValue();
content.decIndent();
content.startLine("</resources>");
content.finish();
files.add(ResContainer.singleFile(fileName, content));
}
Collections.sort(files);
return files;
}
use of java.util.Map in project cachecloud by sohutv.
the class ClientDataCollectReportExecutor method collectReportCostTimeData.
/**
* 收集耗时
*
* @param lastMinute
*/
private List<Map<String, Object>> collectReportCostTimeData(String lastMinute) {
try {
//1. 收集数据
Map<CostTimeDetailStatKey, AtomicLongMap<Integer>> map = UsefulDataCollector.getCostTimeLastMinute(lastMinute);
if (map == null || map.isEmpty()) {
return Collections.emptyList();
}
// 2. 组装数据
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
for (Entry<CostTimeDetailStatKey, AtomicLongMap<Integer>> entry : map.entrySet()) {
CostTimeDetailStatKey costTimeDetailStatKey = entry.getKey();
AtomicLongMap<Integer> statMap = entry.getValue();
CostTimeDetailStatModel model = UsefulDataCollector.generateCostTimeDetailStatKey(statMap);
Map<String, Object> tempMap = new HashMap<String, Object>();
tempMap.put(ClientReportConstant.COST_COUNT, model.getTotalCount());
tempMap.put(ClientReportConstant.COST_COMMAND, costTimeDetailStatKey.getCommand());
tempMap.put(ClientReportConstant.COST_HOST_PORT, costTimeDetailStatKey.getHostPort());
tempMap.put(ClientReportConstant.COST_TIME_90_MAX, model.getNinetyPercentMax());
tempMap.put(ClientReportConstant.COST_TIME_99_MAX, model.getNinetyNinePercentMax());
tempMap.put(ClientReportConstant.COST_TIME_100_MAX, model.getHundredMax());
tempMap.put(ClientReportConstant.COST_TIME_MEAN, model.getMean());
tempMap.put(ClientReportConstant.COST_TIME_MEDIAN, model.getMedian());
tempMap.put(ClientReportConstant.CLIENT_DATA_TYPE, ClientCollectDataTypeEnum.COST_TIME_DISTRI_TYPE.getValue());
list.add(tempMap);
}
return list;
} catch (Exception e) {
UsefulDataCollector.collectException(e, "", System.currentTimeMillis(), ClientExceptionType.CLIENT_EXCEPTION_TYPE);
logger.error("collectReportCostTimeData:" + e.getMessage(), e);
return Collections.emptyList();
}
}
Aggregations