Example usage for com.google.common.collect ArrayListMultimap create

List of usage examples for com.google.common.collect ArrayListMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect ArrayListMultimap create.

Prototype

public static <K, V> ArrayListMultimap<K, V> create() 

Source Link

Document

Creates a new, empty ArrayListMultimap with the default initial capacities.

Usage

From source file:org.jpmml.evaluator.EvaluatorUtil.java

static public <K> List<Map<K, Object>> groupRows(K groupKey, List<? extends Map<K, ?>> table) {
    Map<Object, ListMultimap<K, Object>> groupedRows = Maps.newLinkedHashMap();

    for (int i = 0; i < table.size(); i++) {
        Map<K, ?> row = table.get(i);

        Object groupValue = row.get(groupKey);

        ListMultimap<K, Object> groupedRow = groupedRows.get(groupValue);
        if (groupedRow == null) {
            groupedRow = ArrayListMultimap.create();

            groupedRows.put(groupValue, groupedRow);
        }/*w w w .  j  av  a  2  s . c o  m*/

        Collection<? extends Map.Entry<K, ?>> entries = row.entrySet();
        for (Map.Entry<K, ?> entry : entries) {
            K key = entry.getKey();
            Object value = entry.getValue();

            groupedRow.put(key, value);
        }
    }

    List<Map<K, Object>> resultTable = Lists.newArrayList();

    Collection<Map.Entry<Object, ListMultimap<K, Object>>> entries = groupedRows.entrySet();
    for (Map.Entry<Object, ListMultimap<K, Object>> entry : entries) {
        Map<K, Object> resultRow = Maps.newLinkedHashMap();
        resultRow.putAll((entry.getValue()).asMap());

        // The value of the "group by" column is a single Object, not a Collection (ie. java.util.List) of Objects
        resultRow.put(groupKey, entry.getKey());

        resultTable.add(resultRow);
    }

    return resultTable;
}

From source file:exm.stc.tclbackend.TclTemplateProcessor.java

private static ListMultimap<String, TemplateArg> buildArgMap(TclOpTemplate template, List<TemplateArg> inputs,
        List<TemplateArg> outputs) {
    // May be multiple tokens per output
    ListMultimap<String, TemplateArg> toks = ArrayListMultimap.create();

    List<String> outNames = template.getOutNames();
    for (int i = 0; i < outputs.size(); i++) {
        TemplateArg out = outputs.get(i);
        assert (out.isOutput);

        String argName = outNames.get(i);
        toks.put(argName, out);//from  w ww  . j  a va 2  s . c  o  m
    }

    List<String> inNames = template.getInNames();
    if (template.hasVarArgs()) {
        assert (inputs.size() >= inNames.size() - 1) : inputs + " " + inNames;
    } else {
        assert (inNames.size() == inputs.size()) : inputs + " " + inNames;
    }
    for (int i = 0; i < inNames.size(); i++) {
        String argName = inNames.get(i);
        if (template.hasVarArgs() && i == inNames.size() - 1) {
            // Last argument: varargs
            for (int j = i; j < inputs.size(); j++) {
                TemplateArg input = inputs.get(j);
                assert (!input.isOutput);
                toks.put(argName, input);
            }
        } else {
            TemplateArg input = inputs.get(i);
            assert (!input.isOutput);
            toks.put(argName, input);
        }
    }
    return toks;
}

From source file:org.sonatype.nexus.proxy.registry.DefaultRepositoryTypeRegistry.java

