List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:edu.pitt.dbmi.ccd.db.specification.AnnotationSpecification.java
private static List<Predicate> containsTerms(Root<Annotation> root, CriteriaQuery query, CriteriaBuilder cb, Set<String> terms) { return terms.stream().map(t -> containsLike(t)).map(t -> existsInData(root, query, cb, t)) .collect(Collectors.toList()); }
From source file:edu.pitt.dbmi.ccd.db.specification.AnnotationSpecification.java
private static List<Predicate> doesNotContainTerms(Root<Annotation> root, CriteriaQuery query, CriteriaBuilder cb, Set<String> terms) { return terms.stream().map(t -> containsLike(t)).map(t -> doesNotExistInData(root, query, cb, t)) .collect(Collectors.toList()); }
From source file:ai.grakn.graql.internal.gremlin.GraqlTraversal.java
private static Stream<Fragment> fragments(Set<EquivalentFragmentSet> fragmentSets) { return fragmentSets.stream().flatMap(EquivalentFragmentSet::getFragments); }
From source file:edu.wpi.checksims.util.threading.ParallelAlgorithm.java
public static Set<Submission> parallelSubmissionPreprocessing(SubmissionPreprocessor preprocessor, Set<Submission> submissions) { checkNotNull(preprocessor);/*from w ww .j av a 2 s .co m*/ checkNotNull(submissions); // Map the submissions to PreprocessorWorker instances Collection<PreprocessorWorker> workers = submissions.stream() .map((submission) -> new PreprocessorWorker(submission, preprocessor)).collect(Collectors.toList()); return ImmutableSet.copyOf(executeTasks(workers)); }
From source file:edu.wpi.checksims.util.threading.ParallelAlgorithm.java
/** * Detect similarities in parallel.//from ww w .j a v a 2s.c o m * * @param algorithm Algorithm to use for similarity detection * @param pairs Pairs of submissions to perform detection on * @return Collection of results, one for each pair */ public static Set<AlgorithmResults> parallelSimilarityDetection(SimilarityDetector algorithm, Set<Pair<Submission, Submission>> pairs) { checkNotNull(algorithm); checkNotNull(pairs); // Map the pairs to ChecksimsWorker instances Collection<SimilarityDetectionWorker> workers = pairs.stream() .map((pair) -> new SimilarityDetectionWorker(algorithm, pair)).collect(Collectors.toList()); return ImmutableSet.copyOf(executeTasks(workers)); }
From source file:net.lldp.checksims.util.threading.ParallelAlgorithm.java
public static Set<Submission> parallelSubmissionPreprocessing(SubmissionPreprocessor preprocessor, Set<Submission> submissions, StatusLogger logger) throws ChecksimsException { checkNotNull(preprocessor);/*from w w w. j ava 2s. c o m*/ checkNotNull(submissions); // Map the submissions to PreprocessorWorker instances Collection<PreprocessorWorker> workers = submissions.stream() .map((submission) -> new PreprocessorWorker(submission, preprocessor)).collect(Collectors.toList()); return ImmutableSet.copyOf(executeTasks(workers, logger)); }
From source file:com.netflix.genie.web.controllers.DtoConverters.java
private static Set<String> toV4Tags(final Set<String> tags) { return tags.stream().filter(tag -> !tag.startsWith(GENIE_ID_PREFIX) && !tag.startsWith(GENIE_NAME_PREFIX)) .collect(Collectors.toSet()); }
From source file:net.lldp.checksims.util.threading.ParallelAlgorithm.java
/** * Detect similarities in parallel.//from w ww .j a va2 s . c o m * * @param algorithm Algorithm to use for similarity detection * @param pairs Pairs of submissions to perform detection on * @return Collection of results, one for each pair */ public static <T extends Percentable> Set<AlgorithmResults> parallelSimilarityDetection( SimilarityDetector<T> algorithm, Set<Pair<Submission, Submission>> pairs, StatusLogger logger) throws ChecksimsException { checkNotNull(algorithm); checkNotNull(pairs); // Map the pairs to ChecksimsWorker instances Collection<SimilarityDetectionWorker<T>> workers = pairs.stream() .map((pair) -> new SimilarityDetectionWorker<T>(algorithm, pair)).collect(Collectors.toList()); //TODO do something with the right side? return ImmutableSet.copyOf(executeTasks(workers, logger)); }
From source file:nu.yona.server.analysis.service.AnalysisEngineService.java
static Set<GoalDto> determineRelevantGoals(ActivityPayload payload) { boolean onlyNoGoGoals = payload.isNetworkActivity() && payload.deviceAnonymized.getOperatingSystem() == OperatingSystem.ANDROID; Set<UUID> matchingActivityCategoryIds = payload.activityCategories.stream().map(ActivityCategoryDto::getId) .collect(Collectors.toSet()); Set<GoalDto> goalsOfUser = payload.userAnonymized.getGoals(); return goalsOfUser.stream().filter(g -> !g.isHistoryItem()) .filter(g -> matchingActivityCategoryIds.contains(g.getActivityCategoryId())) .filter(g -> g.isNoGoGoal() || !onlyNoGoGoals) .filter(g -> g.getCreationTime().get().isBefore( TimeUtil.toUtcLocalDateTime(payload.startTime.plus(DEVICE_TIME_INACCURACY_MARGIN)))) .collect(Collectors.toSet()); }
From source file:com.vmware.admiral.compute.container.volume.VolumeUtil.java
/** * Creates additional affinity rules between container descriptions which share * local volumes. Each container group should be deployed on a single host. *///from w w w .j a v a 2 s .c o m public static void applyLocalNamedVolumeConstraints(Collection<ComponentDescription> componentDescriptions) { Map<String, ContainerVolumeDescription> volumes = filterDescriptions(ContainerVolumeDescription.class, componentDescriptions); List<String> localVolumes = volumes.values().stream().filter(v -> DEFAULT_VOLUME_DRIVER.equals(v.driver)) .map(v -> v.name).collect(Collectors.toList()); if (localVolumes.isEmpty()) { return; } Map<String, ContainerDescription> containers = filterDescriptions(ContainerDescription.class, componentDescriptions); // sort containers by local volume: each set is a group of container names // that share a particular local volume List<Set<String>> localVolumeContainers = localVolumes.stream() .map(v -> filterByVolume(v, containers.values())).filter(s -> !s.isEmpty()) .collect(Collectors.toList()); if (localVolumeContainers.isEmpty()) { return; } /** Merge sets of containers sharing local volumes * * C1 C2 C3 C4 C5 C6 * \ /\ / | \ / * L1 L2 L3 L4 * * Input: [C1, C2], [C2, C3], [C4], [C5, C6] * Output: [C1, C2, C3], [C4], [C5, C6] */ localVolumeContainers = mergeSets(localVolumeContainers); Map<String, List<ContainerVolumeDescription>> containerToVolumes = containers.values().stream() .collect(Collectors.toMap(cd -> cd.name, cd -> filterVolumes(cd, volumes.values()))); Map<String, Integer> containerToDriverCount = containerToVolumes.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().stream().map(vd -> vd.driver).collect(Collectors.toSet()).size())); for (Set<String> s : localVolumeContainers) { if (s.size() > 1) { // find the container with highest number of required drivers int max = s.stream().map(cn -> containerToDriverCount.get(cn)) .max((vc1, vc2) -> Integer.compare(vc1, vc2)).get(); Set<String> maxDrivers = s.stream().filter(cn -> containerToDriverCount.get(cn) == max) .collect(Collectors.toSet()); String maxCont = maxDrivers.iterator().next(); s.remove(maxCont); s.stream().forEach(cn -> addAffinity(maxCont, containers.get(cn))); } } }