Example usage for com.google.common.collect ImmutableMap entrySet

List of usage examples for com.google.common.collect ImmutableMap entrySet

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap entrySet.

Prototype

public final ImmutableSet<Entry<K, V>> entrySet() 

Source Link

Usage

From source file:io.druid.indexing.overlord.TwoCloudWorkerSelectStrategy.java

private ImmutableMap<String, ImmutableWorkerInfo> filterWorkers(String ipFilter,
        ImmutableMap<String, ImmutableWorkerInfo> zkWorkers) {
    ImmutableMap.Builder<String, ImmutableWorkerInfo> filtered = ImmutableMap.builder();
    for (Map.Entry<String, ImmutableWorkerInfo> e : zkWorkers.entrySet()) {
        if (e.getValue().getWorker().getIp().startsWith(ipFilter)) {
            filtered.put(e);//from   w ww. j  a va2  s . c  om
        }
    }
    return filtered.build();
}

From source file:com.facebook.buck.versions.NaiveVersionSelector.java

@Override
public ImmutableMap<BuildTarget, Version> resolve(BuildTarget root,
        ImmutableMap<BuildTarget, ImmutableSet<Version>> domain) throws VersionException {
    ImmutableMap.Builder<BuildTarget, Version> selectedVersions = ImmutableMap.builder();
    for (Map.Entry<BuildTarget, ImmutableSet<Version>> ent : domain.entrySet()) {
        selectedVersions.put(ent.getKey(), Iterables.get(ent.getValue(), 0));
    }/* w ww  .  j  a va 2s . c om*/
    return selectedVersions.build();
}

From source file:com.facebook.buck.halide.HalideBuckConfig.java

private ImmutableMap<String, String> getHalideTargetMap() {
    ImmutableMap<String, String> allEntries = delegate.getEntriesForSection(HALIDE_SECTION_NAME);
    ImmutableMap.Builder<String, String> targets = ImmutableMap.builder();
    for (Map.Entry<String, String> entry : allEntries.entrySet()) {
        if (entry.getKey().startsWith(HALIDE_TARGET_KEY_PREFIX)) {
            targets.put(entry.getKey().substring(HALIDE_TARGET_KEY_PREFIX.length()), entry.getValue());
        }//  w  w w.  j a v a  2  s .  c om
    }
    return targets.build();
}

From source file:org.elasticsearch.rest.action.admin.indices.mapping.get.RestGetFieldMappingAction.java

/**
 * Helper method to find out if the only included fieldmapping metadata is typed NULL, which means
 * that type and index exist, but the field did not
 *///w  ww . j  a va 2  s  . c o  m
private boolean isFieldMappingMissingField(
        ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappingsByIndex)
        throws IOException {
    if (mappingsByIndex.size() != 1) {
        return false;
    }

    for (ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>> value : mappingsByIndex.values()) {
        for (ImmutableMap<String, FieldMappingMetaData> fieldValue : value.values()) {
            for (Map.Entry<String, FieldMappingMetaData> fieldMappingMetaDataEntry : fieldValue.entrySet()) {
                if (fieldMappingMetaDataEntry.getValue().isNull()) {
                    return true;
                }
            }
        }
    }
    return false;
}

From source file:com.afewmoreamps.util.COWMap.java

@Override
public V remove(Object key) {
    while (true) {
        ImmutableMap<K, V> original = m_map.get();
        Builder<K, V> builder = new Builder<K, V>();
        V oldValue = null;//from  www.ja v a  2  s. c  om
        for (Map.Entry<K, V> entry : original.entrySet()) {
            if (entry.getKey().equals(key)) {
                oldValue = entry.getValue();
            } else {
                builder.put(entry);
            }
        }
        ImmutableMap<K, V> copy = builder.build();
        if (m_map.compareAndSet(original, copy)) {
            return oldValue;
        }
    }
}

From source file:com.facebook.buck.rules.modern.impl.AbstractValueVisitor.java

@Override
public <K, V> void visitMap(ImmutableMap<K, V> value, ValueTypeInfo<K> keyType, ValueTypeInfo<V> valueType)
        throws E {
    for (Entry<K, V> entry : value.entrySet()) {
        keyType.visit(entry.getKey(), this);
        valueType.visit(entry.getValue(), this);
    }//from w  ww.j a  v a  2 s. c om
}

