List of usage examples for com.google.common.collect Multimap isEmpty
boolean isEmpty();
From source file:pt.org.aguiaj.core.AguiaJActivator.java
public void loadClasses(IPath workingDir) { assert workingDir.toFile().exists() && workingDir.toFile().isDirectory(); this.workingDir = workingDir; List<IPath> workingDirs = new ArrayList<IPath>(); workingDirs.add(workingDir);/* ww w .jav a 2 s . co m*/ IPath dir = workingDir; if (dir.lastSegment().equals("bin")) dir = dir.removeLastSegments(1); addDependencyPaths(workingDirs, dir); AguiaClassLoader.newClassLoader(); packagesClasses = readClasses(workingDirs); // try bin directory, if exists if (packagesClasses.isEmpty()) { IPath binDirPath = workingDir.append("bin"); File binDir = binDirPath.toFile(); if (binDir.exists() && binDir.isDirectory()) { workingDirs.add(binDirPath); Multimap<String, Class<?>> tmp = readClasses(workingDirs); if (!tmp.isEmpty()) { packagesClasses = tmp; this.workingDir = binDirPath; } } } // try a bin directory on parent folder, if exists if (packagesClasses.isEmpty()) { IPath binTry = workingDir.removeLastSegments(1).append("bin"); File binTryDir = binTry.toFile(); if (binTryDir.exists() && binTryDir.isDirectory()) { workingDirs.add(binTry); Multimap<String, Class<?>> tmp = readClasses(workingDirs); if (!tmp.isEmpty()) { packagesClasses = tmp; this.workingDir = binTry; } } } // filter non-visible classes for (Iterator<Class<?>> it = packagesClasses.values().iterator(); it.hasNext();) { Class<?> c = it.next(); if (!ClassModel.getInspector().isClassVisible(c)) it.remove(); } }
From source file:com.dataartisans.flink.dataflow.translation.wrappers.streaming.FlinkGroupAlsoByWindowWrapper.java
@Override public void processWatermark(Watermark mark) throws Exception { context.setCurrentInputWatermark(new Instant(mark.getTimestamp())); Multimap<K, TimerInternals.TimerData> timers = getTimersReadyToProcess(mark.getTimestamp()); if (!timers.isEmpty()) { for (K key : timers.keySet()) { processKeyedWorkItem(KeyedWorkItems.<K, VIN>timersWorkItem(key, timers.get(key))); }//from www . ja va 2s .c om } /** * This is to take into account the different semantics of the Watermark in Flink and * in Dataflow. To understand the reasoning behind the Dataflow semantics and its * watermark holding logic, see the documentation of * {@link WatermarkHold#addHold(ReduceFn.ProcessValueContext, boolean)} * */ long millis = Long.MAX_VALUE; for (FlinkStateInternals state : perKeyStateInternals.values()) { Instant watermarkHold = state.getWatermarkHold(); if (watermarkHold != null && watermarkHold.getMillis() < millis) { millis = watermarkHold.getMillis(); } } if (mark.getTimestamp() < millis) { millis = mark.getTimestamp(); } context.setCurrentOutputWatermark(new Instant(millis)); // Don't forget to re-emit the watermark for further operators down the line. // This is critical for jobs with multiple aggregation steps. // Imagine a job with a groupByKey() on key K1, followed by a map() that changes // the key K1 to K2, and another groupByKey() on K2. In this case, if the watermark // is not re-emitted, the second aggregation would never be triggered, and no result // will be produced. output.emitWatermark(new Watermark(millis)); }
From source file:org.glowroot.local.ui.ClasspathCache.java
synchronized void updateCache() { Multimap<String, File> newClassNameLocations = HashMultimap.create(); for (ClassLoader loader : getKnownClassLoaders()) { updateCache(loader, newClassNameLocations); }// w w w .j ava 2 s . co m updateCacheWithBootstrapClasses(newClassNameLocations); if (!newClassNameLocations.isEmpty()) { Multimap<String, File> newMap = TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural()); newMap.putAll(classNameLocations); newMap.putAll(newClassNameLocations); classNameLocations = ImmutableMultimap.copyOf(newMap); } }
From source file:hku.fyp14017.blencode.stage.StageListener.java
public void precomputeActionsForBroadcastEvents(Map<String, List<String>> currentActions) { Multimap<String, String> actionsToRestartMap = BroadcastHandler.getActionsToRestartMap(); if (!actionsToRestartMap.isEmpty()) { return;/*from w ww . java 2 s.co m*/ } List<String> actions = new ArrayList<String>(); if (currentActions.get(Constants.START_SCRIPT) != null) { actions.addAll(currentActions.get(Constants.START_SCRIPT)); } if (currentActions.get(Constants.BROADCAST_SCRIPT) != null) { actions.addAll(currentActions.get(Constants.BROADCAST_SCRIPT)); } if (currentActions.get(Constants.BROADCAST_NOTIFY_ACTION) != null) { actions.addAll(currentActions.get(Constants.BROADCAST_NOTIFY_ACTION)); } for (String action : actions) { for (String actionOfLook : actions) { if (action.equals(actionOfLook) || isFirstSequenceActionAndEqualsSecond(action, actionOfLook) || isFirstSequenceActionAndEqualsSecond(actionOfLook, action)) { if (!actionsToRestartMap.containsKey(action)) { actionsToRestartMap.put(action, actionOfLook); } else { actionsToRestartMap.get(action).add(actionOfLook); } } } } }
From source file:com.github.rinde.rinsim.core.model.DependencyResolver.java
ImmutableSet<Model<?>> resolve() { addDefaultModels();/* w ww. ja va 2 s . c om*/ final Multimap<Dependency, Dependency> dependencyGraph = constructDependencyGraph(); if (LOGGER.isTraceEnabled()) { for (final Dependency dep : dependencyGraph.keySet()) { final StringBuilder sb = new StringBuilder(); for (final Dependency d : dependencyGraph.get(dep)) { sb.append(d.modelBuilder).append(" "); } LOGGER.trace("{} requires: {}.", dep.modelBuilder.toString(), sb); } } while (!dependencyGraph.isEmpty()) { final List<Dependency> toRemove = new ArrayList<>(); for (final Dependency dep : dependencyGraph.keys()) { final Collection<Dependency> dependencies = dependencyGraph.get(dep); boolean allResolved = true; for (final Dependency dependency : dependencies) { allResolved &= dependency.isResolved(); } if (allResolved) { dep.build(); toRemove.add(dep); } } for (final Dependency mb : toRemove) { dependencyGraph.removeAll(mb); } if (toRemove.isEmpty()) { throw new IllegalArgumentException("Could not resolve dependencies for " + dependencyGraph.keySet() + ", most likely a circular dependency was declared."); } } final ImmutableSet.Builder<Model<?>> builder = ImmutableSet.builder(); for (final Dependency cmb : builders) { builder.add(cmb.build()); } return builder.build(); }
From source file:com.github.rinde.rinsim.ui.SimulationViewer.java
void panelsLayout(Multimap<Integer, PanelRenderer> panels) { if (panels.isEmpty()) { createContent(this); } else {//w w w .j a v a2 s. co m final SashForm vertical = new SashForm(this, SWT.VERTICAL | SWT.SMOOTH); vertical.setLayout(new FillLayout()); final int topHeight = configurePanels(vertical, panels.removeAll(SWT.TOP)); final SashForm horizontal = new SashForm(vertical, SWT.HORIZONTAL | SWT.SMOOTH); horizontal.setLayout(new FillLayout()); final int leftWidth = configurePanels(horizontal, panels.removeAll(SWT.LEFT)); // create canvas createContent(horizontal); final int rightWidth = configurePanels(horizontal, panels.removeAll(SWT.RIGHT)); final int bottomHeight = configurePanels(vertical, panels.removeAll(SWT.BOTTOM)); final int canvasHeight = size.y - topHeight - bottomHeight; if (topHeight > 0 && bottomHeight > 0) { vertical.setWeights(varargs(topHeight, canvasHeight, bottomHeight)); } else if (topHeight > 0) { vertical.setWeights(varargs(topHeight, canvasHeight)); } else if (bottomHeight > 0) { vertical.setWeights(varargs(canvasHeight, bottomHeight)); } final int canvasWidth = size.x - leftWidth - rightWidth; if (leftWidth > 0 && rightWidth > 0) { horizontal.setWeights(varargs(leftWidth, canvasWidth, rightWidth)); } else if (leftWidth > 0) { horizontal.setWeights(varargs(leftWidth, canvasWidth)); } else if (rightWidth > 0) { horizontal.setWeights(varargs(canvasWidth, rightWidth)); } checkState(panels.isEmpty(), "Invalid preferred position set for panels: %s", panels.values()); } }
From source file:com.addthis.hydra.query.MeshQueryMaster.java
/** * @param requestedTasks only query these task ids. empty means query all tasks. *///from ww w .j av a2s .c om private QueryTaskSource[] getSourcesById(String jobId, String subdirectory, boolean allowPartial, Set<Integer> requestedTasks) { if (spawnDataStoreHandler != null) { spawnDataStoreHandler.validateJobForQuery(jobId); } String combinedJob; if (!subdirectory.isEmpty()) { combinedJob = jobId + '/' + subdirectory; } else { combinedJob = jobId; } Multimap<Integer, FileReference> fileReferenceMap; try { fileReferenceMap = cachey.get(combinedJob); } catch (ExecutionException e) { log.warn("", e); throw new QueryException("Exception getting file references: " + e.getMessage()); } if ((fileReferenceMap == null) || fileReferenceMap.isEmpty()) { cachey.invalidate(combinedJob); throw new QueryException("[MeshQueryMaster] No file references found for job: " + combinedJob); } int canonicalTaskCount; try { canonicalTaskCount = validateRequestedTasks(jobId, fileReferenceMap.keySet(), requestedTasks, allowPartial); } catch (Exception ex) { cachey.invalidate(combinedJob); throw ex; } QueryTaskSource[] sourcesByTaskID = new QueryTaskSource[canonicalTaskCount]; for (int taskId = 0; taskId < canonicalTaskCount; taskId++) { Collection<FileReference> sourceOptions = fileReferenceMap.get(taskId); if (!sourceOptions.isEmpty() && (requestedTasks.isEmpty() || requestedTasks.contains(taskId))) { QueryTaskSourceOption[] taskSourceOptions = new QueryTaskSourceOption[sourceOptions.size()]; int taskSourceOptionsIndex = 0; for (FileReference queryReference : sourceOptions) { WorkerData workerData = worky.get(queryReference.getHostUUID()); taskSourceOptions[taskSourceOptionsIndex] = new QueryTaskSourceOption(queryReference, workerData.queryLeases); taskSourceOptionsIndex += 1; } sourcesByTaskID[taskId] = new QueryTaskSource(taskSourceOptions); } else { sourcesByTaskID[taskId] = EMPTY_TASK_SOURCE; } } return sourcesByTaskID; }
From source file:com.torodb.torod.db.postgresql.query.QueryEvaluator.java
@Nonnull private Map<Integer, DatabaseQuery> createDatabaseQueryByStructure(@Nullable QueryCriteria criteria, DSLContext dsl) {/*from w ww . j a v a 2 s . c o m*/ Map<Integer, DatabaseQuery> result; if (criteria == null) { BiMap<Integer, DocStructure> allStructures = colSchema.getStructuresCache().getAllStructures(); result = Maps.newHashMapWithExpectedSize(allStructures.size()); for (Integer sid : colSchema.getStructuresCache().getAllStructures().keySet()) { result.put(sid, SelectAllDatabaseQuery.getInstance()); } } else { Multimap<Integer, QueryCriteria> candidateStructures = QueryStructureFilter.filterStructures(colSchema, criteria); if (candidateStructures.isEmpty()) { result = Collections.emptyMap(); } else { result = Maps.newHashMapWithExpectedSize(candidateStructures.size()); for (Map.Entry<Integer, QueryCriteria> entry : candidateStructures.entries()) { Integer sid = entry.getKey(); DocStructure rootStructure = colSchema.getStructuresCache().getStructure(sid); DatabaseQuery databaseQuery = createDatabaseQuery(entry.getValue(), sid, rootStructure, dsl); if (!(databaseQuery instanceof FalseDatabaseQuery)) { result.put(sid, databaseQuery); } } } } return result; }
From source file:com.b2international.snowowl.snomed.core.ecl.SnomedEclRefinementEvaluator.java
/** * Handles attribute refinements inside attribute group refinements. *///from w w w.j a v a2 s . c o m protected Promise<Collection<Property>> evalGroup(final BranchContext context, final Range<Long> groupCardinality, final AttributeConstraint refinement) { if (refinement.isReversed()) { throw new BadRequestException("Reversed attributes are not supported in group refinements"); } else { return evalRefinement(context, refinement, true, groupCardinality).thenWith(input -> { final Cardinality cardinality = refinement.getCardinality(); // two cases here, one is the [1..x] the other is [0..x] if (cardinality != null && cardinality.getMin() == 0 && cardinality.getMax() != UNBOUNDED_CARDINALITY) { // XXX internal evaluation returns negative matches, that should be excluded from the focusConcept set final Function<Property, Object> idProvider = refinement.isReversed() ? Property::getValue : Property::getObjectId; final Set<String> matchingIds = FluentIterable.from(input).transform(idProvider) .filter(String.class).toSet(); return focusConcepts.resolveToConceptsWithGroups(context) .then(new Function<Multimap<String, Integer>, Collection<Property>>() { @Override public Collection<Property> apply(Multimap<String, Integer> groupsById) { if (groupsById.isEmpty()) { return Sets.newHashSet(); } else { final Collection<Property> matchingProperties = newHashSetWithExpectedSize( groupsById.size() - matchingIds.size()); for (Entry<String, Integer> entry : groupsById.entries()) { final String id = entry.getKey(); if (!matchingIds.contains(id)) { matchingProperties.add(new Property(id, entry.getValue())); } } return matchingProperties; } } }); } else { return Promise.immediate(input); } }).failWith(throwable -> { if (throwable instanceof MatchAll) { return focusConcepts.resolveToConceptsWithGroups(context) .then(new Function<Multimap<String, Integer>, Collection<Property>>() { @Override public Collection<Property> apply(Multimap<String, Integer> groupsById) { final Collection<Property> matchingProperties = newHashSetWithExpectedSize( groupsById.size()); for (Entry<String, Integer> entry : groupsById.entries()) { matchingProperties.add(new Property(entry.getKey(), entry.getValue())); } return matchingProperties; } }); } throw new SnowowlRuntimeException(throwable); }); } }
From source file:org.jclouds.cleanup.doclet.ClassDocParser.java
private Collection<String> extractComment(String defaultCommentText, Multimap<String, String> defaultTags, ProgramElementDoc... elements) { String commentText = null;//from w ww . j a v a 2 s . c o m for (ProgramElementDoc element : elements) { if (element != null && element.commentText() != null && !element.commentText().trim().isEmpty()) { commentText = element.commentText(); break; } } if (commentText == null) { commentText = defaultCommentText; } Multimap<String, String> tagsToOutput = LinkedListMultimap.create(); if (defaultTags != null) tagsToOutput.putAll(defaultTags); for (ProgramElementDoc element : elements) { if (element != null) { for (Tag tag : element.tags()) { tagsToOutput.put(tag.name(), tag.text()); } } } if (commentText == null && tagsToOutput.isEmpty()) return ImmutableList.of(); List<String> result = Lists.newArrayList(); if (commentText != null) { for (String line : commentText.split("\n")) { result.add(line.trim()); } if (!tagsToOutput.isEmpty()) { result.add(""); } } for (Map.Entry<String, String> tag : tagsToOutput.entries()) { result.add(tag.getKey() + " " + tag.getValue()); } return result; }