@Override public Annotations asAnnotations() { if (_annotations.size() == 2) { Iterator<Map.Entry<Class<?>,Annotation>> it = _annotations.entrySet().iterator(); Map.Entry<Class<?>,Annotation> en1 = it.next(), en2 = it.next(); return new TwoAnnotations(en1.getKey(), en1.getValue(), en2.getKey(), en2.getValue()); } return new AnnotationMap(_annotations); }
private static List<List<Long>> changedExecutors(Map<List<Long>, NodeInfo> map, Map<List<Long>, List<Object>> newExecToNodePort) { HashMap<NodeInfo, List<List<Long>>> tmpSlotAssigned = map == null ? new HashMap<>() : Utils.reverseMap(map); HashMap<List<Object>, List<List<Long>>> slotAssigned = new HashMap<>(); for (Entry<NodeInfo, List<List<Long>>> entry : tmpSlotAssigned.entrySet()) { NodeInfo ni = entry.getKey(); List<Object> key = new ArrayList<>(2); key.add(ni.get_node()); key.add(ni.get_port_iterator().next()); List<List<Long>> value = new ArrayList<>(entry.getValue()); value.sort(Comparator.comparing(a -> a.get(0))); slotAssigned.put(key, value); } HashMap<List<Object>, List<List<Long>>> tmpNewSlotAssigned = newExecToNodePort == null ? new HashMap<>() : Utils.reverseMap(newExecToNodePort); HashMap<List<Object>, List<List<Long>>> newSlotAssigned = new HashMap<>(); for (Entry<List<Object>, List<List<Long>>> entry : tmpNewSlotAssigned.entrySet()) { List<List<Long>> value = new ArrayList<>(entry.getValue()); value.sort(Comparator.comparing(a -> a.get(0))); newSlotAssigned.put(entry.getKey(), value); } Map<List<Object>, List<List<Long>>> diff = mapDiff(slotAssigned, newSlotAssigned); List<List<Long>> ret = new ArrayList<>(); for (List<List<Long>> val : diff.values()) { ret.addAll(val); } return ret; }
public void send(Map<Integer, NodeInfo> taskToNode, Map<NodeInfo, IConnection> connections) { HashMap<NodeInfo, Stream<TaskMessage>> bundleMapByDestination = groupBundleByDestination(taskToNode); for (Map.Entry<NodeInfo, Stream<TaskMessage>> entry : bundleMapByDestination.entrySet()) { NodeInfo node = entry.getKey(); IConnection conn = connections.get(node); if (conn != null) { Iterator<TaskMessage> iter = entry.getValue().iterator(); if (iter.hasNext()) { conn.send(iter); } } else { LOG.warn("Connection not available for hostPort {}", node); } } }
@Override public Iterator<Entry<Long, ByteBuffer>> getFileMetadata(List<Long> fileIds) throws HiveException { getCount.incrementAndGet(); HashMap<Long, ByteBuffer> result = new HashMap<>(); for (Long id : fileIds) { MockItem mi = cache.get(id); if (mi == null) continue; getHitCount.incrementAndGet(); result.put(id, mi.data); } return result.entrySet().iterator(); }
/** * Build the environment used for all exec calls. * * @return The environment variables. */ public Map<String, String> execEnv(Map<String, String> env) { HashMap<String, String> res = new HashMap<String, String>(); for (String key : appConf.getStrings(AppConfig.EXEC_ENVS_NAME)) { String val = System.getenv(key); if (val != null) { res.put(key, val); } } if (env != null) res.putAll(env); for (Map.Entry<String, String> envs : res.entrySet()) { LOG.info("Env " + envs.getKey() + "=" + envs.getValue()); } return res; }
public String toString() { String out = "Portfolio [ID=" + ID + " status=" + status + " type=" + type + " pkid=" + pkid + "\n "; Iterator iter = positions.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); out += entry.getKey() + ":" + entry.getValue() + ", "; } out += "\n P1:" + position1 + ", P2:" + position2; return out + "\n]"; }
/** * Adds all entries from the given configuration into this configuration. The keys * are prepended with the given prefix. * * @param other * The configuration whose entries are added to this configuration. * @param prefix * The prefix to prepend. */ public void addAll(Configuration other, String prefix) { final StringBuilder bld = new StringBuilder(); bld.append(prefix); final int pl = bld.length(); synchronized (this.confData) { synchronized (other.confData) { for (Map.Entry<String, Object> entry : other.confData.entrySet()) { bld.setLength(pl); bld.append(entry.getKey()); this.confData.put(bld.toString(), entry.getValue()); } } } }
@Override public Annotations asAnnotations() { if (_annotations.size() == 2) { Iterator<Map.Entry<Class<?>,Annotation>> it = _annotations.entrySet().iterator(); Map.Entry<Class<?>,Annotation> en1 = it.next(), en2 = it.next(); return new TwoAnnotations(en1.getKey(), en1.getValue(), en2.getKey(), en2.getValue()); } return new AnnotationMap(_annotations); }
public String toString() { String out = "PortfolioPdx [ID=" + ID + " status=" + status + " type=" + type + " pkid=" + pkid + "\n "; Iterator iter = positions.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); out += entry.getKey() + ":" + entry.getValue() + ", "; } out += "\n P1:" + position1 + ", P2:" + position2; return out + "\n]"; }
/** * Merge the rhs tables from another join tree. * * @param src * the source join tree */ public void mergeRHSSemijoin(QBJoinTree src) { for (Entry<String, ArrayList<ASTNode>> e : src.rhsSemijoin.entrySet()) { String key = e.getKey(); ArrayList<ASTNode> value = rhsSemijoin.get(key); if (value == null) { rhsSemijoin.put(key, e.getValue()); } else { value.addAll(e.getValue()); } } }
public String toString() { String out = "Portfolio [ID=" + ID + " status=" + status + " type=" + type + " pkid=" + pkid + "\n "; Iterator iter = positions.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); out += entry.getKey() + ":" + entry.getValue() + ", "; } out += "\n P1:" + position1 + ", P2:" + position2; return out + "\n]"; }
@Override public PropsData clone() { final HashMap<String, Map<String, PropsEntry>> newProfiles = new HashMap<>(); final HashMap<String, PropsEntry> newBase = new HashMap<>(baseProperties); for (final Map.Entry<String, Map<String, PropsEntry>> entry : profileProperties.entrySet()) { final Map<String, PropsEntry> map = new HashMap<>(entry.getValue().size()); map.putAll(entry.getValue()); newProfiles.put(entry.getKey(), map); } final PropsData pd = new PropsData(newBase, newProfiles); pd.appendDuplicateProps = appendDuplicateProps; pd.ignoreMissingMacros = ignoreMissingMacros; pd.skipEmptyProps = skipEmptyProps; return pd; }
public String toString() { StringBuilder buf=new StringBuilder("Fragmentation list contains "); synchronized(frag_tables) { buf.append(frag_tables.size()).append(" tables\n"); for(Iterator<Entry<Address,FragmentationTable>> it=frag_tables.entrySet().iterator(); it.hasNext();) { Entry<Address,FragmentationTable> entry=it.next(); buf.append(entry.getKey()).append(": " ).append(entry.getValue()).append("\n"); } } return buf.toString(); }
/** * This method pre-computes the weights of groups to speed up processing * when validating a given set. We compute the weights of groups in * different places, so we have a separate method. */ private void computeGroupWeight(){ for (Entry<Long, Long> entry : serverGroup.entrySet()) { Long sid = entry.getKey(); Long gid = entry.getValue(); if(!groupWeight.containsKey(gid)) groupWeight.put(gid, serverWeight.get(sid)); else { long totalWeight = serverWeight.get(sid) + groupWeight.get(gid); groupWeight.put(gid, totalWeight); } } /* * Do not consider groups with weight zero */ for(long weight: groupWeight.values()){ LOG.debug("Group weight: " + weight); if(weight == ((long) 0)){ numGroups--; LOG.debug("One zero-weight group: " + 1 + ", " + numGroups); } } }