java类com.google.common.collect.TreeMultimap的实例源码

Loader.java 文件源码 项目:CauldronGit 阅读 28 收藏 0 点赞 0 评论 0
private void identifyDuplicates(List<ModContainer> mods)
{
    TreeMultimap<ModContainer, File> dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
    for (ModContainer mc : mods)
    {
        if (mc.getSource() != null)
        {
            dupsearch.put(mc, mc.getSource());
        }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet())
    {
        if (e.getCount() > 1)
        {
            FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement()));
            dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
        }
    }
    if (!dupes.isEmpty())
    {
        throw new DuplicateModsFoundException(dupes);
    }
}
AggregateMultiProjectTaskReportModel.java 文件源码 项目:Pushjet-Android 阅读 21 收藏 0 点赞 0 评论 0
public void build() {
    groups = TreeMultimap.create(new Comparator<String>() {
        public int compare(String string1, String string2) {
            return string1.compareToIgnoreCase(string2);
        }
    }, new Comparator<TaskDetails>() {
        public int compare(TaskDetails task1, TaskDetails task2) {
            return task1.getPath().compareTo(task2.getPath());
        }
    });
    for (TaskReportModel project : projects) {
        for (String group : project.getGroups()) {
            for (final TaskDetails task : project.getTasksForGroup(group)) {
                groups.put(group, mergeTasksWithSameName ? new MergedTaskDetails(task) : task);
            }
        }
    }
}
AggregateMultiProjectTaskReportModel.java 文件源码 项目:Pushjet-Android 阅读 20 收藏 0 点赞 0 评论 0
public void build() {
    groups = TreeMultimap.create(new Comparator<String>() {
        public int compare(String string1, String string2) {
            return string1.compareToIgnoreCase(string2);
        }
    }, new Comparator<TaskDetails>() {
        public int compare(TaskDetails task1, TaskDetails task2) {
            return task1.getPath().compareTo(task2.getPath());
        }
    });
    for (TaskReportModel project : projects) {
        for (String group : project.getGroups()) {
            for (final TaskDetails task : project.getTasksForGroup(group)) {
                groups.put(group, mergeTasksWithSameName ? new MergedTaskDetails(task) : task);
            }
        }
    }
}
RegionSplitCalculator.java 文件源码 项目:pbase 阅读 97 收藏 0 点赞 0 评论 0
/**
 * Generates a coverage multimap from split key to Regions that start with the
 * split key.
 * 
 * @return coverage multimap
 */
public Multimap<byte[], R> calcCoverage() {
  // This needs to be sorted to force the use of the comparator on the values,
  // otherwise byte array comparison isn't used
  Multimap<byte[], R> regions = TreeMultimap.create(BYTES_COMPARATOR,
      rangeCmp);

  // march through all splits from the start points
  for (Entry<byte[], Collection<R>> start : starts.asMap().entrySet()) {
    byte[] key = start.getKey();
    for (R r : start.getValue()) {
      regions.put(key, r);

      for (byte[] coveredSplit : splits.subSet(r.getStartKey(),
          specialEndKey(r))) {
        regions.put(coveredSplit, r);
      }
    }
  }
  return regions;
}
ManageUsers.java 文件源码 项目:scheduling 阅读 16 收藏 0 点赞 0 评论 0
private static Multimap<String, String> loadGroups(String groupFilePath) throws ManageUsersException {
    Multimap<String, String> groupsMap = TreeMultimap.create();
    String line = null;

    try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(groupFilePath)))) {
        while ((line = reader.readLine()) != null) {
            if (!line.trim().isEmpty()) {
                String[] u2g = line.split(":");
                if (u2g.length == 2) {
                    groupsMap.put(u2g[0].trim(), u2g[1].trim());
                }
            }
        }
    } catch (IOException e) {
        exitWithErrorMessage("could not read group file : " + groupFilePath, null, e);
    }
    return groupsMap;
}
IntegrationCleanupServiceImpl.java 文件源码 项目:artifactory 阅读 16 收藏 0 点赞 0 评论 0
/**
 * The integration cleanup deletes artifacts according to the snapshot and the classifier,
 * unlike the previous approach that was to deletes artifacts according to the snapshot only,
 * See issue RTFACT-6675
 */
