List of usage examples for com.google.common.collect TreeMultimap keySet
@Override @GwtIncompatible("NavigableSet") public NavigableSet<K> keySet()
Because a TreeMultimap has unique sorted keys, this method returns a NavigableSet , instead of the java.util.Set specified in the Multimap interface.
From source file:com.enitalk.controllers.bots.TimeZoneTestr.java
public static void main(String[] args) { Set<String> ids = DateTimeZone.getAvailableIDs(); TreeMultimap<Long, String> map = TreeMultimap.create(); for (String id : ids) { DateTimeZone dz = DateTimeZone.forID(id); int offset = dz.getOffset(DateTime.now().withZone(DateTimeZone.UTC)); map.put(TimeUnit.MILLISECONDS.toMinutes(offset), id); }// www .j a v a 2 s. com ObjectMapper j = new ObjectMapper(); ArrayNode a = j.createArrayNode(); map.keySet().forEach((Long key) -> { a.addObject().set(key.toString(), j.convertValue(map.get(key), ArrayNode.class)); }); System.out.println(a); // System.out.println(map); }
From source file:org.crypto.sse.DynRH_Disk.java
public static void update(ConcurrentMap<String, byte[]> dictionary, TreeMultimap<String, byte[]> tokenUp) { for (String label : tokenUp.keySet()) { dictionary.put(label, tokenUp.get(label).first()); }//from ww w .j a va 2 s.c o m }
From source file:org.clusion.DynRHAndroid.java
public static void update(HashMap<String, byte[]> dictionary, TreeMultimap<String, byte[]> tokenUp) { for (String label : tokenUp.keySet()) { dictionary.put(label, tokenUp.get(label).first()); }//w w w .j a va 2 s.com }
From source file:com.publictransitanalytics.scoregenerator.output.ComparativeSectorReachInformation.java
private static Map<SimplePath, Integer> getPathCounts(final Set<MovementPath> bestPaths) throws InterruptedException { final Map<SimplePath, Integer> pathCounts; final TreeMultimap<Integer, SimplePath> frequencyMap = TreeMultimap.create(Integer::compareTo, (p1, p2) -> p1.toString().compareTo(p2.toString())); if (bestPaths != null) { final ImmutableMultiset.Builder<SimplePath> bestSimplePathsBuilder = ImmutableMultiset.builder(); for (final MovementPath bestPath : bestPaths) { bestSimplePathsBuilder.add(new SimplePath(bestPath)); }/* w w w .ja v a 2s .co m*/ final ImmutableMultiset<SimplePath> bestSimplePaths = bestSimplePathsBuilder.build(); for (final SimplePath path : bestSimplePaths.elementSet()) { frequencyMap.put(bestSimplePaths.count(path), path); } pathCounts = new LinkedHashMap<>(); for (final Integer frequency : frequencyMap.keySet().descendingSet()) { final NavigableSet<SimplePath> pathsForFrequency = frequencyMap.get(frequency); for (final SimplePath pathForFrequency : pathsForFrequency) { pathCounts.put(pathForFrequency, frequency); } } } else { pathCounts = null; } return pathCounts; }
From source file:org.icgc.dcc.portal.util.MutationUtils.java
/** * Determines the unique affected donor counts by project from the supplied ssm occurrences. * /*from www. java2 s . c om*/ * @param ssmOccurrences - the list of ssm occurrences of the related mutation * @return the affected donor counts by project */ public static List<Map<String, Object>> affectedProjectDonorCounts(List<Map<String, Object>> ssmOccurrences) { // Sorted for stability TreeMultimap<String, String> projectDonorIds = TreeMultimap.create(); Map<String, String> projectNames = newHashMap(); for (val ssmOccurrence : ssmOccurrences) { String projectId = projectId(ssmOccurrence); projectNames.put(projectId, projectName(ssmOccurrence)); projectDonorIds.put(projectId, donorId(ssmOccurrence)); } List<Map<String, Object>> records = newArrayList(); for (String projectId : projectDonorIds.keySet()) { // Attributes String projectName = projectNames.get(projectId); Integer projectDonorCount = projectDonorIds.get(projectId).size(); // Assemble Map<String, Object> record = newLinkedHashMap(); record.put("_project_id", projectId); record.put("project_name", projectName); record.put("count", projectDonorCount); records.add(record); } return records; }
From source file:org.artifactory.repo.cleanup.IntegrationCleanupServiceImpl.java
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()); }//from w w w . ja v a2 s . c o m // May need to prune the parents of deleted files for (RepoPath parent : parents) { pruningService.prune(parent); } }
From source file:com.tuplejump.stargate.lucene.query.function.MatchPartition.java
private List<Tuple> getAllMatches(ResultMapper resultMapper, Map<String, Integer> positions) { List<Tuple> allMatches = new ArrayList<>(); TreeMultimap<DecoratedKey, IndexEntryCollector.IndexEntry> docs = resultMapper.docsByRowKey(); for (final DecoratedKey dk : docs.keySet()) { List<IndexEntryCollector.IndexEntry> entries = new ArrayList<>(docs.get(dk)); final Map<CellName, ColumnFamily> fullSlice = resultMapper.fetchRangeSlice(entries, dk); List<Tuple> tuples = new ArrayList<>(fullSlice.size()); for (IndexEntryCollector.IndexEntry entry : entries) { CellName cellName = entry.clusteringKey; ColumnFamily cf = fullSlice.get(cellName); if (cf != null) { Tuple tuple = aggregateFunction.createTuple(options); resultMapper.tableMapper.load(positions, tuple, new Row(dk, cf)); tuples.add(tuple);/*ww w. j av a 2 s. c o m*/ } } int splice = Math.min(tuples.size(), maxMatches); allMatches.addAll(matchPartition(tuples.subList(0, splice))); } return allMatches; }
From source file:com.tuplejump.stargate.cassandra.RowFetcher.java
private List<Row> fetchIOOptimized() throws IOException { List<Row> rows = new ArrayList<>(); TreeMultimap<DecoratedKey, IndexEntryCollector.IndexEntry> docs = resultMapper.docsByRowKey(); for (DecoratedKey dk : docs.keySet()) { NavigableSet<IndexEntryCollector.IndexEntry> entries = docs.get(dk); if (!resultMapper.filter.dataRange.contains(dk)) { if (logger.isTraceEnabled()) { logger.trace("Skipping entry {} outside of assigned scan range", dk.getToken()); }/* w w w .j a v a 2s. c om*/ continue; } final Map<CellName, ColumnFamily> fullSlice = resultMapper.fetchPagedRangeSlice(entries, dk, limit); for (IndexEntryCollector.IndexEntry input : entries) { CellName cellName = input.clusteringKey; if (!resultMapper.filter.columnFilter(dk.getKey()).maySelectPrefix(table.getComparator(), cellName.start())) { continue; } ColumnFamily data = fullSlice.get(cellName); if (data == null || resultMapper.searchSupport.deleteIfNotLatest(dk, data.maxTimestamp(), input.pkName, data)) continue; float score = input.score; ColumnFamily cleanColumnFamily = resultMapper.showScore ? scored(score, data) : data; rows.add(new Row(dk, cleanColumnFamily)); columnsCount++; if (columnsCount > limit) break; } if (columnsCount > limit) break; } return rows; }
From source file:eus.ixa.ixa.pipe.ml.resources.POSDictionary.java
public String getMostFrequentTag(String word) { TreeMultimap<Integer, String> mfTagMap = getOrderedMap(word); String mfTag = null;//from w w w . j av a 2 s. c o m if (!mfTagMap.isEmpty()) { SortedSet<String> mfTagSet = mfTagMap.get(mfTagMap.keySet().first()); mfTag = mfTagSet.first(); } else { mfTag = "O"; } return mfTag; }
From source file:org.artifactory.repo.cleanup.IntegrationCleanupServiceImpl.java
/** * 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/*from w w w . j a va2 s .c o m*/ */ 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); } } }