Example usage for com.google.common.collect Multimap get

List of usage examples for com.google.common.collect Multimap get

Introduction

In this page you can find the example usage for com.google.common.collect Multimap get.

Prototype

Collection<V> get(@Nullable K key);

Source Link

Document

Returns a view collection of the values associated with key in this multimap, if any.

Usage

From source file:org.apache.tez.analyzer.plugins.ContainerReuseAnalyzer.java

@Override
public void analyze(DagInfo dagInfo) throws TezException {
    for (VertexInfo vertexInfo : dagInfo.getVertices()) {
        Multimap<Container, TaskAttemptInfo> containers = vertexInfo.getContainersMapping();
        for (Container container : containers.keySet()) {
            List<String> record = Lists.newLinkedList();
            record.add(vertexInfo.getVertexName());
            record.add(vertexInfo.getTaskAttempts().size() + "");
            record.add(container.getHost());
            record.add(container.getId());
            record.add(Integer.toString(containers.get(container).size()));
            csvResult.addRecord(record.toArray(new String[record.size()]));
        }/*ww w .j ava  2  s.co  m*/
    }
}

From source file:org.springframework.ide.eclipse.boot.dash.lattice.LatticeBootDashModel.java

private void refreshActualLRPs(List<DesiredLRPResponse> dlrps) {
    List<ActualLRPResponse> lrps = getReceptor().getActualLRPs();
    Multimap<String, ActualLRPResponse> byProcessGuid = ArrayListMultimap.create();
    for (ActualLRPResponse lrp : lrps) {
        byProcessGuid.put(lrp.getProcessGuid(), lrp);
    }//from  w w w.  ja v a 2  s .co  m
    for (DesiredLRPResponse dlrp : dlrps) {
        String processGuid = dlrp.getProcessGuid();
        Collection<ActualLRPResponse> alrps = byProcessGuid.get(processGuid);
        LatticeBootDashElement el = getElementFor(processGuid);
        if (el != null) {
            el.setActualLrps(alrps);
        }
    }
}

From source file:com.streamsets.pipeline.stage.destination.salesforce.ForceTarget.java

/**
 * {@inheritDoc}//  ww w .  j a  v a  2  s  . co m
 */
@Override
public void write(Batch batch) throws StageException {
    Multimap<String, Record> partitions = ELUtils.partitionBatchByExpression(sObjectNameEval, sObjectNameVars,
            conf.sObjectNameTemplate, batch);
    Set<String> sObjectNames = partitions.keySet();
    for (String sObjectName : sObjectNames) {
        List<OnRecordErrorException> errors = writer.writeBatch(sObjectName, partitions.get(sObjectName), this);
        for (OnRecordErrorException error : errors) {
            errorRecordHandler.onError(error);
        }
    }
}

From source file:fr.irit.smac.may.speadl.ui.builder.SourceRelativeFileSystemAccess.java

/**
 * Since sourceTraces are relative the URI has to be computed with the currentSource as context
 *//*from w w  w  . j  a  v a  2  s  .com*/
//TODO this fixes relative URIs for Xtend only, but what about all other languages?
@Override
public void flushSourceTraces(String generatorName) throws CoreException {
    Multimap<URI, IPath> sourceTraces = getSourceTraces();
    if (sourceTraces != null) {
        Set<URI> keys = sourceTraces.keySet();
        String source = getCurrentSource();
        IContainer container = Strings.isEmpty(source) ? getProject() : getProject().getFolder(source);
        for (URI uri : keys) {
            if (uri != null && source != null) {
                Collection<IPath> paths = sourceTraces.get(uri);
                IFile sourceFile = container.getFile(new Path(uri.toFileString()));
                if (sourceFile.exists()) {
                    IPath[] tracePathArray = paths.toArray(new IPath[paths.size()]);
                    getTraceMarkers().installMarker(sourceFile, generatorName, tracePathArray);
                }
            }
        }
    }
    resetSourceTraces();
}

From source file:org.fabrician.enabler.DockerClient.java

private Optional<String> getFirstValue(Multimap<String, String> map, String key) {
    Collection<String> values = map.get(key);
    return Optional.fromNullable((values != null && values.size() >= 1) ? values.iterator().next() : null);
}

From source file:com.squareup.wire.schema.Linker.java

/** Add all paths in {@code paths} to {@code sink}, plus their public imports, recursively. */
private void addImports(Collection<String> sink, Collection<String> paths,
        Multimap<String, String> publicImports) {
    for (String path : paths) {
        if (sink.add(path)) {
            addImports(sink, publicImports.get(path), publicImports);
        }/*w w w .j  a v  a2s  .c  o  m*/
    }
}

From source file:org.sosy_lab.cpachecker.util.precondition.segkro.rules.PatternBasedRule.java

private Collection<Map<String, Formula>> getAllAssignments(Multimap<String, Formula> pFromBindings) {
    final Set<String> boundVariables = pFromBindings.keySet();
    final List<Collection<Formula>> dimensions = new ArrayList<>(boundVariables.size());
    for (String var : boundVariables) {
        dimensions.add(pFromBindings.get(var));
    }//from ww w .  ja  v a  2s .com

    Collection<Map<String, Formula>> result = Lists.newArrayList();
    for (List<Formula> x : Cartesian.product(dimensions)) {
        final Map<String, Formula> tuple = Maps.newHashMap();
        final Iterator<Formula> xIt = x.iterator();
        for (String var : boundVariables) {
            Formula f = xIt.next();
            tuple.put(var, f);
        }
        result.add(tuple);
    }

    return result;
}

From source file:org.xacml4j.v30.pdp.PolicySet.java

/**
 * Gets policy combiner parameter with a given name
 *
 * @param policyId a policy identifier/*w  w  w .  j a v  a2s  .com*/
 * @param name a parameter name
 * @return a collection of combiner parameters
 */
public Collection<CombinerParameter> getPolicyCombinerParam(String policyId, String name) {
    Multimap<String, CombinerParameter> p = policyCombinerParameters.get(policyId);
    return (p == null) ? ImmutableList.<CombinerParameter>of() : p.get(name);
}

From source file:com.b2international.snowowl.datastore.server.importer.AbstractTerminologyImportValidator.java

private void checkDuplication() {

    for (final String attributeName : uniqueAttributes.keySet()) {
        final Multimap<String, String> attributeValueSheetNamesMap = uniqueAttributes.get(attributeName);
        for (final String attributeValue : attributeValueSheetNamesMap.keySet()) {
            final Collection<String> sheetNames = attributeValueSheetNamesMap.get(attributeValue);

            if (sheetNames.size() > 1) {
                for (final String sheetName : sheetNames) {
                    addDefect(sheetName, DefectType.DIFFERENCES,
                            "'" + attributeName + "' attribute must be unique.");
                }//w  ww  .j a v a  2  s  . co  m
            }

        }
    }

}

From source file:org.xacml4j.v30.pdp.PolicySet.java

/**
 * Gets policy set combiner parameter with a given name
 *
 * @param policySetId a policy set identifier
 * @param name a parameter name//from  w ww  .  java 2  s . c  o  m
 * @return a collection of combiner parameters
 */
public Collection<CombinerParameter> getPolicySetCombinerParam(String policySetId, String name) {
    Multimap<String, CombinerParameter> p = policySetCombinerParameters.get(policySetId);
    return (p == null) ? ImmutableList.<CombinerParameter>of() : p.get(name);
}