List of usage examples for com.google.common.collect Multimap keySet
Set<K> keySet();
From source file:com.rackspacecloud.blueflood.io.datastax.DPreaggregatedMetricsRW.java
private void insertMetricsIndividually(Multimap<Locator, IMetric> map, Granularity granularity) throws IOException { Map<ResultSetFuture, Locator> futureLocatorMap = new HashMap<ResultSetFuture, Locator>(); for (Locator locator : map.keySet()) { for (IMetric metric : map.get(locator)) { RollupType rollupType = metric.getRollupType(); // lookup the right io object DAbstractMetricIO io = rollupTypeToIO.get(rollupType); if (io == null) { throw new InvalidDataException(String.format( "insertMetrics(locator=%s, granularity=%s): unsupported preaggregated rollupType=%s", locator, granularity, rollupType.name())); }// ww w.jav a 2 s .com if (!(metric.getMetricValue() instanceof Rollup)) { throw new InvalidDataException(String.format( "insertMetrics(locator=%s, granularity=%s): metric value %s is not type Rollup", locator, granularity, metric.getMetricValue().getClass().getSimpleName())); } ResultSetFuture future = io.putAsync(locator, metric.getCollectionTime(), (Rollup) metric.getMetricValue(), granularity, metric.getTtlInSeconds()); futureLocatorMap.put(future, locator); if (granularity == Granularity.FULL) { Instrumentation.markFullResPreaggregatedMetricWritten(); } if (!LocatorCache.getInstance().isLocatorCurrentInBatchLayer(locator)) { locatorIO.insertLocator(locator); LocatorCache.getInstance().setLocatorCurrentInBatchLayer(locator); } else { LOG.trace("insertMetrics(): not inserting locator " + locator); } if (isRecordingDelayedMetrics) { insertLocatorIfDelayed(metric); } } } for (ResultSetFuture future : futureLocatorMap.keySet()) { try { future.getUninterruptibly().all(); } catch (Exception ex) { Instrumentation.markWriteError(); LOG.error(String.format("error writing preaggregated metric for locator %s, granularity %s", futureLocatorMap.get(future), granularity), ex); } } }
From source file:org.jnario.compiler.JnarioBatchCompiler.java
protected ResourceSet loadXtendFiles(final ResourceSet resourceSet) { encodingProvider.setDefaultEncoding(getFileEncoding()); final NameBasedFilter nameBasedFilter = new NameBasedFilter(); nameBasedFilter.setExtension(fileExtensionProvider.getPrimaryFileExtension()); PathTraverser pathTraverser = new PathTraverser(); List<String> sourcePathDirectories = getSourcePathDirectories(); Multimap<String, URI> pathes = pathTraverser.resolvePathes(sourcePathDirectories, new Predicate<URI>() { public boolean apply(URI input) { boolean matches = nameBasedFilter.matches(input); return matches; }//from w ww.j av a 2s . c o m }); for (String src : pathes.keySet()) { URI baseDir = URI.createFileURI(src + "/"); String identifier = Joiner.on("_").join(baseDir.segments()); for (URI uri : pathes.get(src)) { if (log.isDebugEnabled()) { log.debug("load jnario file '" + uri + "'"); } resourceSet.getResource(uri, true); } } return resourceSet; }
From source file:org.dragoneronca.nlp.wol.disambiguation.WolPathFinder.java
@Override protected void filterEdges(Set<? extends Edge> edges) { Set<LightSemanticEdge> semanticEdges = (Set<LightSemanticEdge>) edges; Multimap<Integer, LightSemanticEdge> edgesByTermMap = LinkedHashMultimap.create(); for (LightSemanticEdge semanticEdge : semanticEdges) { if (!excludedTermHashes.contains(semanticEdge.getTargetWordHash())) { edgesByTermMap.put(semanticEdge.getTargetWordHash(), semanticEdge); }/*w w w. ja va 2s . c o m*/ } Set<LightSemanticEdge> goodSemanticEdges = new HashSet<>(); for (Integer key : edgesByTermMap.keySet()) { Collection<LightSemanticEdge> lightSemanticEdges = edgesByTermMap.get(key); LightSemanticEdge maxEdge = Collections.max(lightSemanticEdges, new Comparator<LightSemanticEdge>() { @Override public int compare(LightSemanticEdge edge1, LightSemanticEdge edge2) { return Double.compare(edge1.getWeight(), edge2.getWeight()); } }); goodSemanticEdges.add(maxEdge); } edges.retainAll(goodSemanticEdges); }
From source file:org.apache.calcite.rel.rules.AbstractMaterializedViewRule.java
/** Currently we only support TableScan - Project - Filter - Join */ private static boolean isValidRexNodePlan(RelNode node, RelMetadataQuery mq) { final Multimap<Class<? extends RelNode>, RelNode> m = mq.getNodeTypes(node); for (Class<? extends RelNode> c : m.keySet()) { if (!TableScan.class.isAssignableFrom(c) && !Project.class.isAssignableFrom(c) && !Filter.class.isAssignableFrom(c) && !Join.class.isAssignableFrom(c)) { // Skip it return false; }// ww w.ja v a 2s . c o m } return true; }
From source file:org.mule.util.xa.XaTransactionRecoverer.java
public synchronized Xid[] recover(int flag) throws XAException { //No need to do anything for XAResource.TMENDRSCAN if (flag == XAResource.TMENDRSCAN) { return new Xid[0]; }/* w ww. j a va 2 s. c o m*/ //For XAResource.TMSTARTRSCAN and XAResource.TMNOFLAGS (only possible values despite XAResource.TMENDRSCAN we returns //the set of Xid to recover (no commit, no rollback) and bitronix will commit, rollback for Xid that are //dangling transactions and will do nothing for those that are currently being executed. Multimap<Xid, XaQueueTxJournalEntry> xidXaJournalEntryMultimap = xaTxQueueTransactionJournal .getAllLogEntries(); if (logger.isDebugEnabled()) { logger.debug("Executing XA recover"); logger.debug("Found " + xidXaJournalEntryMultimap.size() + " in the tx log"); } List<Xid> txsToRecover = new ArrayList<Xid>(); for (Xid xid : xidXaJournalEntryMultimap.keySet()) { Collection<XaQueueTxJournalEntry> entries = xidXaJournalEntryMultimap.get(xid); Object commitOrRollback = CollectionUtils.find(entries, new Predicate() { @Override public boolean evaluate(Object object) { XaQueueTxJournalEntry logEntry = (XaQueueTxJournalEntry) object; return logEntry.isCommit() || logEntry.isRollback(); } }); if (commitOrRollback != null) { continue; } txsToRecover.add(xid); } if (logger.isDebugEnabled()) { logger.debug("found " + txsToRecover.size() + " txs to recover"); } return txsToRecover.toArray(new Xid[txsToRecover.size()]); }
From source file:com.palantir.atlasdb.sweep.SweepTaskRunner.java
private void sweepCells(String tableName, Multimap<Cell, Long> cellTsPairsToSweep, Set<Cell> sentinelsToAdd) { if (cellTsPairsToSweep.isEmpty()) { return;/*from w ww. ja va 2s . co m*/ } for (Follower follower : followers) { follower.run(txManager, tableName, cellTsPairsToSweep.keySet(), TransactionType.HARD_DELETE); } if (!sentinelsToAdd.isEmpty()) { keyValueService.addGarbageCollectionSentinelValues(tableName, sentinelsToAdd); } keyValueService.delete(tableName, cellTsPairsToSweep); }
From source file:org.eclipse.osee.orcs.db.internal.change.MissingChangeItemFactoryImpl.java
private Set<RelationChangeItem> createExistingRelations(HasCancellation cancellation, OrcsSession session, TransactionReadable destTx, final Multimap<Integer, RelationData> relationChangesToAdd) throws OseeCoreException { final Set<RelationChangeItem> toReturn = new LinkedHashSet<RelationChangeItem>(); DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, getBranch(destTx), relationChangesToAdd.keySet()); loader.fromTransaction(destTx.getGuid()); loader.load(cancellation, new LoadDataHandlerAdapter() { @Override//from w ww . j a va2s.c o m public void onData(ArtifactData data) throws OseeCoreException { for (RelationData relData : relationChangesToAdd.get(data.getLocalId())) { toReturn.add(createRelationChangeItem(relData)); } } }); return toReturn; }
From source file:org.terasology.entitySystem.pojo.PojoEventSystem.java
private Set<EventHandlerInfo> selectEventHandlers(Class<? extends Event> eventType, EntityRef entity) { Set<EventHandlerInfo> result = Sets.newHashSet(); Multimap<Class<? extends Component>, EventHandlerInfo> handlers = componentSpecificHandlers.get(eventType); if (handlers == null) return result; for (Class<? extends Component> compClass : handlers.keySet()) { if (entity.hasComponent(compClass)) { for (EventHandlerInfo eventHandler : handlers.get(compClass)) { if (eventHandler.isValidFor(entity)) { result.add(eventHandler); }/*from w ww.j av a 2 s .c o m*/ } } } return result; }
From source file:org.summer.ss.core.dispatch.DispatchingSupport.java
public Multimap<JvmOperation, JvmOperation> getDispatcher2dispatched(XtendClass clazz, boolean isLocalOnly) { final JvmGenericType type = associations.getInferredType(clazz); Multimap<Pair<String, Integer>, JvmOperation> dispatchMethods = LinkedHashMultimap.create(); collectDispatchMethods(type, dispatchMethods); Multimap<JvmOperation, JvmOperation> dispatcher2dispatched = LinkedHashMultimap.create(); for (final Pair<String, Integer> signature : dispatchMethods.keySet()) { JvmOperation localDispatcher = findSyntheticDispatchMethod(clazz, signature); if (localDispatcher != null) { Iterable<JvmOperation> dispatched = dispatchMethods.get(signature); if (isLocalOnly) dispatched = filter(dispatched, new Predicate<JvmOperation>() { public boolean apply(JvmOperation input) { return input.getDeclaringType() == type; }/*from w w w. j ava 2s . com*/ }); dispatcher2dispatched.putAll(localDispatcher, dispatched); } else if (!isLocalOnly) { Iterator<JvmOperation> iterator = filter(filter(type.getAllFeatures(), JvmOperation.class), new Predicate<JvmOperation>() { public boolean apply(JvmOperation input) { return visibilityService.isVisible(input, type) && input.getParameters().size() == signature.getSecond() && input.getSimpleName().equals(signature.getFirst()); } }).iterator(); if (iterator.hasNext()) { dispatcher2dispatched.putAll(iterator.next(), dispatchMethods.get(signature)); } } } return dispatcher2dispatched; }
From source file:ch.uzh.ifi.attempto.acewiki.gui.GrammarPage.java
protected void doUpdate() { setTabRow(TabRow.getMainTabRow(TabRow.TAB_GRAMMAR, mWiki)); title.setText(LocaleResources.getString("acewiki_page_grammar")); if (mInfo == null) { return;//from w ww . j a v a 2 s .c o m } table1.clear(); table2.clear(); table3.clear(); table4.clear(); mTableTokens.clear(); Map<String, Set<String>> langs = mInfo.getLanguages(); table1.addEntry("Name", GuiUtils.getNameComponent(mWiki, mInfo.getName())); table1.addEntry("Startcat", mInfo.getStartcat()); table1.addEntry("Categories", mInfo.getCategories().size() + ""); table1.addEntry("Functions", mInfo.getFunctions().size() + ""); table1.addEntry("Languages", langs.keySet().size() + ""); for (String lang : asSortedList(langs.keySet())) { table2.addEntry(GuiUtils.getNameComponent(mWiki, lang), JOINER_SPACE.join(langs.get(lang))); } for (String cat : asSortedList(mInfo.getCategories())) { table3.addEntry(cat, JOINER_COMMA.join(mGrammar.getProducers(cat))); table4.addEntry(cat, JOINER_COMMA.join(mGrammar.getConsumers(cat))); } // Make a token -> categories table Multimap<String, String> tokenToCats = null; tokenToCats = mGrammar.getTokenToCats(mWiki.getLanguage()); if (tokenToCats != null) { mTableTokensLabel.setText("There are " + tokenToCats.keySet().size() + " tokens.\n" + "Note that this list includes only tokens that are generated by " + "functions that produce categories but do not consume them."); for (String tok : asSortedList(tokenToCats.keySet())) { mTableTokens.addEntry(tok, JOINER_COMMA.join(tokenToCats.get(tok))); } } }