protected Multimap<Class<? extends Repository>, RepositoryTypeDescriptor> getRepositoryTypeDescriptors() {
    synchronized (this) {
        // maybe the previous who was blocking us already did the job
        if (repositoryTypeDescriptorsMap == null) {
            Multimap<Class<? extends Repository>, RepositoryTypeDescriptor> result = ArrayListMultimap.create();

            // fill in the defaults
            Class<? extends Repository> role = null;

            role = Repository.class;

            result.put(role, new RepositoryTypeDescriptor(role, M1Repository.ID, "repositories",
                    RepositoryType.UNLIMITED_INSTANCES));
            result.put(role, new RepositoryTypeDescriptor(role, M2Repository.ID, "repositories",
                    RepositoryType.UNLIMITED_INSTANCES));

            role = ShadowRepository.class;

            result.put(role, new RepositoryTypeDescriptor(role, M1LayoutedM2ShadowRepository.ID, "shadows",
                    RepositoryType.UNLIMITED_INSTANCES));
            result.put(role, new RepositoryTypeDescriptor(role, M2LayoutedM1ShadowRepository.ID, "shadows",
                    RepositoryType.UNLIMITED_INSTANCES));

            role = GroupRepository.class;

            result.put(role, new RepositoryTypeDescriptor(role, M1GroupRepository.ID, "groups",
                    RepositoryType.UNLIMITED_INSTANCES));
            result.put(role, new RepositoryTypeDescriptor(role, M2GroupRepository.ID, "groups",
                    RepositoryType.UNLIMITED_INSTANCES));

            // No implementation exists in core!
            // role = WebSiteRepository.class.getName();

            // result.put( role, new RepositoryTypeDescriptor( role, XXX, "sites" ) );

            logger.info("Registered default repository types.");

            this.repositoryTypeDescriptorsMap = result;
        }/*from  ww  w.  j a  v a  2 s.c om*/

        return repositoryTypeDescriptorsMap;
    }
}

From source file:com.streamsets.pipeline.lib.jdbc.SchemaTableClassifier.java

/**
 * Split records according to tuples (schemaName, tableName)
 *
 * @param batch batch of SDC records/*from w w  w.ja v  a  2 s .  co  m*/
 * @return batch partitions grouped by the tuples (schemaName, tableName)
 * @throws OnRecordErrorException
 */
public Multimap<SchemaAndTable, Record> classify(Batch batch) throws OnRecordErrorException {
    Multimap<SchemaAndTable, Record> partitions = ArrayListMultimap.create();
    Iterator<Record> batchIterator = batch.getRecords();

    while (batchIterator.hasNext()) {
        Record record = batchIterator.next();
        String schemaName = schemaNameExpr;
        String tableName = tableNameExpr;

        if (dynamicSchemaName) {
            try {
                RecordEL.setRecordInContext(schemaNameVars, record);
                schemaName = schemaNameEval.eval(schemaNameVars, schemaNameExpr, String.class);
                LOG.debug("Expression '{}' is evaluated to '{}' : ", schemaNameExpr, schemaName);
            } catch (ELEvalException e) {
                LOG.error("Failed to evaluate expression '{}' : ", schemaNameExpr, e.toString(), e);
                throw new OnRecordErrorException(record, e.getErrorCode(), e.getParams());
            }
        }

        if (dynamicTableName) {
            try {
                RecordEL.setRecordInContext(tableNameVars, record);
                tableName = tableNameEval.eval(tableNameVars, tableNameExpr, String.class);
                LOG.debug("Expression '{}' is evaluated to '{}' : ", tableNameExpr, tableName);
            } catch (ELEvalException e) {
                LOG.error("Failed to evaluate expression '{}' : ", tableNameExpr, e.toString(), e);
                throw new OnRecordErrorException(record, e.getErrorCode(), e.getParams());
            }
        }

        SchemaAndTable partitionKey = new SchemaAndTable(schemaName, tableName);
        partitions.put(partitionKey, record);
    }

    return partitions;
}

From source file:eu.esdihumboldt.hale.common.align.model.transformation.tree.visitor.CellNodeValidator.java

/**
 * @see AbstractTargetToSourceVisitor#visit(CellNode)
 *///from  w w w.  j a v a2s. co  m
@Override
public boolean visit(CellNode node) {
    // evaluate if for the cell all needed inputs are set
    Cell cell = node.getCell();

    // collect source and target nodes per entity name

    ListMultimap<String, Pair<SourceNode, Entity>> sources = ArrayListMultimap.create();
    if (cell.getSource() != null) {
        for (Entry<String, ? extends Entity> sourceEntry : cell.getSource().entries()) {
            String name = sourceEntry.getKey();
            Entity entity = sourceEntry.getValue();
            SourceNode sourceNode = findSourceNode(node, entity);
            if (sourceNode != null) {
                if (sourceNode.isDefined()) {
                    sources.put(name, new Pair<SourceNode, Entity>(sourceNode, entity));
                }
            } else {
                log.error("Source node for entity not found.");
            }
        }
    }

    ListMultimap<String, Pair<TargetNode, Entity>> targets = ArrayListMultimap.create();
    for (Entry<String, ? extends Entity> targetEntry : cell.getTarget().entries()) {
        String name = targetEntry.getKey();
        Entity entity = targetEntry.getValue();
        TargetNode targetNode = findTargetNode(node, entity);
        if (targetNode != null) {
            targets.put(name, new Pair<TargetNode, Entity>(targetNode, entity));
        } else {
            log.error("Target node for entity not found.");
        }
    }

    boolean valid = validate(node, sources, targets);

    if (valid) {
        processValid(cell, sources, targets);
    }

    node.setValid(valid);

    // don't visit source nodes
    return false;
}

