List of usage examples for java.util.stream Collectors groupingBy
public static <T, K, A, D> Collector<T, ?, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier, Collector<? super T, A, D> downstream)
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<Account, DoubleSummaryStatistics> aggregateByAccount_serial_lazy_streams_ec() { Map<Account, DoubleSummaryStatistics> accountDoubleMap = this.ecPositions.stream().collect(Collectors .groupingBy(Position::getAccount, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(accountDoubleMap); return accountDoubleMap; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<String, DoubleSummaryStatistics> aggregateByCategory_serial_lazy_jdk() { Map<String, DoubleSummaryStatistics> categoryDoubleMap = this.jdkPositions.stream().collect(Collectors .groupingBy(Position::getCategory, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(categoryDoubleMap); return categoryDoubleMap; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<String, DoubleSummaryStatistics> aggregateByCategory_serial_lazy_streams_ec() { Map<String, DoubleSummaryStatistics> categoryDoubleMap = this.ecPositions.stream().collect(Collectors .groupingBy(Position::getCategory, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(categoryDoubleMap); return categoryDoubleMap; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<Product, DoubleSummaryStatistics> aggregateByProduct_parallel_lazy_jdk() { Map<Product, DoubleSummaryStatistics> result = this.jdkPositions.parallelStream().collect(Collectors .groupingBy(Position::getProduct, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result);//www. ja va 2 s . c o m return result; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<Product, DoubleSummaryStatistics> aggregateByProduct_parallel_lazy_streams_ec() { Map<Product, DoubleSummaryStatistics> result = this.ecPositions.parallelStream().collect(Collectors .groupingBy(Position::getProduct, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result);/*from www. j a v a 2s.com*/ return result; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<Account, DoubleSummaryStatistics> aggregateByAccount_parallel_lazy_jdk() { Map<Account, DoubleSummaryStatistics> result = this.jdkPositions.parallelStream().collect(Collectors .groupingBy(Position::getAccount, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result);/*from w w w . ja v a 2s. c om*/ return result; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<Account, DoubleSummaryStatistics> aggregateByAccount_parallel_lazy_streams_ec() { Map<Account, DoubleSummaryStatistics> result = this.ecPositions.parallelStream().collect(Collectors .groupingBy(Position::getAccount, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result);//from ww w .jav a 2s . c o m return result; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<String, DoubleSummaryStatistics> aggregateByCategory_parallel_lazy_jdk() { Map<String, DoubleSummaryStatistics> result = this.jdkPositions.parallelStream().collect(Collectors .groupingBy(Position::getCategory, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result);/*from w w w. j a va2 s. com*/ return result; }
From source file:org.eclipse.collections.impl.jmh.AggregateByTest.java
@Benchmark public Map<String, DoubleSummaryStatistics> aggregateByCategory_parallel_lazy_streams_ec() { Map<String, DoubleSummaryStatistics> result = this.ecPositions.parallelStream().collect(Collectors .groupingBy(Position::getCategory, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result);/*from w ww . j a v a2s .co m*/ return result; }
From source file:org.eclipse.collections.impl.jmh.AnagramSetTest.java
@Benchmark public void serial_lazy_jdk() { Map<Alphagram, Set<String>> groupBy = this.jdkWords.stream() .collect(Collectors.groupingBy(Alphagram::new, Collectors.toSet())); groupBy.entrySet().stream().map(Map.Entry::getValue).filter(list -> list.size() >= SIZE_THRESHOLD) .sorted(Comparator.<Set<String>>comparingInt(Set::size).reversed()) .map(list -> list.size() + ": " + list).forEach(e -> Assert.assertFalse(e.isEmpty())); }