From source file:google.registry.monitoring.metrics.VirtualMetric.java

@VisibleForTesting
ImmutableList<MetricPoint<V>> getTimestampedValues(Instant timestamp) {
    ImmutableMap<ImmutableList<String>, V> values = valuesSupplier.get();

    ImmutableList.Builder<MetricPoint<V>> metricPoints = new ImmutableList.Builder<>();
    for (Entry<ImmutableList<String>, V> entry : values.entrySet()) {
        metricPoints.add(MetricPoint.create(this, entry.getKey(), timestamp, timestamp, entry.getValue()));
    }// w ww .j  a  va 2 s.c  om

    cardinality = values.size();
    return metricPoints.build();
}

From source file:io.fabric8.jube.local.ProcessMonitor.java

protected void processMonitor() {
    ImmutableMap<String, Installation> map = processManager.listInstallationMap();
    ImmutableSet<Map.Entry<String, Installation>> entries = map.entrySet();
    ImmutableMap<String, PodCurrentContainer> podRunningContainers = model.getPodRunningContainers(model);

    for (Map.Entry<String, Installation> entry : entries) {
        final String id = entry.getKey();
        if (excludedPodIds.contains(id)) {
            continue;
        }/*from   ww  w  .j a v a 2  s.  c o m*/
        Installation installation = entry.getValue();
        Long pid = null;
        try {
            pid = installation.getActivePid();
        } catch (IOException e) {
            LOG.warn("Failed to access pid for " + id + ". " + e, e);
        }
        final boolean alive = pid != null && pid.longValue() > 0;

        final PodCurrentContainer podCurrentContainer = podRunningContainers.get(id);
        if (podCurrentContainer == null) {
            File installDir = installation.getInstallDir();
            if (installDir.exists()) {
                LOG.debug("No pod container for id: " + id);
            } else {
                processManager.uninstall(installation);
            }
        } else {
            // lets mark the container as running or not...
            NodeHelper.podTransaction(model, podCurrentContainer.getPod(), new Runnable() {
                @Override
                public void run() {
                    podCurrentContainer.containerAlive(id, alive);
                }
            });
        }
    }
}

From source file:org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.TransactionPurchasesHiddenMarkovModel.java

protected String chooseCategory(double transactionTime, int numPurchases) throws Exception {
    ImmutableMap<String, Double> exhaustionTimes = this.inventory.getExhaustionTimes();
    Map<String, Double> weights = Maps.newHashMap();

    for (Map.Entry<String, Double> entry : exhaustionTimes.entrySet()) {
        String category = entry.getKey();
        double weight = this.categoryWF.weight(entry.getValue(), transactionTime);
        weights.put(category, weight);/* w ww.  j  a  va  2  s .c  o  m*/
    }

    if (numPurchases > 0) {
        weights.put(STOP_STATE, Constants.STOP_CATEGORY_WEIGHT);
    }

    Sampler<String> sampler = RouletteWheelSampler.create(weights, seedFactory);

    return sampler.sample();
}

From source file:com.google.javascript.jscomp.deps.BrowserWithTransformedPrefixesModuleResolver.java

public BrowserWithTransformedPrefixesModuleResolver(ImmutableSet<String> modulePaths,
        ImmutableList<String> moduleRootPaths, ErrorHandler errorHandler, PathEscaper pathEscaper,
        ImmutableMap<String, String> prefixReplacements) {
    super(modulePaths, moduleRootPaths, errorHandler, pathEscaper);
    Set<PrefixReplacement> p = prefixReplacements.entrySet().stream()
            .map(entry -> PrefixReplacement.of(entry.getKey(), entry.getValue())).collect(toImmutableSortedSet(
                    // Sort by length in descending order to prefixes are applied most specific to
                    // least specific.
                    Comparator.<PrefixReplacement>comparingInt(r -> r.prefix().length()).reversed()
                            .thenComparing(PrefixReplacement::prefix)));
    this.prefixReplacements = ImmutableSet.copyOf(p);
    this.expectedPrefixes = this.prefixReplacements.stream().map(PrefixReplacement::prefix).sorted()
            .collect(Collectors.joining(", "));
}