From source file:tterrag.potionapi.common.util.ReplaceUtil.java

public static void overwriteEntry(RegistryNamespaced registry, String name, Object object) {
    Object oldThing = registry.getObject(name);
    Repl.overwrite_do(registry, name, object, oldThing);
    Multimap<String, Object> reg = Repl.replacements.get(registry);
    if (reg == null) {
        Repl.replacements.put(registry, reg = ArrayListMultimap.create());
    }//from  w w  w .ja  va 2s.c o m
    if (!reg.containsKey(name)) {
        reg.put(name, oldThing);
    }
    reg.put(name, object);
    Repl.alterDelegateChain(registry, name, object);
}

From source file:org.apache.cassandra.tools.nodetool.TableStats.java

@Override
public void execute(NodeProbe probe) {
    if (!outputFormat.isEmpty() && !"json".equals(outputFormat) && !"yaml".equals(outputFormat)) {
        throw new IllegalArgumentException("arguments for -F are json,yaml only.");
    }/*from www .jav  a 2  s .co  m*/

    TableStats.OptionFilter filter = new OptionFilter(ignore, tableNames);
    ArrayListMultimap<String, ColumnFamilyStoreMBean> selectedTableMbeans = ArrayListMultimap.create();
    Map<String, StatsKeyspace> keyspaceStats = new HashMap<>();

    // get a list of table stores
    Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> tableMBeans = probe.getColumnFamilyStoreMBeanProxies();

    while (tableMBeans.hasNext()) {
        Map.Entry<String, ColumnFamilyStoreMBean> entry = tableMBeans.next();
        String keyspaceName = entry.getKey();
        ColumnFamilyStoreMBean tableProxy = entry.getValue();

        if (filter.isKeyspaceIncluded(keyspaceName)) {
            StatsKeyspace stats = keyspaceStats.get(keyspaceName);
            if (stats == null) {
                stats = new StatsKeyspace(probe, keyspaceName);
                keyspaceStats.put(keyspaceName, stats);
            }
            stats.add(tableProxy);

            if (filter.isTableIncluded(keyspaceName, tableProxy.getTableName()))
                selectedTableMbeans.put(keyspaceName, tableProxy);
        }
    }

    // make sure all specified keyspace and tables exist
    filter.verifyKeyspaces(probe.getKeyspaces());
    filter.verifyTables();

    // get metrics of keyspace
    StatsHolder holder = new StatsHolder();
    for (Map.Entry<String, Collection<ColumnFamilyStoreMBean>> entry : selectedTableMbeans.asMap().entrySet()) {
        String keyspaceName = entry.getKey();
        Collection<ColumnFamilyStoreMBean> tables = entry.getValue();
        StatsKeyspace statsKeyspace = keyspaceStats.get(keyspaceName);

        // get metrics of table statistics for this keyspace
        for (ColumnFamilyStoreMBean table : tables) {
            String tableName = table.getTableName();
            StatsTable statsTable = new StatsTable();
            statsTable.name = tableName;
            statsTable.isIndex = tableName.contains(".");
            statsTable.sstableCount = probe.getColumnFamilyMetric(keyspaceName, tableName, "LiveSSTableCount");
            int[] leveledSStables = table.getSSTableCountPerLevel();
            if (leveledSStables != null) {
                statsTable.isLeveledSstable = true;

                for (int level = 0; level < leveledSStables.length; level++) {
                    int count = leveledSStables[level];
                    long maxCount = 4L; // for L0
                    if (level > 0)
                        maxCount = (long) Math.pow(10, level);
                    // show max threshold for level when exceeded
                    statsTable.sstablesInEachLevel.add(count + ((count > maxCount) ? "/" + maxCount : ""));
                }
            }

            Long memtableOffHeapSize = null;
            Long bloomFilterOffHeapSize = null;
            Long indexSummaryOffHeapSize = null;
            Long compressionMetadataOffHeapSize = null;
            Long offHeapSize = null;
            Double percentRepaired = null;

            try {
                memtableOffHeapSize = (Long) probe.getColumnFamilyMetric(keyspaceName, tableName,
                        "MemtableOffHeapSize");
                bloomFilterOffHeapSize = (Long) probe.getColumnFamilyMetric(keyspaceName, tableName,
                        "BloomFilterOffHeapMemoryUsed");
                indexSummaryOffHeapSize = (Long) probe.getColumnFamilyMetric(keyspaceName, tableName,
                        "IndexSummaryOffHeapMemoryUsed");
                compressionMetadataOffHeapSize = (Long) probe.getColumnFamilyMetric(keyspaceName, tableName,
                        "CompressionMetadataOffHeapMemoryUsed");
                offHeapSize = memtableOffHeapSize + bloomFilterOffHeapSize + indexSummaryOffHeapSize
                        + compressionMetadataOffHeapSize;
                percentRepaired = (Double) probe.getColumnFamilyMetric(keyspaceName, tableName,
                        "PercentRepaired");
            } catch (RuntimeException e) {
                // offheap-metrics introduced in 2.1.3 - older versions do not have the appropriate mbeans
                if (!(e.getCause() instanceof InstanceNotFoundException))
                    throw e;
            }

            statsTable.spaceUsedLive = format(
                    (Long) probe.getColumnFamilyMetric(keyspaceName, tableName, "LiveDiskSpaceUsed"),
                    humanReadable);
            statsTable.spaceUsedTotal = format(
                    (Long) probe.getColumnFamilyMetric(keyspaceName, tableName, "TotalDiskSpaceUsed"),
                    humanReadable);
            statsTable.spaceUsedBySnapshotsTotal = format(
                    (Long) probe.getColumnFamilyMetric(keyspaceName, tableName, "SnapshotsSize"),
                    humanReadable);
            if (offHeapSize != null) {
                statsTable.offHeapUsed = true;
                statsTable.offHeapMemoryUsedTotal = format(offHeapSize, humanReadable);

            }
            if (percentRepaired != null) {
                statsTable.percentRepaired = Math.round(100 * percentRepaired) / 100.0;
            }
            statsTable.sstableCompressionRatio = probe.getColumnFamilyMetric(keyspaceName, tableName,
                    "CompressionRatio");
            Object estimatedPartitionCount = probe.getColumnFamilyMetric(keyspaceName, tableName,
                    "EstimatedPartitionCount");
            if (Long.valueOf(-1L).equals(estimatedPartitionCount)) {
                estimatedPartitionCount = 0L;
            }
            statsTable.numberOfKeysEstimate = estimatedPartitionCount;

            statsTable.memtableCellCount = probe.getColumnFamilyMetric(keyspaceName, tableName,
                    "MemtableColumnsCount");
            statsTable.memtableDataSize = format(
                    (Long) probe.getColumnFamilyMetric(keyspaceName, tableName, "MemtableLiveDataSize"),
                    humanReadable);
            if (memtableOffHeapSize != null) {
                statsTable.memtableOffHeapUsed = true;
                statsTable.memtableOffHeapMemoryUsed = format(memtableOffHeapSize, humanReadable);
            }
            statsTable.memtableSwitchCount = probe.getColumnFamilyMetric(keyspaceName, tableName,
                    "MemtableSwitchCount");
            statsTable.localReadCount = ((CassandraMetricsRegistry.JmxTimerMBean) probe
                    .getColumnFamilyMetric(keyspaceName, tableName, "ReadLatency")).getCount();

            double localReadLatency = ((CassandraMetricsRegistry.JmxTimerMBean) probe
                    .getColumnFamilyMetric(keyspaceName, tableName, "ReadLatency")).getMean() / 1000;
            double localRLatency = localReadLatency > 0 ? localReadLatency : Double.NaN;
            statsTable.localReadLatencyMs = localRLatency;
            statsTable.localWriteCount = ((CassandraMetricsRegistry.JmxTimerMBean) probe
                    .getColumnFamilyMetric(keyspaceName, tableName, "WriteLatency")).getCount();

            double localWriteLatency = ((CassandraMetricsRegistry.JmxTimerMBean) probe
                    .getColumnFamilyMetric(keyspaceName, tableName, "WriteLatency")).getMean() / 1000;
            double localWLatency = localWriteLatency > 0 ? localWriteLatency : Double.NaN;
            statsTable.localWriteLatencyMs = localWLatency;
            statsTable.pendingFlushes = probe.getColumnFamilyMetric(keyspaceName, tableName, "PendingFlushes");

            statsTable.bloomFilterFalsePositives = probe.getColumnFamilyMetric(keyspaceName, tableName,
                    "BloomFilterFalsePositives");
            statsTable.bloomFilterFalseRatio = probe.getColumnFamilyMetric(keyspaceName, tableName,
                    "RecentBloomFilterFalseRatio");
            statsTable.bloomFilterSpaceUsed = format(
                    (Long) probe.getColumnFamilyMetric(keyspaceName, tableName, "BloomFilterDiskSpaceUsed"),
                    humanReadable);

            if (bloomFilterOffHeapSize != null) {
                statsTable.bloomFilterOffHeapUsed = true;
                statsTable.bloomFilterOffHeapMemoryUsed = format(bloomFilterOffHeapSize, humanReadable);
            }

            if (indexSummaryOffHeapSize != null) {
                statsTable.indexSummaryOffHeapUsed = true;
                statsTable.indexSummaryOffHeapMemoryUsed = format(indexSummaryOffHeapSize, humanReadable);
            }
            if (compressionMetadataOffHeapSize != null) {
                statsTable.compressionMetadataOffHeapUsed = true;
                statsTable.compressionMetadataOffHeapMemoryUsed = format(compressionMetadataOffHeapSize,
                        humanReadable);
            }
            statsTable.compactedPartitionMinimumBytes = (Long) probe.getColumnFamilyMetric(keyspaceName,
                    tableName, "MinPartitionSize");
            statsTable.compactedPartitionMaximumBytes = (Long) probe.getColumnFamilyMetric(keyspaceName,
                    tableName, "MaxPartitionSize");
            statsTable.compactedPartitionMeanBytes = (Long) probe.getColumnFamilyMetric(keyspaceName, tableName,
                    "MeanPartitionSize");

            CassandraMetricsRegistry.JmxHistogramMBean histogram = (CassandraMetricsRegistry.JmxHistogramMBean) probe
                    .getColumnFamilyMetric(keyspaceName, tableName, "LiveScannedHistogram");
            statsTable.averageLiveCellsPerSliceLastFiveMinutes = histogram.getMean();
            statsTable.maximumLiveCellsPerSliceLastFiveMinutes = histogram.getMax();

            histogram = (CassandraMetricsRegistry.JmxHistogramMBean) probe.getColumnFamilyMetric(keyspaceName,
                    tableName, "TombstoneScannedHistogram");
            statsTable.averageTombstonesPerSliceLastFiveMinutes = histogram.getMean();
            statsTable.maximumTombstonesPerSliceLastFiveMinutes = histogram.getMax();
            statsTable.droppedMutations = format(
                    (Long) probe.getColumnFamilyMetric(keyspaceName, tableName, "DroppedMutations"),
                    humanReadable);
            statsKeyspace.tables.add(statsTable);
        }
        holder.keyspaces.add(statsKeyspace);
    }
    // print out the keyspace and table statistics
    TableStatsPrinter printer = TableStatsPrinter.from(outputFormat);
    printer.print(holder, System.out);
}