private void conditionalCleanup(RepoPath repoPath) {
    LocalRepo repo = repositoryService.localRepositoryByKey(repoPath.getRepoKey());
    if (repo == null) {
        return;
    }

    SnapshotVersionsRetriever retriever = new SnapshotVersionsRetriever(false);
    ModuleInfo deployedModuleInfo = repositoryService.getItemModuleInfo(repoPath);
    ModuleInfo baseRevisionModule = getBaseRevisionModuleInfo(deployedModuleInfo);
    TreeMultimap<Calendar, ItemInfo> cleanupCandidates = retriever.collectVersionsItems(repo, baseRevisionModule,
            false);
    Map<String,TreeMultimap<Calendar, ItemInfo>> cleanupCandidatesByClassifier=forkByClassifier(cleanupCandidates);
    for (TreeMultimap<Calendar, ItemInfo> calendarItemInfoTreeMultimap : cleanupCandidatesByClassifier.values()) {
        while (calendarItemInfoTreeMultimap.keySet().size() > repo.getMaxUniqueSnapshots()) {
            performCleanup(calendarItemInfoTreeMultimap);
        }
    }

}
IntegrationCleanupServiceImpl.java 文件源码 项目:artifactory 阅读 15 收藏 0 点赞 0 评论 0
private Map<String, TreeMultimap<Calendar, ItemInfo>> forkByClassifier(
        TreeMultimap<Calendar, ItemInfo> cleanupCandidates) {
    Map<String, TreeMultimap<Calendar, ItemInfo>> result= Maps.newHashMap();
    for (Calendar calendar : cleanupCandidates.keySet()) {
        NavigableSet<ItemInfo> itemInfos = cleanupCandidates.get(calendar);
        for (ItemInfo itemInfo : itemInfos) {
            String classifier=resolveClassifier(itemInfo);
            TreeMultimap<Calendar, ItemInfo> classifierMap = result.get(classifier);
            if(classifierMap==null){
                //classifierMap= TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural().reverse());
                classifierMap= TreeMultimap.create(Ordering.natural(), Ordering.natural());;
                result.put(classifier,classifierMap);
            }
            classifierMap.put(calendar,itemInfo);
        }
    }
    return result;
}
IntegrationCleanupServiceImpl.java 文件源码 项目:artifactory 阅读 16 收藏 0 点赞 0 评论 0
private void performCleanup(TreeMultimap<Calendar, ItemInfo> cleanupCandidates) {
    Calendar first = cleanupCandidates.keySet().first();

    Set<RepoPath> parents = Sets.newHashSet();
    SortedSet<ItemInfo> itemsToRemove = cleanupCandidates.removeAll(first);
    for (ItemInfo itemToRemove : itemsToRemove) {
        RepoPath repoPath = itemToRemove.getRepoPath();
        repositoryService.undeploy(repoPath, false, false);
        parents.add(repoPath.getParent());
        log.info("Removed old unique snapshot '{}'.", itemToRemove.getRelPath());
    }
    // May need to prune the parents of deleted files
    for (RepoPath parent : parents) {
        pruningService.prune(parent);
    }
}
VersionsRetriever.java 文件源码 项目:artifactory 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Collects versions items under the given node for the given repo
 *
 * @param repo                 The repo to search in
 * @param baseRevisionModule   Base module info to search under, we try both artifact and desriptor path if it's distinctive
 * @param pathHasVersionTokens If we should search with version tokens, this applies for release artifacts as the user
 *                             may provide release/integration tokens to search for latest version
 */
public TreeMultimap<Calendar, ItemInfo> collectVersionsItems(StoringRepo repo, ModuleInfo baseRevisionModule,
        boolean pathHasVersionTokens) {
    RepoLayout repoLayout = repo.getDescriptor().getRepoLayout();
    String baseArtifactPath = ModuleInfoUtils.constructArtifactPath(baseRevisionModule, repoLayout, false);
    ItemNode artifactSearchNode = getTreeNode(repo, repoLayout, baseArtifactPath, pathHasVersionTokens);
    if (artifactSearchNode != null) {
        internalCollectVersionsItems(repo, artifactSearchNode);
    }

    if (repoLayout.isDistinctiveDescriptorPathPattern()) {
        String baseDescriptorPath = ModuleInfoUtils.constructDescriptorPath(baseRevisionModule, repoLayout, false);
        if (!baseDescriptorPath.equals(baseArtifactPath)) {
            ItemNode descriptorSearchNode = getTreeNode(repo, repoLayout, baseDescriptorPath, pathHasVersionTokens);
            if (descriptorSearchNode != null) {
                internalCollectVersionsItems(repo, descriptorSearchNode);
            }
        }
    }

    return versionsItems;
}
LocalLatestVersionResolver.java 文件源码 项目:artifactory 阅读 16 收藏 0 点赞 0 评论 0
private InternalRequestContext getLatestVersionRequestContext(InternalRequestContext requestContext,
        StoringRepo repo, ModuleInfo originalModuleInfo, boolean searchForReleaseVersion) {
    VersionsRetriever retriever =
            searchForReleaseVersion ? new ReleaseVersionsRetriever(true) : new SnapshotVersionsRetriever(true);
    ModuleInfo baseRevisionModule = getBaseRevisionModuleInfo(originalModuleInfo);
    TreeMultimap<Calendar, ItemInfo> versionsItems = retriever.collectVersionsItems(repo, baseRevisionModule, true);
    if (versionsItems != null) {
        if (searchForReleaseVersion && !ConstantValues.requestSearchLatestReleaseByDateCreated.getBoolean()) {
            return getRequestContentForReleaseByVersion(versionsItems.values(), repo, requestContext,
                    originalModuleInfo);
        } else {
            return getRequestContextFromMap(versionsItems, repo, requestContext, originalModuleInfo,
                    searchForReleaseVersion);
        }
    } else {
        return requestContext;
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号