Search in sources :

Example 56 with Map

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);
}
Also used : Fingerprint(com.google.devtools.build.lib.util.Fingerprint) Map(java.util.Map)

Example 57 with Map

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));
                }
            }
        }
    }
}
Also used : SkylarkCallable(com.google.devtools.build.lib.skylarkinterface.SkylarkCallable) HashMap(java.util.HashMap) Method(java.lang.reflect.Method) LinkedList(java.util.LinkedList) SkylarkJavaMethodDoc(com.google.devtools.build.docgen.skylark.SkylarkJavaMethodDoc) SkylarkModule(com.google.devtools.build.lib.skylarkinterface.SkylarkModule) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SkylarkModuleDoc(com.google.devtools.build.docgen.skylark.SkylarkModuleDoc) HashSet(java.util.HashSet) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 58 with Map

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;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) PhiInsn(jadx.core.dex.instructions.PhiInsn) HashMap(java.util.HashMap) InsnArg(jadx.core.dex.instructions.args.InsnArg) HashMap(java.util.HashMap) Map(java.util.Map)

Example 59 with Map

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;
}
Also used : HashMap(java.util.HashMap) ResourceEntry(jadx.core.xmlgen.entry.ResourceEntry) ArrayList(java.util.ArrayList) CodeWriter(jadx.core.codegen.CodeWriter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 60 with Map

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();
    }
}
Also used : CostTimeDetailStatKey(com.sohu.tv.jedis.stat.model.CostTimeDetailStatKey) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AtomicLongMap(com.sohu.tv.jedis.stat.utils.AtomicLongMap) ParseException(java.text.ParseException) CostTimeDetailStatModel(com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel) HashMap(java.util.HashMap) Map(java.util.Map) AtomicLongMap(com.sohu.tv.jedis.stat.utils.AtomicLongMap)

Aggregations

Map (java.util.Map)18519 HashMap (java.util.HashMap)11152 ArrayList (java.util.ArrayList)4318 List (java.util.List)3718 Test (org.junit.Test)3076 Set (java.util.Set)2132 HashSet (java.util.HashSet)1884 IOException (java.io.IOException)1729 LinkedHashMap (java.util.LinkedHashMap)1605 Iterator (java.util.Iterator)1517 TreeMap (java.util.TreeMap)1160 ImmutableMap (com.google.common.collect.ImmutableMap)1043 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)869 File (java.io.File)788 Collection (java.util.Collection)765 Collectors (java.util.stream.Collectors)652 ConcurrentMap (java.util.concurrent.ConcurrentMap)412 LinkedList (java.util.LinkedList)409 Collections (java.util.Collections)388 InputStream (java.io.InputStream)362