From source file:eu.opensourceprojects.mondo.benchmarks.transformationzoo.instantiator.SpecimenGenerator.java

public List<EObject> generate(ResourceSet resourceSet) {
    Gpw.setSeed(c.getSeed());/* ww w .j a v a  2s.  c om*/
    List<EObject> ret = newArrayList();
    ListMultimap<EClass, EObject> indexByKind = ArrayListMultimap.create();

    currentDepth = 0;
    currentMaxDepth = 0;

    for (EClass eClass : c.possibleRootEClasses()) {
        currentMaxDepth = c.getDepthDistributionFor(eClass).sample();
        int nbInstance = c.getRootDistributionFor(eClass).sample();
        for (int i = 0; i < nbInstance; i++) {

            Optional<EObject> generateEObject = generateEObject(eClass, indexByKind);
            if (generateEObject.isPresent()) {
                ret.add(generateEObject.get());
            }
        }
    }

    //System.out.println("Generating XRef");

    for (EObject eObjectRoot : ret) {
        TreeIterator<EObject> eAllContents = eObjectRoot.eAllContents();
        while (eAllContents.hasNext()) {
            EObject eObject = eAllContents.next();
            generateCrossReferences(eObject, indexByKind);
        }
    }

    Map<EClass, Integer> resourcesSize = newHashMap();
    for (EClass eClass : c.possibleRootEClasses()) {
        setNextResourceSizeForType(resourcesSize, eClass);
    }

    // Avoid the generation of several resources
    //
    // System.out.println("Generating resources");
    //
    // for (EObject eObjectRoot : ret) {
    // TreeIterator<EObject> eAllContents = eObjectRoot.eAllContents();
    // createResource(resourceSet, resourcesSize, eAllContents, eObjectRoot,
    // ret);
    // while (eAllContents.hasNext()) {
    // EObject eObject = eAllContents.next();
    // createResource(resourceSet, resourcesSize, eAllContents, eObject,
    // ret);
    // }
    // }
    //
    // System.out.println("#EObject=" +
    // ImmutableSet.copyOf(indexByKind.values()).size());
    // System.out.println("#Resource=" + resourceSet.getResources().size());
    //
    // for (Map.Entry<EClass, Collection<EObject>> entry :
    // indexByKind.asMap().entrySet()) {
    // EClass eClass = entry.getKey();
    // System.out.println("#" + eClass.getEPackage().getNsURI() + "::" +
    // entry.getKey().getName() + "="
    // + entry.getValue().size());
    // }

    return ret;
}

