List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
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 ava 2 s. c o m*/ dup++; } } }
From source file:org.apache.flex.compiler.internal.as.codegen.LabelScopeControlFlowContext.java
@Override boolean hasGotoLabel(String label, boolean allowDuplicates) { Multimap<String, LabeledStatementNode> labelMap = getLabelMap(); if (allowDuplicates) return labelMap.containsKey(label); else//from w ww.j av a 2 s.c o m return labelMap.get(label).size() == 1; }
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 ww w . j a v a 2s. 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 .ja v a 2 s . 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++;//from ww w . j a va 2 s . c om final Triple result = new ImmutableTriple(subject, type, ressource); outputTriples.add(result); } } } return loops; }
From source file:org.sonar.server.qualityprofile.ws.QProfileInheritanceAction.java
private Long getOverridingRuleCount(Multimap<String, FacetValue> profileStats) { Long result = null;/* w w w . j a v a2 s . c o m*/ if (profileStats.containsKey("inheritance")) { for (FacetValue value : profileStats.get("inheritance")) { if ("OVERRIDES".equals(value.getKey())) { result = value.getValue(); } } } return result; }
From source file:pt.ua.ieeta.biomedhub.dictionaries.NejiWriter.java
@Override public void write(String file, Multimap syn) { BufferedWriter writer = null; Multimap<String, String> synons = (Multimap) syn; try {// ww w. j ava 2s . c o m writer = new BufferedWriter(new FileWriter(file)); for (String s : synons.keySet()) { String _syns = ""; for (String _syn : synons.get(s)) { _syns += _syn + "|"; } writer.write("UMLS:" + s + ":T023:ANAT\t" + removeLastChar(_syns) + "\n"); System.out.println("UMLS:" + s + ":T023:ANAT\t" + removeLastChar(_syns)); } } catch (IOException e) { } finally { try { if (writer != null) { writer.close(); } } catch (IOException e) { } } }
From source file:co.cask.cdap.common.zookeeper.coordination.BalancedAssignmentStrategy.java
/** * Balance the assignment by spreading it across all handlers evenly. * * @param handlerQueue The priority queue for tracking number of resources assigned to a given handler. * @param assigner The assigner for changing the assignment. * @param maxDiff The maximum differences between the handlers that has the most resources assigned vs the one with * the least resources assigned. *//*w w w .j ava 2 s . c om*/ private <T> void balance(MinMaxPriorityQueue<HandlerSize<T>> handlerQueue, ResourceAssigner<T> assigner, int maxDiff) { HandlerSize<T> minHandler = handlerQueue.peekFirst(); HandlerSize<T> maxHandler = handlerQueue.peekLast(); // Move assignment from the handler that has the most assigned partition replica to the least one, until the // differences is within the desired range. Multimap<T, PartitionReplica> assignments = assigner.get(); while (maxHandler.getSize() - minHandler.getSize() > maxDiff) { PartitionReplica partitionReplica = assignments.get(maxHandler.getHandler()).iterator().next(); // Remove min and max from the queue, and perform the reassignment. handlerQueue.removeFirst(); handlerQueue.removeLast(); assigner.set(minHandler.getHandler(), partitionReplica); // After assignment, the corresponding size should get updated, hence put it back to the queue for next iteration. handlerQueue.add(minHandler); handlerQueue.add(maxHandler); minHandler = handlerQueue.peekFirst(); maxHandler = handlerQueue.peekLast(); } }
From source file:annis.ql.parser.ComponentSearchRelationNormalizer.java
private boolean checkForViolation(List<QueryNode> nodes, AtomicLong maxID) { Multimap<QueryNode, Join> joins = createJoinMap(nodes); LinkedList<QueryNode> nodeCopy = new LinkedList<>(nodes); for (QueryNode n : nodeCopy) { if (joins.get(n).size() > 1) { Iterator<Join> itJoinsForNode = joins.get(n).iterator(); Join joinToSplit = itJoinsForNode.next(); if (joinToSplit.getTarget().getId() == n.getId()) { replicateFromJoinTarget(joinToSplit, n, nodes, maxID); } else { replicateFromJoinSource(joinToSplit, n, nodes, maxID); }// ww w.j a v a 2s .c o m return true; } } return false; }
From source file:fr.ujm.tse.lt2c.satin.rules.run.RunRDFS13.java
@Override protected int process(final TripleStore ts1, final TripleStore ts2, final Collection<Triple> outputTriples) { final long datatype = AbstractDictionary.datatype; final long type = AbstractDictionary.type; final long subClassOf = AbstractDictionary.subClassOf; final long literal = AbstractDictionary.literal; 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(datatype)) { loops++;//from w ww . j a v a 2 s .co m final Triple result = new ImmutableTriple(subject, subClassOf, literal); outputTriples.add(result); } } } return loops; }