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

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

Introduction

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

Prototype

Map<K, Collection<V>> asMap();

Source Link

Document

Returns a view of this multimap as a Map from each distinct key to the nonempty collection of that key's associated values.

Usage

From source file:edu.cmu.lti.oaqa.baseqa.document.rerank.scorers.LuceneDocumentScorer.java

@Override
public void prepare(JCas jcas) throws AnalysisEngineProcessException {
    uri2conf2score = HashBasedTable.create();
    uri2conf2rank = HashBasedTable.create();
    List<String> tokens = TypeUtil.getOrderedTokens(jcas).stream().map(Token::getCoveredText)
            .map(QueryParser::escape).filter(name -> !name.isEmpty() && !stoplist.contains(name.toLowerCase()))
            .collect(toList());//  w  w  w  .  j a v a2 s .  c o  m
    Multimap<String, String> ctype2names = HashMultimap.create();
    for (Concept concept : TypeUtil.getConcepts(jcas)) {
        Set<String> ctypes = TypeUtil.getConceptTypes(concept).stream().map(ConceptType::getAbbreviation)
                .collect(toSet());
        String cnames = TypeUtil.getConceptNames(concept).stream().map(LuceneDocumentScorer::normalizeQuoteName)
                .distinct().collect(joining(" "));
        ctypes.stream().filter(t -> !FORBIDDEN_CTYPES.contains(t))
                .forEach(ctype -> ctype2names.put(ctype, cnames));
    }
    Multimap<String, String> ctypepre2names = HashMultimap.create();
    ctype2names.asMap().entrySet().forEach(e -> ctypepre2names.putAll(e.getKey().split(":")[0], e.getValue()));
    Multimap<String, String> ctype2mentions = HashMultimap.create();
    for (Concept concept : TypeUtil.getConcepts(jcas)) {
        Set<String> ctypes = TypeUtil.getConceptTypes(concept).stream().map(ConceptType::getAbbreviation)
                .collect(toSet());
        String cmentions = TypeUtil.getConceptMentions(concept).stream().map(ConceptMention::getMatchedName)
                .map(LuceneDocumentScorer::normalizeQuoteName).distinct().collect(joining(" "));
        ctypes.stream().filter(t -> !FORBIDDEN_CTYPES.contains(t))
                .forEach(ctype -> ctype2mentions.put(ctype, cmentions));
    }
    Multimap<String, String> ctypepre2mentions = HashMultimap.create();
    ctypepre2mentions.asMap().entrySet()
            .forEach(e -> ctypepre2mentions.putAll(e.getKey().split(":")[0], e.getValue()));
    LOG.debug("Query strings");
    ExecutorService service = Executors.newCachedThreadPool();
    // execute against all tokens
    service.submit(() -> {
        String concatTokens = String.join(" ", tokens);
        LOG.debug(" - Concatenated tokens: {}", concatTokens);
        for (String field : fields) {
            searchInField(concatTokens, field, "tokens_concatenated@" + field);
        }
        searchAllField(concatTokens, "tokens_concatenated@all");
    });
    // execute against concatenated concept names
    service.submit(() -> {
        String concatCnames = String.join(" ", ctype2names.values());
        LOG.debug(" - Concatenated concept names: {}", concatCnames);
        for (String field : fields) {
            searchInField(concatCnames, field, "cnames_concatenated@" + field);
        }
        searchAllField(concatCnames, "cnames_concatenated@all");
    });
    // execute against concatenated concept mentions
    service.submit(() -> {
        String concatCmentions = String.join(" ", ctype2mentions.values());
        LOG.debug(" - Concatenated concept mentions: {}", concatCmentions);
        for (String field : fields) {
            searchInField(concatCmentions, field, "cmentions_concatenated@" + field);
        }
        searchAllField(concatCmentions, "cmentions_concatenated@");
    });
    // execute against concept names for each concept
    service.submit(() -> {
        for (String cnames : ImmutableSet.copyOf(ctype2names.values())) {
            LOG.debug(" - Concatenated concept names: {}", cnames);
            for (String field : fields) {
                searchInField(cnames, field, "cnames_individual@" + field);
            }
            searchAllField(cnames, "cnames_individual@all");
        }
    });
    // execute against concept names for each concept type
    service.submit(() -> {
        for (String ctype : ctype2names.keySet()) {
            String concatCnames = String.join(" ", ctype2names.get(ctype));
            LOG.debug(" - Concatenated concept names for {}: {}", ctype, concatCnames);
            for (String field : fields) {
                searchInField(concatCnames, field, "cnames@" + ctype + "@" + field);
            }
            searchAllField(concatCnames, "cnames@" + ctype + "@all");
        }
    });
    // execute against concept names for each concept type prefix
    service.submit(() -> {
        for (String ctypepre : ctypepre2names.keySet()) {
            String concatCnames = String.join(" ", ctypepre2names.get(ctypepre));
            LOG.debug(" - Concatenated concept names for {}: {}", ctypepre, concatCnames);
            for (String field : fields) {
                searchInField(concatCnames, field, "cnames@" + ctypepre + "@" + field);
            }
            searchAllField(concatCnames, "cnames@" + ctypepre + "@all");
        }
    });
    // execute against concept mentions for each concept
    service.submit(() -> {
        for (String cmentions : ImmutableSet.copyOf(ctype2mentions.values())) {
            LOG.debug(" - Concatenated concept mentions: {}", cmentions);
            for (String field : fields) {
                searchInField(cmentions, field, "cmentions_individual@" + field);
            }
            searchAllField(cmentions, "cmentions_individual@all");
        }
    });
    // execute against concept mentions for each concept type
    service.submit(() -> {
        for (String ctype : ctype2mentions.keySet()) {
            String concatCmentions = String.join(" ", ctype2mentions.get(ctype));
            LOG.debug(" - Concatenated concept mentions for {}: {}", ctype, concatCmentions);
            for (String field : fields) {
                searchInField(concatCmentions, field, "cmentions@" + ctype + "@" + field);
            }
            searchAllField(concatCmentions, "cmentions@" + ctype + "@all");
        }
    });
    // execute against concept mentions for each concept type prefix
    service.submit(() -> {
        for (String ctypepre : ctypepre2mentions.keySet()) {
            String concatCmentions = String.join(" ", ctypepre2mentions.get(ctypepre));
            LOG.debug(" - Concatenated concept mentions for {}: {}", ctypepre, concatCmentions);
            for (String field : fields) {
                searchInField(concatCmentions, field, "cmentions@" + ctypepre + "@" + field);
            }
            searchAllField(concatCmentions, "cmentions@" + ctypepre + "@all");
        }
    });
    service.shutdown();
    try {
        service.awaitTermination(1, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        throw new AnalysisEngineProcessException(e);
    }
    confs = new HashSet<>(uri2conf2score.columnKeySet()); // to avoid ConcurrentModificationException
}

From source file:com.facebook.swift.codec.metadata.ThriftStructMetadataBuilder.java

private Iterable<ThriftFieldMetadata> buildFieldInjections() {
    Multimap<Optional<Short>, FieldMetadata> fieldsById = Multimaps.index(fields, getThriftFieldId());
    return Iterables.transform(fieldsById.asMap().values(),
            new Function<Collection<FieldMetadata>, ThriftFieldMetadata>() {
                @Override/*  ww  w .  j a  v a2 s.com*/
                public ThriftFieldMetadata apply(Collection<FieldMetadata> input) {
                    checkArgument(!input.isEmpty(), "input is empty");
                    return buildField(input);
                }
            });
}

From source file:it.unibz.inf.ontop.r2rml.R2RMLWriter.java

private ImmutableList<OBDAMappingAxiom> splitMappingAxiom(OBDAMappingAxiom mappingAxiom,
        String delimiterSubstring) {
    Multimap<Function, Function> subjectTermToTargetTriples = ArrayListMultimap.create();
    for (Function targetTriple : mappingAxiom.getTargetQuery()) {
        Function subjectTerm = getFirstFunctionalTerm(targetTriple)
                .orElseThrow(() -> new IllegalStateException("Invalid OBDA mapping"));
        subjectTermToTargetTriples.put(subjectTerm, targetTriple);
    }// w  ww  .  ja  va 2 s .  c o m
    // If the partition per target triple subject is non trivial
    if (subjectTermToTargetTriples.size() > 1) {
        // Create ids for the new mapping axioms
        Map<Function, String> subjectTermToMappingIndex = new HashMap<>();
        int i = 1;
        for (Function subjectTerm : subjectTermToTargetTriples.keySet()) {
            subjectTermToMappingIndex.put(subjectTerm, mappingAxiom.getId() + delimiterSubstring + i);
            i++;
        }
        // Generate one mapping axiom per subject
        return subjectTermToTargetTriples.asMap().entrySet().stream()
                .map(e -> OBDA_DATA_FACTORY.getRDBMSMappingAxiom(subjectTermToMappingIndex.get(e.getKey()),
                        mappingAxiom.getSourceQuery(), new ArrayList<Function>(e.getValue())))
                .collect(ImmutableCollectors.toList());
    }
    return ImmutableList.of(mappingAxiom);
}

From source file:com.palantir.atlasdb.keyvalue.cassandra.CassandraVerifier.java

protected static void sanityCheckRingConsistency(Set<InetSocketAddress> currentAddrs, String keyspace,
        boolean isSsl, boolean safetyDisabled, int socketTimeoutMillis, int socketQueryTimeoutMillis) {
    Multimap<Set<TokenRange>, InetSocketAddress> tokenRangesToHost = HashMultimap.create();
    for (InetSocketAddress addr : currentAddrs) {
        Cassandra.Client client = null;/*  w  ww.j a  v a  2s.  co m*/
        try {
            client = CassandraClientFactory.getClientInternal(addr, isSsl, socketTimeoutMillis,
                    socketQueryTimeoutMillis);
            try {
                client.describe_keyspace(keyspace);
            } catch (NotFoundException e) {
                log.info(
                        "Tried to check ring consistency for node {} before keyspace was fully setup; aborting check for now.",
                        addr, e);
                return;
            }
            tokenRangesToHost.put(ImmutableSet.copyOf(client.describe_ring(keyspace)), addr);
        } catch (Exception e) {
            log.warn("failed to get ring info from host: {}", addr, e);
        } finally {
            if (client != null) {
                client.getOutputProtocol().getTransport().close();
            }
        }
    }

    if (tokenRangesToHost.isEmpty()) {
        log.error(
                "Failed to get ring info for entire Cassandra cluster ({}); ring could not be checked for consistency.",
                keyspace);
        return;
    }

    if (tokenRangesToHost.keySet().size() == 1) {
        return;
    }

    RuntimeException e = new IllegalStateException(
            "Hosts have differing ring descriptions.  This can lead to inconsistent reads and lost data. ");
    log.error("QA-86204 " + e.getMessage() + tokenRangesToHost, e);

    if (tokenRangesToHost.size() > 2) {
        for (Entry<Set<TokenRange>, Collection<InetSocketAddress>> entry : tokenRangesToHost.asMap()
                .entrySet()) {
            if (entry.getValue().size() == 1) {
                log.error("Host: " + entry.getValue().iterator().next()
                        + " disagrees with the other nodes about the ring state.");
            }
        }
    }

    if (tokenRangesToHost.keySet().size() == 2) {
        ImmutableList<Set<TokenRange>> sets = ImmutableList.copyOf(tokenRangesToHost.keySet());
        Set<TokenRange> set1 = sets.get(0);
        Set<TokenRange> set2 = sets.get(1);
        log.error("Hosts are split.  group1: " + tokenRangesToHost.get(set1) + " group2: "
                + tokenRangesToHost.get(set2));
    }

    logErrorOrThrow(e.getMessage(), safetyDisabled);
}

From source file:org.apache.hadoop.hbase.mapreduce.LoadIncrementalHFiles.java

/**
 * This takes the LQI's grouped by likely regions and attempts to bulk load
 * them.  Any failures are re-queued for another pass with the
 * groupOrSplitPhase.//from   w w  w  . j a  v  a  2  s . com
 */
protected void bulkLoadPhase(final HTable table, final HConnection conn, ExecutorService pool,
        Deque<LoadQueueItem> queue, final Multimap<ByteBuffer, LoadQueueItem> regionGroups) throws IOException {
    // atomically bulk load the groups.
    Set<Future<List<LoadQueueItem>>> loadingFutures = new HashSet<Future<List<LoadQueueItem>>>();
    for (Entry<ByteBuffer, ? extends Collection<LoadQueueItem>> e : regionGroups.asMap().entrySet()) {
        final byte[] first = e.getKey().array();
        final Collection<LoadQueueItem> lqis = e.getValue();

        final Callable<List<LoadQueueItem>> call = new Callable<List<LoadQueueItem>>() {
            public List<LoadQueueItem> call() throws Exception {
                List<LoadQueueItem> toRetry = tryAtomicRegionLoad(conn, table.getName(), first, lqis);
                return toRetry;
            }
        };
        loadingFutures.add(pool.submit(call));
    }

    // get all the results.
    for (Future<List<LoadQueueItem>> future : loadingFutures) {
        try {
            List<LoadQueueItem> toRetry = future.get();

            // LQIs that are requeued to be regrouped.
            queue.addAll(toRetry);

        } catch (ExecutionException e1) {
            Throwable t = e1.getCause();
            if (t instanceof IOException) {
                // At this point something unrecoverable has happened.
                // TODO Implement bulk load recovery
                throw new IOException("BulkLoad encountered an unrecoverable problem", t);
            }
            LOG.error("Unexpected execution exception during bulk load", e1);
            throw new IllegalStateException(t);
        } catch (InterruptedException e1) {
            LOG.error("Unexpected interrupted exception during bulk load", e1);
            throw (InterruptedIOException) new InterruptedIOException().initCause(e1);
        }
    }
}

From source file:org.gradle.build.docs.dsl.source.GenerateDefaultImportsTask.java

@TaskAction
public void generate() throws IOException {
    SimpleClassMetaDataRepository<ClassMetaData> repository = new SimpleClassMetaDataRepository<ClassMetaData>();
    repository.load(getMetaDataFile());//from  w  w  w.  ja v a  2 s  .c om

    final Set<String> excludedPrefixes = new HashSet<String>();
    final Set<String> excludedPackages = new HashSet<String>();
    for (String excludePattern : excludePatterns) {
        if (excludePattern.endsWith(".**")) {
            String baseName = excludePattern.substring(0, excludePattern.length() - 3);
            excludedPrefixes.add(baseName + '.');
            excludedPackages.add(baseName);
        } else {
            excludedPackages.add(excludePattern);
        }
    }
    final Set<String> packages = new TreeSet<String>();
    packages.addAll(extraPackages);
    final Multimap<String, String> simpleNames = HashMultimap.create();

    repository.each(new Action<ClassMetaData>() {
        public void execute(ClassMetaData classMetaData) {
            if (classMetaData.getOuterClassName() != null) {
                // Ignore inner classes
                return;
            }
            String packageName = classMetaData.getPackageName();
            if (excludedPackages.contains(packageName)) {
                return;
            }
            for (String excludedPrefix : excludedPrefixes) {
                if (packageName.startsWith(excludedPrefix)) {
                    return;
                }
            }
            simpleNames.put(classMetaData.getSimpleName(), classMetaData.getClassName());
            packages.add(packageName);
        }
    });

    for (Map.Entry<String, Collection<String>> entry : simpleNames.asMap().entrySet()) {
        if (entry.getValue().size() > 1) {
            System.out.println(String.format("Multiple DSL types have short name '%s'", entry.getKey()));
            for (String className : entry.getValue()) {
                System.out.println("    * " + className);
            }
        }
    }

    final PrintWriter writer = new PrintWriter(new FileWriter(getDestFile()));
    try {
        for (String packageName : packages) {
            writer.print("import ");
            writer.print(packageName);
            writer.println(".*");
        }
    } finally {
        writer.close();
    }
}

From source file:org.eclipse.jdt.ls.core.internal.highlighting.SemanticHighlightingService.java

protected List<SemanticHighlightingInformation> toInfos(IDocument document,
        List<HighlightedPositionCore> positions) {
    Multimap<Integer, SemanticHighlightingTokens.Token> infos = HashMultimap.create();
    for (HighlightedPositionCore position : positions) {
        int[] lineAndColumn = JsonRpcHelpers.toLine(document, position.offset);
        if (lineAndColumn == null) {
            JavaLanguageServerPlugin.logError(
                    "Cannot locate line and column information for the semantic highlighting position: "
                            + position + ". Skipping it.");
            continue;
        }//from w  w  w  .ja  v a 2s .  c  o m
        int line = lineAndColumn[0];
        int character = lineAndColumn[1];
        int length = position.length;
        int scope = LOOKUP_TABLE.inverse().get(position.getHighlighting());
        infos.put(line, new SemanticHighlightingTokens.Token(character, length, scope));
    }
    //@formatter:off
    return infos.asMap().entrySet().stream().map(entry -> new SemanticHighlightingInformation(entry.getKey(),
            SemanticHighlightingTokens.encode(entry.getValue()))).collect(Collectors.toList());
    //@formatter:on
}

From source file:edu.cmu.lti.oaqa.baseqa.concept.rerank.scorers.LuceneConceptScorer.java

@Override
public void prepare(JCas jcas) throws AnalysisEngineProcessException {
    uri2conf2score = HashBasedTable.create();
    uri2conf2rank = HashBasedTable.create();
    List<String> tokens = TypeUtil.getOrderedTokens(jcas).stream().map(Token::getCoveredText)
            .map(QueryParser::escape).filter(name -> !name.isEmpty() && !stoplist.contains(name.toLowerCase()))
            .collect(toList());//from w  ww .  jav a2 s. c o  m
    Multimap<String, String> ctype2names = HashMultimap.create();
    for (Concept concept : TypeUtil.getConcepts(jcas)) {
        Set<String> ctypes = TypeUtil.getConceptTypes(concept).stream().map(ConceptType::getAbbreviation)
                .collect(toSet());
        String cnames = TypeUtil.getConceptNames(concept).stream().map(LuceneConceptScorer::normalizeQuoteName)
                .distinct().collect(joining(" "));
        ctypes.stream().filter(t -> !FORBIDDEN_CTYPES.contains(t))
                .forEach(ctype -> ctype2names.put(ctype, cnames));
    }
    Multimap<String, String> ctypepre2names = HashMultimap.create();
    ctype2names.asMap().entrySet().forEach(e -> ctypepre2names.putAll(e.getKey().split(":")[0], e.getValue()));
    Multimap<String, String> ctype2mentions = HashMultimap.create();
    for (Concept concept : TypeUtil.getConcepts(jcas)) {
        Set<String> ctypes = TypeUtil.getConceptTypes(concept).stream().map(ConceptType::getAbbreviation)
                .collect(toSet());
        String cmentions = TypeUtil.getConceptMentions(concept).stream().map(ConceptMention::getMatchedName)
                .map(LuceneConceptScorer::normalizeQuoteName).distinct().collect(joining(" "));
        ctypes.stream().filter(t -> !FORBIDDEN_CTYPES.contains(t))
                .forEach(ctype -> ctype2mentions.put(ctype, cmentions));
    }
    Multimap<String, String> ctypepre2mentions = HashMultimap.create();
    ctypepre2mentions.asMap().entrySet()
            .forEach(e -> ctypepre2mentions.putAll(e.getKey().split(":")[0], e.getValue()));
    LOG.debug("Query strings");
    ExecutorService service = Executors.newCachedThreadPool();
    // execute against all tokens
    service.submit(() -> {
        String concatTokens = String.join(" ", tokens);
        LOG.debug(" - Concatenated tokens: {}", concatTokens);
        for (String field : fields) {
            searchInField(concatTokens, field, "tokens_concatenated@" + field);
        }
        searchAllField(concatTokens, "tokens_concatenated@all");
    });
    // execute against concatenated concept names
    service.submit(() -> {
        String concatCnames = String.join(" ", ctype2names.values());
        LOG.debug(" - Concatenated concept names: {}", concatCnames);
        for (String field : fields) {
            searchInField(concatCnames, field, "cnames_concatenated@" + field);
        }
        searchAllField(concatCnames, "cnames_concatenated@all");
    });
    // execute against concatenated concept mentions
    service.submit(() -> {
        String concatCmentions = String.join(" ", ctype2mentions.values());
        LOG.debug(" - Concatenated concept mentions: {}", concatCmentions);
        for (String field : fields) {
            searchInField(concatCmentions, field, "cmentions_concatenated@" + field);
        }
        searchAllField(concatCmentions, "cmentions_concatenated@");
    });
    // execute against concept names for each concept
    service.submit(() -> {
        for (String cnames : ImmutableSet.copyOf(ctype2names.values())) {
            LOG.debug(" - Concatenated concept names: {}", cnames);
            for (String field : fields) {
                searchInField(cnames, field, "cnames_individual@" + field);
            }
            searchAllField(cnames, "cnames_individual@all");
        }
    });
    // execute against concept names for each concept type
    service.submit(() -> {
        for (String ctype : ctype2names.keySet()) {
            String concatCnames = String.join(" ", ctype2names.get(ctype));
            LOG.debug(" - Concatenated concept names for {}: {}", ctype, concatCnames);
            for (String field : fields) {
                searchInField(concatCnames, field, "cnames@" + ctype + "@" + field);
            }
            searchAllField(concatCnames, "cnames@" + ctype + "@all");
        }
    });
    // execute against concept names for each concept type prefix
    service.submit(() -> {
        for (String ctypepre : ctypepre2names.keySet()) {
            String concatCnames = String.join(" ", ctypepre2names.get(ctypepre));
            LOG.debug(" - Concatenated concept names for {}: {}", ctypepre, concatCnames);
            for (String field : fields) {
                searchInField(concatCnames, field, "cnames@" + ctypepre + "@" + field);
            }
            searchAllField(concatCnames, "cnames@" + ctypepre + "@all");
        }
    });
    // execute against concept mentions for each concept
    service.submit(() -> {
        for (String cmentions : ImmutableSet.copyOf(ctype2mentions.values())) {
            LOG.debug(" - Concatenated concept mentions: {}", cmentions);
            for (String field : fields) {
                searchInField(cmentions, field, "cmentions_individual@" + field);
            }
            searchAllField(cmentions, "cmentions_individual@all");
        }
    });
    // execute against concept mentions for each concept type
    service.submit(() -> {
        for (String ctype : ctype2mentions.keySet()) {
            String concatCmentions = String.join(" ", ctype2mentions.get(ctype));
            LOG.debug(" - Concatenated concept mentions for {}: {}", ctype, concatCmentions);
            for (String field : fields) {
                searchInField(concatCmentions, field, "cmentions@" + ctype + "@" + field);
            }
            searchAllField(concatCmentions, "cmentions@" + ctype + "@all");
        }
    });
    // execute against concept mentions for each concept type prefix
    service.submit(() -> {
        for (String ctypepre : ctypepre2mentions.keySet()) {
            String concatCmentions = String.join(" ", ctypepre2mentions.get(ctypepre));
            LOG.debug(" - Concatenated concept mentions for {}: {}", ctypepre, concatCmentions);
            for (String field : fields) {
                searchInField(concatCmentions, field, "cmentions@" + ctypepre + "@" + field);
            }
            searchAllField(concatCmentions, "cmentions@" + ctypepre + "@all");
        }
    });
    service.shutdown();
    try {
        service.awaitTermination(1, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        throw new AnalysisEngineProcessException(e);
    }
    confs = uri2conf2score.columnKeySet();
}

From source file:com.android.build.gradle.internal.TDependencyManager.java

private void processLibraries(@NonNull Multimap<AndroidLibrary, Configuration> reverseMap) {
    for (Map.Entry<AndroidLibrary, Collection<Configuration>> entry : reverseMap.asMap().entrySet()) {
        setupPrepareLibraryTask(entry.getKey(), entry.getValue());
    }//from w  ww  . j a  v  a 2  s . c  o  m
}

From source file:org.apache.beam.sdk.io.HadoopWriteFiles.java

private List<KV<FileResult<DestinationT>, ResourceId>> finalizeAllDestinations(
        List<FileResult<DestinationT>> fileResults, @Nullable Integer fixedNumShards) throws Exception {
    Multimap<KV<DestinationT, BoundedWindow>, FileResult<DestinationT>> res = ArrayListMultimap.create();
    for (FileResult<DestinationT> result : fileResults) {
        res.put(KV.of(result.getDestination(), result.getWindow()), result);
    }//from  w  w w. ja v a 2  s  .co  m
    List<KV<FileResult<DestinationT>, ResourceId>> resultsToFinalFilenames = Lists.newArrayList();
    for (Map.Entry<KV<DestinationT, BoundedWindow>, Collection<FileResult<DestinationT>>> destEntry : res
            .asMap().entrySet()) {
        KV<DestinationT, BoundedWindow> destWindow = destEntry.getKey();
        resultsToFinalFilenames.addAll(writeOperation.finalizeDestination(destWindow.getKey(),
                destWindow.getValue(), fixedNumShards, destEntry.getValue()));
    }
    return resultsToFinalFilenames;
}