From source file:edu.coeia.hashanalysis.HashAnalysisPanel.java

/** Creates new form HashAnalysisPanel */
public HashAnalysisPanel(final JPanel parentPanel) {
    initComponents();// w  ww.  j a  va2 s . co m

    this.aCase = ((FileSystemPanel) parentPanel).getCase();
    this.caseFacade = ((FileSystemPanel) parentPanel).getCaseFrame().getCaseFacade();
    this.parentFrame = ((FileSystemPanel) parentPanel).getCaseFrame();
    this.hashCategories = new ArrayList<HashCategory>();
    this.hashLibraryDuplicationResult = new ArrayList<MatchingResult>();
    this.caseDuplicationsMap = ArrayListMultimap.create();

    try {
        this.initializingHashCategoriesJList();
    } catch (Exception e) {
        e.printStackTrace();
    }

    TableColumn tableColumn = this.matchedTable.getColumnModel().getColumn(3);
    tableColumn.setCellRenderer(new LabelCellRenderer());

    TableColumn tableColumn2 = this.caseDuplicationResultTable.getColumnModel().getColumn(3);
    tableColumn2.setCellRenderer(new LabelCellRenderer());
}

From source file:org.mskcc.cbio.portal.mut_diagram.Pileup.java

/**
 * Return a list of pileups for the specified list of mutations.  The list of
 * pileups may be empty but will not be null.
 *
 * @param mutations list of mutations, must not be null
 * @return a list of pileups for the specified list of mutations
 *///from   w w  w . java2s. c  o  m
