List of usage examples for java.util ArrayList stream
default Stream<E> stream()
From source file:com.intel.daal.spark.rdd.DistributedNumericTable.java
/** * Generator method that transforms a JavaRDD<Vector> into a DistributedNumericTable, * keeping the original partitioning.// w w w .j a v a 2 s . c o m * @param vecrdd - A JavaRDD<Vector> object. * @param maxRowsPerTable - Max number of rows in eachNumericTable. If this is non-positive * then all rows in a partition are transformed into a single NumericTable. * @return A DistributedNumericTable backed by HomogenNumericTables. */ public static DistributedNumericTable fromJavaVectorRDD(final JavaRDD<Vector> vecrdd, final int maxRowsPerTable) { Vector first = vecrdd.first(); int ncols = first.size(); JavaPairRDD<Vector, Long> vecrddWithIds = vecrdd.zipWithIndex(); JavaRDD<NumericTableWithIndex> jntrdd = vecrddWithIds .mapPartitions(new FlatMapFunction<Iterator<Tuple2<Vector, Long>>, NumericTableWithIndex>() { public List<NumericTableWithIndex> call(Iterator<Tuple2<Vector, Long>> it) { DaalContext context = new DaalContext(); ArrayList<NumericTableWithIndex> tables = new ArrayList<NumericTableWithIndex>(); int cursize = 0; int nrows = 0; ArrayList<Double> data = new ArrayList<>(); while (it.hasNext()) { Tuple2<Vector, Long> tup = it.next(); double[] row = tup._1().toArray(); for (double r : row) { data.add(r); } cursize += row.length; nrows++; if (nrows == maxRowsPerTable || !it.hasNext()) { NumericTableWithIndex part = new NumericTableWithIndex(tup._2() - nrows + 1, new HomogenNumericTable(context, data.stream().mapToDouble(i -> i).toArray(), cursize / nrows, nrows)); tables.add(part); cursize = 0; nrows = 0; } } return tables; } }, true); return new DistributedNumericTable(jntrdd, vecrdd.count(), ncols); }
From source file:com.gabrielluz.megasenaanalyzer.MegaSenaAnalyzer.java
public Integer[] getTimesNumbersPicked(int ultimosSorteios) { Integer[] counterArray = new Integer[60]; int temp = (this._pickedNumbers.size() - ultimosSorteios); for (int i = 0; i < counterArray.length; i++) { counterArray[i] = 0;/* w w w. ja va 2 s. c o m*/ } for (int i = temp; i < this._pickedNumbers.size(); i++) { ArrayList<Integer> intArray2 = this._pickedNumbers.get(i); intArray2.stream().forEach((Integer j) -> { counterArray[j - 1]++; }); } return counterArray; }
From source file:io.paradoxical.francois.ServiceApplication.java
@Override public void run(ServiceConfiguration config, final Environment env) throws Exception { ArrayList<BiConsumer<ServiceConfiguration, Environment>> run = new ArrayList<>(); run.add(this::configureJson); run.add(this::configureLogging); run.stream().forEach(configFunction -> configFunction.accept(config, env)); }
From source file:org.nirvana.ServiceApplication.java
@Override public void run(ServiceConfiguration config, final Environment env) throws Exception { ArrayList<BiConsumer<ServiceConfiguration, Environment>> run = new ArrayList<>(); run.add(this::configureJson); run.add(this::configureLogging); run.add(this::configureFilters); run.stream().forEach(configFunction -> configFunction.accept(config, env)); }
From source file:se.trixon.almond.dialogs.cron.ElementPanel.java
protected void initModel(ArrayList<String> arrayList) { arrayList.stream().forEach((string) -> { mListModel.addElement(string);//from w w w . ja v a2 s . c o m }); list.setModel(mListModel); spinner.setModel(new SpinnerNumberModel(2, 2, mListModel.getSize() + mOffset - 1, 1)); }
From source file:de.unima.core.persistence.AbstractEntityRepository.java
@Override public List<T> findAll() { return store.readWithConnection(connection -> connection.as(Dataset.class).map(dataset -> { final ArrayList<String> graphIds = Lists.newArrayList(dataset.listNames()); return graphIds.stream().filter(this::isGraphOfEntityInstance) .map(graph -> createEntity(graph, dataset)).collect(Collectors.toList()); })).get().get();// w w w .j a va 2 s .co m }
From source file:$.ServiceApplication.java
@Override public void run(ServiceConfiguration config, final Environment env) throws Exception { ArrayList<BiConsumer<ServiceConfiguration, Environment>> run = new ArrayList<>(); run.add(this::configureJson); run.add(this::configureLogging); run.add(this::configureFilters); run.stream().forEach(configFunction -> configFunction.accept(config, env)); }// w ww. ja v a2 s. c om
From source file:io.pravega.controller.server.eventProcessor.ScaleRequestHandler.java
private CompletableFuture<List<Void>> clearMarkers(final String scope, final String stream, final ArrayList<Integer> segments, final OperationContext context) { return FutureHelpers.allOfWithResults(segments.stream().parallel() .map(x -> streamMetadataStore.removeMarker(scope, stream, x, context, executor)) .collect(Collectors.toList())); }
From source file:com.wormsim.simulation.Walker.java
/** * For serialization - to be replaced?// ww w . ja va 2s .co m * * @param rng The random number generator to use. * @param seed The initial seed number (unused but important for * recording). * @param zoo The zoo to use. * @param fitness The fitness tracker * @param tracked_quantities Quantities tracked in the simulation. */ protected Walker(RandomGenerator rng, long seed, AnimalZoo2 zoo, TrackedCalculation fitness, ArrayList<TrackedCalculation> tracked_quantities) { this.rng = rng; this.seed = seed; this.zoo = zoo.generate(rng); this.fitness = fitness.generate(rng); this.tracked_quantities = tracked_quantities.stream().map((v) -> v.generate(rng)) .collect(Collectors.toCollection(ArrayList::new)); this.tracked_quantities.add(this.fitness); }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.response_entities.TKAllWatchListsResponse.java
@JsonSetter("watchlists") @SuppressWarnings("unchecked") public void setWatchLists(LinkedHashMap<String, Object> watchListsResponse) { ArrayList<String> resultList = new ArrayList<>(); Object list = watchListsResponse.get("watchlist"); ArrayList<LinkedHashMap<String, String>> itemList = new ArrayList<>(); if (list.getClass() == ArrayList.class) { //we know from condition this is right itemList = (ArrayList) list; } else {//from ww w .j a va 2 s .com itemList.add((LinkedHashMap) watchListsResponse.get("watchlist")); } resultList.addAll(itemList.stream().map(item -> item.get("id")).collect(Collectors.toList())); this.watchLists = new String[resultList.size()]; this.watchLists = resultList.toArray(this.watchLists); }