/** * @param stats {@link CoordinatorStats} to accumulate assignment statistics. * @param tierToSkip if not null, this tier will be skipped from doing assignment, use when primary replica was * assigned. */ private void assignReplicas( final DruidCoordinatorRuntimeParams params, final DataSegment segment, final CoordinatorStats stats, @Nullable final String tierToSkip ) { for (final Object2IntMap.Entry<String> entry : targetReplicants.object2IntEntrySet()) { final String tier = entry.getKey(); if (tier.equals(tierToSkip)) { log.info("Skipping replica assignment for tier [%s]", tier); continue; } final int numAssigned = assignReplicasForTier( tier, entry.getIntValue(), params.getSegmentReplicantLookup().getTotalReplicants(segment.getId(), tier), params, createLoadQueueSizeLimitingPredicate(params), segment ); stats.addToTieredStat(ASSIGNED_COUNT, tier, numAssigned); } }
continue; final String tier = entry.getKey();
protected Map<String, Type<?>> buildTypes() { final Map<String, Type<?>> types = Maps.newHashMap(); final List<TypeTemplate> templates = Lists.newArrayList(); for (final Object2IntMap.Entry<String> entry : RECURSIVE_TYPES.object2IntEntrySet()) { templates.add(DSL.check(entry.getKey(), entry.getIntValue(), getTemplate(entry.getKey()))); } final TypeTemplate choice = templates.stream().reduce(DSL::or).get(); final TypeFamily family = new RecursiveTypeFamily(name, choice); for (final String name : TYPE_TEMPLATES.keySet()) { final Type<?> type; final int recurseId = RECURSIVE_TYPES.getOrDefault(name, -1); if (recurseId != -1) { type = family.apply(recurseId); } else { type = getTemplate(name).apply(family).apply(-1); } types.put(name, type); } return types; }
/** @return a set of keys whose values are greater than the specific cutoff. */ public Set<T> keySet(int cutoff) { Set<T> set = new HashSet<>(); for (Entry<T> p : count_map.object2IntEntrySet()) { if (p.getIntValue() > cutoff) set.add(p.getKey()); } return set; }
/** * Merge second counter set. * * @param other Other set of counters. */ public static <O> void update(Object2IntOpenHashMap<O> first, Object2IntOpenHashMap<O> second) { for(Iterator<Object2IntMap.Entry<O>> iter = second.object2IntEntrySet().fastIterator(); iter.hasNext();) { Object2IntMap.Entry<O> entry = iter.next(); second.addTo(entry.getKey(), entry.getIntValue()); } } }
protected Set<StringPrediction> toSet(Object2IntMap<String> map) { Set<StringPrediction> set = new HashSet<>(); for (Entry<String> e : map.object2IntEntrySet()) set.add(new StringPrediction(e.getKey(), e.getIntValue())); return set; }
private String[] compileTagset(Object2IntMap<String> aTagsetCollector) { String[] tagset = new String[aTagsetCollector.size()]; for (Entry<String> e : aTagsetCollector.object2IntEntrySet()) { tagset[e.getIntValue()] = e.getKey(); } return tagset; }
public Set<T> keySet(double threshold) { Set<T> set = new HashSet<>(); double d; for (Entry<T> p : count_map.object2IntEntrySet()) { d = MathUtils.divide(p.getIntValue(), total_count); if (d > threshold) set.add(p.getKey()); } return set; } }
@Override public boolean containsKey(final Object k) { final ObjectIterator<Object2IntMap.Entry<K>> i = object2IntEntrySet().iterator(); while (i.hasNext()) if (i.next().getKey() == k) return true; return false; } @Override
public List<ObjectDoublePair<T>> toList(double threshold) { List<ObjectDoublePair<T>> list = new ArrayList<>(); double d; for (Entry<T> p : count_map.object2IntEntrySet()) { d = MathUtils.divide(p.getIntValue(), total_count); if (d > threshold) list.add(new ObjectDoublePair<T>(p.getKey(), d)); } return list; }
@Override public PairOfObjectInt<K> next() { if (!hasNext()) { return null; } Object2IntMap.Entry<K> entry = iter.next(); pair.set(entry.getKey(), entry.getIntValue()); return pair; }
/** @return a set of keys whose values are greater than the specific cutoff. */ public Set<T> keySet(int cutoff) { Set<T> set = new HashSet<>(); for (Entry<T> p : count_map.object2IntEntrySet()) { if (p.getValue() > cutoff) set.add(p.getKey()); } return set; }
private List<PairOfObjectInt<K>> getEntriesSorted(Comparator<PairOfObjectInt<K>> comparator) { List<PairOfObjectInt<K>> list = Lists.newArrayList(); for (Object2IntMap.Entry<K> e : counts.object2IntEntrySet()) { list.add(new PairOfObjectInt<K>(e.getKey(), e.getIntValue())); } Collections.sort(list, comparator); return list; }
public Set<T> keySet(double threshold) { Set<T> set = new HashSet<>(); double d; for (Entry<T> p : count_map.object2IntEntrySet()) { d = MathUtils.divide(p.getValue(), total_count); if (d > threshold) set.add(p.getKey()); } return set; } }
public List<ObjectIntPair<T>> toList(int cutoff) { List<ObjectIntPair<T>> list = new ArrayList<>(); for (Entry<T> p : count_map.object2IntEntrySet()) { if (p.getValue() > cutoff) list.add(new ObjectIntPair<>(p.getKey(), p.getValue())); } return list; }
@Override public K previous() { return i.previous().getKey(); }; @Override
@Override public K next() { return i.next().getKey(); }; @Override
final String tier = entry.getKey();
@Override public GroupKey next() { Object2IntMap.Entry<IntArray> entry = _iterator.next(); _groupKey._groupId = entry.getIntValue(); _groupKey._stringKey = getGroupKey(entry.getKey()); return _groupKey; }
/** * Returns true if at least one tier in target replica assignment exists in cluster but does not have enough replicas. */ private boolean loadingInProgress(final DruidCluster druidCluster) { for (final Object2IntMap.Entry<String> entry : targetReplicants.object2IntEntrySet()) { final String tier = entry.getKey(); // if there are replicants loading in cluster if (druidCluster.hasTier(tier) && entry.getIntValue() > currentReplicants.getOrDefault(tier, 0)) { return true; } } return false; }