public static List<Pileup> pileup(final List<ExtendedMutation> mutations) {
    checkNotNull(mutations, "mutations must not be null");

    List<Pileup> pileups = Lists.newArrayList();
    SetMultimap<Integer, String> labels = HashMultimap.create();
    ListMultimap<Integer, ExtendedMutation> mutationsByLocation = ArrayListMultimap.create();
    for (ExtendedMutation mutation : mutations) {
        String label = mutation.getProteinChange();
        if (label != null) {
            try {
                int location = Integer.valueOf(label.replaceAll("[A-Za-z\\.*]+", ""));
                labels.put(location, label);
                mutationsByLocation.put(location, mutation);
            } catch (NumberFormatException e) {
                logger.warn("ignoring extended mutation " + label + ", no location information");
            }
        }
    }

    for (Map.Entry<Integer, Collection<ExtendedMutation>> entry : mutationsByLocation.asMap().entrySet()) {
        int location = entry.getKey();
        Set<String> locationLabels = labels.get(location);
        List<String> sortedLocationLabels = new ArrayList<String>();
        sortedLocationLabels.addAll(locationLabels);
        Collections.sort(sortedLocationLabels);
        String label = Joiner.on("/").join(sortedLocationLabels);
        int missenseCount = 0;
        Set<String> caseIds = Sets.newHashSet();

        for (ExtendedMutation mutation : entry.getValue()) {
            caseIds.add(mutation.getSampleId() + ":" + mutation.getProteinChange());

            if (mutation.getMutationType() != null
                    && mutation.getMutationType().toLowerCase().contains("missense")) {
                missenseCount++;
            }
        }

        pileups.add(new Pileup(label, location, caseIds.size(), missenseCount));
    }

    return ImmutableList.copyOf(pileups);
}