List of usage examples for com.google.common.collect Multimap keySet
Set<K> keySet();
From source file:it.sayservice.platform.smartplanner.otp.schedule.sorter.BucketSet.java
private void computeDup(Multimap<String, Bucket> map) { for (String key : map.keySet()) { Collection<Bucket> bs = map.get(key); int dup = 1; for (Bucket b : bs) { b.setDup(dup);/*from w w w. j a va2s . com*/ dup++; } } }
From source file:org.gradle.execution.TaskNameResolvingBuildExecuter.java
public void select(GradleInternal gradle) { Multimap<String, Task> selectedTasks = doSelect(gradle, names, taskNameResolver); this.executer = gradle.getTaskGraph(); for (String name : selectedTasks.keySet()) { executer.addTasks(selectedTasks.get(name)); }/*from w w w. j a va 2 s.c om*/ if (selectedTasks.keySet().size() == 1) { description = String.format("primary task %s", GUtil.toString(selectedTasks.keySet())); } else { description = String.format("primary tasks %s", GUtil.toString(selectedTasks.keySet())); } }
From source file:org.apache.tez.analyzer.plugins.SlowNodeAnalyzer.java
@Override public void analyze(DagInfo dagInfo) throws TezException { Multimap<String, TaskAttemptInfo> nodeDetails = dagInfo.getNodeDetails(); for (String nodeName : nodeDetails.keySet()) { List<String> record = Lists.newLinkedList(); Collection<TaskAttemptInfo> taskAttemptInfos = nodeDetails.get(nodeName); record.add(nodeName);//from ww w.java2 s . c o m record.add(taskAttemptInfos.size() + ""); record.add(getNumberOfTasks(taskAttemptInfos, TaskAttemptState.KILLED) + ""); record.add(getNumberOfTasks(taskAttemptInfos, TaskAttemptState.FAILED) + ""); Iterable<TaskAttemptInfo> succeedTasks = getFilteredTaskAttempts(taskAttemptInfos, TaskAttemptState.SUCCEEDED); record.add(getAvgTaskExecutionTime(succeedTasks) + ""); Iterable<TaskAttemptInfo> killedTasks = getFilteredTaskAttempts(taskAttemptInfos, TaskAttemptState.KILLED); record.add(getAvgTaskExecutionTime(killedTasks) + ""); Iterable<TaskAttemptInfo> failedTasks = getFilteredTaskAttempts(taskAttemptInfos, TaskAttemptState.FAILED); record.add(getAvgTaskExecutionTime(failedTasks) + ""); record.add(getAvgCounter(taskAttemptInfos, FileSystemCounter.class.getName(), FileSystemCounter.HDFS_BYTES_READ.name()) + ""); record.add(getAvgCounter(taskAttemptInfos, FileSystemCounter.class.getName(), FileSystemCounter.HDFS_BYTES_WRITTEN.name()) + ""); record.add(getAvgCounter(taskAttemptInfos, FileSystemCounter.class.getName(), FileSystemCounter.FILE_BYTES_READ.name()) + ""); record.add(getAvgCounter(taskAttemptInfos, FileSystemCounter.class.getName(), FileSystemCounter.FILE_BYTES_WRITTEN.name()) + ""); record.add( getAvgCounter(taskAttemptInfos, TaskCounter.class.getName(), TaskCounter.GC_TIME_MILLIS.name()) + ""); record.add(getAvgCounter(taskAttemptInfos, TaskCounter.class.getName(), TaskCounter.CPU_MILLISECONDS.name()) + ""); csvResult.addRecord(record.toArray(new String[record.size()])); } }
From source file:net.myrrix.online.eval.AUCEvaluator.java
@Override public EvaluationResult evaluate(MyrrixRecommender recommender, RescorerProvider provider, // ignored Multimap<Long, RecommendedItem> testData) throws TasteException { FastByIDMap<FastIDSet> converted = new FastByIDMap<FastIDSet>(testData.size()); for (long userID : testData.keySet()) { Collection<RecommendedItem> userTestData = testData.get(userID); FastIDSet itemIDs = new FastIDSet(userTestData.size()); converted.put(userID, itemIDs);/*from w ww .j a v a 2 s . co m*/ for (RecommendedItem datum : userTestData) { itemIDs.add(datum.getItemID()); } } return evaluate(recommender, converted); }
From source file:uk.ac.ebi.mdk.apps.tool.SuggestExchangeMetabolites.java
@Override public void process() { System.out.print("Reading reconstructions..."); Reconstruction input = read(getFile("input")); Reconstruction reference = read(getFile("reference")); System.out.println("done"); // find compounds which are exchange in the 'reference' and list // - those which are exchanged and present the input // - those which are terminal in the input Multimap<Metabolite, MetabolicReaction> exchanged = exchanged(reference); Multimap<Long, Metabolite> index = index(exchanged.keySet()); BiMap<UUID, Integer> metaboliteIdx = HashBiMap.create(input.metabolome().size()); int i = 0;/*from ww w . j a v a 2 s .co m*/ for (Metabolite m : input.metabolome()) metaboliteIdx.put(m.uuid(), i++); int[] occurences = new int[input.metabolome().size()]; for (MetabolicReaction rxn : input.reactome()) { for (MetabolicParticipant p : rxn.getParticipants()) { occurences[metaboliteIdx.get(p.getMolecule().uuid())]++; } } CSVWriter csv = new CSVWriter(new OutputStreamWriter(System.out), ',', '"'); for (final Metabolite metabolite : input.metabolome()) { for (ChemicalStructure structure : metabolite.getStructures()) { long hashCode = generator.generate(structure.getStructure()); if (index.containsKey(hashCode)) { for (Metabolite refMetabolite : index.get(hashCode)) { for (MetabolicReaction rxn : exchanged.get(refMetabolite)) { csv.writeNext(new String[] { metabolite.toString(), Integer.toString(occurences[metaboliteIdx.get(metabolite.uuid())]), rxn.toString() }); } } } } } try { csv.flush(); csv.close(); } catch (IOException e) { System.err.println(e.getMessage()); } }
From source file:org.jclouds.joyent.sdc.v6_5.compute.SDCComputeService.java
@Override protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) { Multimap<String, String> zoneToZoneAndGroupNames = orphanedGroupsByDatacenterId.apply(deadNodes); for (String datacenterId : zoneToZoneAndGroupNames.keySet()) { cleanupOrphanedKeysInZone(ImmutableSet.copyOf(zoneToZoneAndGroupNames.get(datacenterId)), datacenterId); }//from w ww . j ava 2 s. c o m }
From source file:io.crate.sql.tree.ObjectLiteral.java
public ObjectLiteral(@Nullable Multimap<String, Expression> values) { if (values == null) { this.values = ImmutableMultimap.of(); } else {/*from w ww . j av a 2 s . co m*/ this.values = values; if (values.size() != values.keySet().size()) { throw new IllegalArgumentException("object contains duplicate keys: " + values); } } }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunRDFS10.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long subClassOf = AbstractDictionary.subClassOf; final long type = AbstractDictionary.type; final long clazz = AbstractDictionary.classRdfs; int loops = 0; final Multimap<Long, Long> typeMultimap = ts1.getMultiMapForPredicate(type); if (typeMultimap != null && !typeMultimap.isEmpty()) { for (final Long subject : typeMultimap.keySet()) { if (typeMultimap.get(subject).contains(clazz)) { loops++;//from www. ja v a 2 s . co m final Triple result = new ImmutableTriple(subject, subClassOf, subject); outputTriples.add(result); } } } return loops; }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunRDFS6.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long subPropertyOf = AbstractDictionary.subPropertyOf; final long type = AbstractDictionary.type; final long property = AbstractDictionary.property; int loops = 0; final Multimap<Long, Long> typeMultimap = ts1.getMultiMapForPredicate(type); if (typeMultimap != null && !typeMultimap.isEmpty()) { for (final Long subject : typeMultimap.keySet()) { if (typeMultimap.get(subject).contains(property)) { loops++;//from w w w . jav a2s . com final Triple result = new ImmutableTriple(subject, subPropertyOf, subject); outputTriples.add(result); } } } return loops; }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunRDFS8.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long clazz = AbstractDictionary.classRdfs; final long type = AbstractDictionary.type; final long ressource = AbstractDictionary.ressource; int loops = 0; final Multimap<Long, Long> typeMultimap = ts1.getMultiMapForPredicate(type); if (typeMultimap != null && !typeMultimap.isEmpty()) { for (final Long subject : typeMultimap.keySet()) { if (typeMultimap.get(subject).contains(clazz)) { loops++;// www . j a va 2 s. c o m final Triple result = new ImmutableTriple(subject, type, ressource); outputTriples.add(result); } } } return loops; }