List of usage examples for java.util Set parallelStream
default Stream<E> parallelStream()
From source file:ai.grakn.test.engine.tasks.storage.TaskStateInMemoryStoreTest.java
@Test public void testGetTasksByCreator() { TaskId id = stateStorage.newState(task()); Set<TaskState> res = stateStorage.getTasks(null, null, this.getClass().getName(), null, 0, 0); assertTrue(res.parallelStream().map(TaskState::getId).filter(x -> x.equals(id)).collect(Collectors.toList()) .size() == 1);/*from ww w . j av a 2s . co m*/ }
From source file:ai.grakn.test.engine.tasks.storage.TaskStateInMemoryStoreTest.java
@Test public void testGetTasksByClassName() { TaskId id = stateStorage.newState(task()); Set<TaskState> res = stateStorage.getTasks(null, ShortExecutionMockTask.class.getName(), null, null, 0, 0); assertTrue(res.parallelStream().map(TaskState::getId).filter(x -> x.equals(id)).collect(Collectors.toList()) .size() == 1);//from w w w.j a v a 2s .com }
From source file:ai.grakn.test.engine.tasks.storage.TaskStateGraphStoreTest.java
@Test public void testGetTaskStateByStatus() { TaskId id = stateStorage.newState(task().markScheduled()); assertNotNull(id);/* w w w.j av a 2s. c o m*/ Set<TaskState> res = stateStorage.getTasks(CREATED, null, null, null, 0, 0); assertTrue(res.parallelStream().map(TaskState::getId).filter(x -> x.equals(id)).collect(Collectors.toList()) .size() == 1); }
From source file:ai.grakn.test.engine.tasks.storage.TaskStateGraphStoreTest.java
@Test public void testGetTaskStateByCreator() { TaskId id = stateStorage.newState(task(TaskSchedule.now(), Json.object(), "other")); assertNotNull(id);/*w w w. j av a 2 s.co m*/ Set<TaskState> res = stateStorage.getTasks(null, null, "other", null, 0, 0); assertTrue(res.parallelStream().map(TaskState::getId).filter(x -> x.equals(id)).collect(Collectors.toList()) .size() == 1); }
From source file:com.fitbur.jestify.junit.spring.IntegrationTestCreator.java
void create() { Map<DescriptorKey, ParameterDescriptor> parameterDescriptors = context.getParamaterDescriptors(); Map<DescriptorKey, FieldDescriptor> fieldDescriptors = context.getFieldDescriptors(); Object[] arguments = new Object[parameterDescriptors.size()]; Collection<FieldDescriptor> descriptors = fieldDescriptors.values(); Set<FieldDescriptor> mockDescriptors = descriptors.parallelStream().filter(p -> p.getMock().isPresent()) .collect(toSet());//from w w w.j ava 2 s .c o m //process fields with a custom index first mockDescriptors.parallelStream().filter(p -> p.getMock().get().index() != -1) .map(p -> new IndexMockInjector(context, testReifier, appContext, p, arguments)) .forEach(IndexMockInjector::inject); //process fields with custom names second mockDescriptors.parallelStream().filter(p -> !p.getMock().get().name().isEmpty()) .map(p -> new NameMockInjector(context, testReifier, appContext, p, arguments)) .forEach(NameMockInjector::inject); //process fields with type based injection mockDescriptors.parallelStream() .filter(p -> p.getMock().get().index() == -1 && p.getMock().get().name().isEmpty()) .map(p -> new TypeMockInjector(context, testReifier, appContext, p, arguments)) .forEach(TypeMockInjector::inject); //process fields with custom names second descriptors.parallelStream().filter(p -> !p.getMock().isPresent() && (p.getAnnotation(Inject.class).isPresent() || p.getAnnotation(Autowired.class).isPresent())) .map(p -> new RealInjector(context, testReifier, appContext, p, arguments)) .forEach(RealInjector::inject); testReifier.reifyCut(context.getCutDescriptor(), arguments); }
From source file:ai.grakn.test.engine.tasks.storage.TaskStateGraphStoreTest.java
@Test public void testGetTaskStateByClassName() { TaskId id = stateStorage.newState(task()); assertNotNull(id);/*w ww . jav a 2 s. c o m*/ Set<TaskState> res = stateStorage.getTasks(null, ShortExecutionMockTask.class.getName(), null, null, 0, 0); assertTrue(res.parallelStream().map(TaskState::getId).filter(x -> x.equals(id)).collect(Collectors.toList()) .size() == 1); }
From source file:delfos.rs.collaborativefiltering.als.ALSRecommender.java
@Override public RecommendationsToUser recommendToUser(DatasetLoader<? extends Rating> dataset, MatrixFactorizationModel recommendationModel, User user, Set<Item> candidateItems) { List<Recommendation> recommendations = candidateItems.parallelStream().map(item -> { double predictRating = recommendationModel.predictRating(user, item); return new Recommendation(item, predictRating); }).collect(Collectors.toList()); return new RecommendationsToUser(user, recommendations); }
From source file:de.flashpixx.rrd_antlr4.generator.IBaseGenerator.java
/** * ctor/* ww w .j a v a2 s . co m*/ * * @param p_baseoutputdirectory base output directory * @param p_templates array with exporting templates * @param p_imports set with imported grammar files * @param p_docuclean set with documentation strings */ protected IBaseGenerator(final File p_baseoutputdirectory, final Set<File> p_imports, final Set<String> p_docuclean, final Set<ETemplate> p_templates) { m_docuclean = p_docuclean; m_templates = p_templates; m_baseoutput = p_baseoutputdirectory; m_imports = Collections.unmodifiableMap(p_imports.parallelStream() .collect(Collectors.toMap(i -> FilenameUtils.removeExtension(i.getName()), i -> i))); }
From source file:com.wso2.code.quality.matrices.ChangesFinder.java
/** * Finding the authors of the commits// w w w . j a va2s . co m * * @param owner owner of the repository * @param repositoryName repository name * @param fileName name of the file which is required to get blame details * @param arrayListOfRelevantChangedLinesOfSelectedFile arraylist containing the changed line ranges of the current selected file * @param gitHubToken github token for accessing github GraphQL API */ public void iterateOverToFindAuthors(String owner, String repositoryName, String fileName, ArrayList<String> arrayListOfRelevantChangedLinesOfSelectedFile, String gitHubToken) { for (Map.Entry m : commitHashesMapOfTheParent.entrySet()) { String oldRange = (String) m.getKey(); Set<String> commitHashes = (Set<String>) m.getValue(); commitHashes.parallelStream().forEach(parentCommitHashForCallingGraphQl -> { graphqlApiJsonObject.put("query", "{repository(owner:\"" + owner + "\",name:\"" + repositoryName + "\"){object(expression:\"" + parentCommitHashForCallingGraphQl + "\"){ ... on Commit{blame(path:\"" + fileName + "\"){ranges{startingLine endingLine age commit{ url author { name email } } } } } } } }"); JSONObject rootJsonObject = null; try { rootJsonObject = (JSONObject) graphQlApiCaller.callGraphQlApi(graphqlApiJsonObject, gitHubToken); readBlameReceivedForAFile(rootJsonObject, arrayListOfRelevantChangedLinesOfSelectedFile, true, oldRange); } catch (CodeQualityMatricesException e) { logger.error(e.getMessage(), e.getCause()); System.exit(1); } }); } }
From source file:org.age.services.topology.internal.DefaultTopologyService.java
/** * Simple master selection. We rely on Hazelcast, so we just need to perform local, deterministic selection. * * In this case we selects the node with the largest nodeId. *//*from w w w . java2 s . c o m*/ private void electMaster(@NonNull final FSM<State, Event> fsm) { log.debug("Locally selecting master."); final Set<@NonNull NodeDescriptor> computeNodes = getComputeNodes(); final Optional<NodeDescriptor> maxIdentity = computeNodes.parallelStream() .max(Comparator.comparing(NodeDescriptor::id)); log.debug("Max identity is {}.", maxIdentity); assert maxIdentity.isPresent(); if (identityService.nodeId().equals(maxIdentity.get().id())) { log.debug("I am master."); master = true; runtimeConfig.put(ConfigKeys.MASTER, identityService.nodeId()); // Select initial topology type if this is the first election if (!runtimeConfig.containsKey(ConfigKeys.TOPOLOGY_TYPE)) { log.debug("Seems to be the first election. Selecting topology."); final Optional<TopologyProcessor> selectedProcessor = topologyProcessors.parallelStream() .max(Comparator.comparing(TopologyProcessor::priority)); assert selectedProcessor.isPresent(); currentTopologyProcessor = selectedProcessor.get(); log.debug("Selected initial topology: {}.", currentTopologyProcessor); runtimeConfig.put(ConfigKeys.TOPOLOGY_TYPE, currentTopologyProcessor.name()); } listenerKey = runtimeConfig.addEntryListener(new TopologyTypeChangeListener(), ConfigKeys.TOPOLOGY_TYPE, true); service.fire(Event.TOPOLOGY_TYPE_CHANGED); fsm.goTo(State.MASTER_ELECTED_MASTER); topic.publish(TopologyMessage.createWithoutPayload(MASTER_ELECTED)); } else { log.debug("I am slave."); master = false; if (listenerKey != null) { runtimeConfig.removeEntryListener(listenerKey); } fsm.goTo(State.MASTER_ELECTED_SLAVE); } }