List of usage examples for java.util List parallelStream
default Stream<E> parallelStream()
From source file:com.baidu.rigel.biplatform.tesseract.isservice.search.agg.AggregateCompute.java
/** * ?// w w w . j a va2s .co m * * @param dataList * ? * @param query * * @return LinkedList<ResultRecord> ?? */ public static List<SearchIndexResultRecord> aggregate(List<SearchIndexResultRecord> dataList, int dimSize, List<QueryMeasure> queryMeasures) { if (CollectionUtils.isEmpty(queryMeasures) || CollectionUtils.isEmpty(dataList) || dataList.size() == 1) { LOGGER.info("no need to group."); return dataList; } List<SearchIndexResultRecord> result = new ArrayList<SearchIndexResultRecord>(); // Set<Integer> countIndex = Sets.newHashSet(); // for (int i = 0 ; i < queryMeasures.size() ; i++) { // if (queryMeasures.get(i).getAggregator().equals(Aggregator.COUNT)) { // countIndex.add(dimSize + i); // } // } int arraySize = dataList.get(0).getFieldArraySize(); long current = System.currentTimeMillis(); Map<String, SearchIndexResultRecord> groupResult = dataList.parallelStream() .collect(Collectors.groupingByConcurrent(SearchIndexResultRecord::getGroupBy, Collectors .reducing(new SearchIndexResultRecord(new Serializable[arraySize], null), (x, y) -> { SearchIndexResultRecord var = new SearchIndexResultRecord(new Serializable[arraySize], y.getGroupBy()); try { for (int i = 0; i < dimSize; i++) { var.setField(i, y.getField(i)); } int index = dimSize; for (int i = 0; i < queryMeasures.size(); i++) { QueryMeasure measure = queryMeasures.get(i); index = i + dimSize; var.setField(i + dimSize, Aggregate.aggregate(x.getField(index), y.getField(index), measure.getAggregator())); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return var; }))); LOGGER.info("group agg(sum) cost: {}ms!", (System.currentTimeMillis() - current)); result.addAll(groupResult.values()); return result; }
From source file:com.civprod.writerstoolbox.NaturalLanguage.util.TextAndTokenHandling.RegexTokenFilter.java
public List<String> filter(List<String> tokens) { return tokens.parallelStream().filter(this).collect(Collectors.toList()); }
From source file:com.mec.DAO.GE.EdificioDAO.java
public List<EstablecimientoEdificio> getByEstablecimientoId(int id) { Query query = getSessionGE().createQuery("from EstablecimientoEdificio where EstablecimientoId = :id"); query.setParameter("id", id); List<EstablecimientoEdificio> edificios = query.list(); edificios.parallelStream().forEach((edi) -> { lazyInit(edi);//w ww.j av a2 s . co m }); return edificios; }
From source file:org.wallerlab.yoink.regionizer.partitioner.CubePartitioner.java
private void checkEveryGridPoint(Map<Region.Name, Region> regions, Region.Name cubeRegionName, List<GridPoint> gridPoints, List<Coord> coordinates) { coordinates.parallelStream().forEach(currentCoord -> { Map<String, Object> properties = gridPointAssigner.assign(currentCoord, regions, cubeRegionName); if (!properties.isEmpty()) { SimpleGridPoint gridPoint = new SimpleGridPoint(); gridPoint.setCoordinate(currentCoord); gridPoint.setIndexInCube(coordinates.indexOf(currentCoord)); gridPoint.setProperties(properties); gridPoints.add(gridPoint);//from ww w . java 2s .c om } }); }
From source file:cognition.pipeline.commandline.CommandRunFromFileSystem.java
@Override public void process(CommandLine cmd) { folderAbsolutePath = cmd.getOptionValue("folder"); File folder = new File(folderAbsolutePath); String[] files = folder.list(); List<String> fileList = new ArrayList<>(); fileList.addAll(Arrays.asList(files)); fileList.parallelStream().forEach(file -> { String absoluteFilePath = folderAbsolutePath + file; logger.info("Processing " + absoluteFilePath); dncPipelineService.processFile(absoluteFilePath); });/*ww w . j a v a2s . com*/ logger.info("Finished all files in directory " + folderAbsolutePath); }
From source file:cognition.pipeline.service.ElasticsearchService.java
public void exportToElastic(String url, Long port) { Client client = new TransportClient() .addTransportAddress(new InetSocketTransportAddress(url, port.intValue())); logger.info("Getting results from the results table..."); List<DNCWorkCoordinate> results = dncWorkUnitDao.getResults(); results.parallelStream().forEach(coordinate -> { try {/*from w w w .j a v a 2 s .co m*/ client.prepareIndex("coordinates", "coordinate", coordinate.getCoordinateString()) .setSource(jsonBuilder().startObject().field("id", coordinate.getCoordinateString()) .field("patientId", coordinate.getPatientId()) .field("tableName", coordinate.getSourceTable()) .field("idInTable", coordinate.getIdInSourceTable()) .field("dataType", StringTools.getOrEmpty(coordinate.getType())) .field("dataColumnName", StringTools.getOrEmpty(coordinate.getPkColumnName())) .field("documentXhtml", coordinate.getConversionResult()) .field("documentText", HTMLUtil.getContentFromHTML(coordinate.getConversionResult())) .field("lastModifiedDate", TimeUtil.fromUTCFormat(HTMLUtil .getMetaValue(coordinate.getConversionResult(), "Last-Modified"))) .field("author", HTMLUtil.getMetaValue(coordinate.getConversionResult(), "Author")) .field("pageCount", Integer.valueOf( HTMLUtil.getMetaValue(coordinate.getConversionResult(), "xmpTPg:NPages"))) .endObject()) .execute().actionGet(); } catch (IOException e) { logger.error(e.getMessage()); } }); logger.info("All done."); client.close(); }
From source file:org.egov.infra.admin.master.service.ActionService.java
private Action findNearestMatchingAction(String url, List<Action> actions) { return actions.isEmpty() ? null : actions.parallelStream() .filter(action -> LevenshteinDistance.getDefaultInstance().apply(url, action.getUrl()) < 1) .findFirst().orElse(actions.get(0)); }
From source file:lumbermill.internal.transformers.Grok.java
public Observable<List<E>> parse(List<E> events) { return Observable.just(events.parallelStream().map(this::doGrok).collect(toList())); }
From source file:uk.ac.ebi.ep.data.repositories.EnzymePortalCompoundRepositoryImpl.java
@Override public List<String> findEnzymesByCompound(String compoundId) { Set<String> enzymes = new TreeSet<>(); JPAQuery query = new JPAQuery(entityManager); BooleanExpression compound = $.compoundId.equalsIgnoreCase(compoundId); List<EnzymePortalCompound> compounds = query.from($).where(compound).distinct().list($); compounds.parallelStream().forEach(c -> { enzymes.add(c.getUniprotAccession().getAccession()); });/*from w w w. ja v a2 s . c om*/ return enzymes.stream().distinct().collect(Collectors.toList()); }
From source file:com.mec.Services.EstablecimientosService.java
private void initCollections(List<EstablecimientoPost> establecimientos) { establecimientos.parallelStream().forEach((establecimiento) -> { this.setGeoAndConexiones(establecimiento); });// ww w .j ava 2 s. c o m }