java.util.Set.parallelStream()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中java.util.Set.parallelStream()方法的一些代码示例,展示了Set.parallelStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Set.parallelStream()方法的具体详情如下:
包路径:java.util.Set
类名称:Set
方法名:parallelStream

Set.parallelStream介绍

暂无

代码示例

代码示例来源:origin: google/guava

@Override
public Stream<E> parallelStream() {
 return set1.parallelStream().filter(set2::contains);
}

代码示例来源:origin: google/guava

@Override
public Stream<E> parallelStream() {
 return set1.parallelStream().filter(e -> !set2.contains(e));
}

代码示例来源:origin: stanfordnlp/CoreNLP

@Override public Stream<E> parallelStream()       {return s.parallelStream();}

代码示例来源:origin: prestodb/presto

@Override
public Stream<E> parallelStream() {
 return set1.parallelStream().filter(set2::contains);
}

代码示例来源:origin: prestodb/presto

@Override
public Stream<E> parallelStream() {
 return set1.parallelStream().filter(e -> !set2.contains(e));
}

代码示例来源:origin: yu199195/hmily

private List<HmilyCompensationVO> findAll(final Set<byte[]> keys) {
  return keys.parallelStream()
      .map(this::buildVOByKey)
      .filter(Objects::nonNull)
      .collect(Collectors.toList());
}

代码示例来源:origin: yu199195/hmily

private List<HmilyCompensationVO> findByPage(final Set<byte[]> keys, final int start, final int pageSize) {
  return keys.parallelStream()
      .skip(start)
      .limit(pageSize)
      .map(this::buildVOByKey)
      .filter(Objects::nonNull)
      .collect(Collectors.toList());
}

代码示例来源:origin: Vedenin/useful-java-links

/** 12. Using Java 8 Stream Api parallel 2  **/
@Benchmark
public long test12_UsingJava8StreamApiparallel2() throws IOException {
  return map.entrySet().parallelStream().mapToLong(e -> e.getKey() + e.getValue()).sum();
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public void parallel_lazy_jdk()
{
  Map<Alphagram, List<String>> groupBy = this.jdkWords.parallelStream().collect(Collectors.groupingBy(Alphagram::new));
  groupBy.entrySet()
      .parallelStream()
      .map(Map.Entry::getValue)
      .filter(list -> list.size() >= SIZE_THRESHOLD)
      .sorted(Comparator.<List<String>>comparingInt(List::size).reversed())
      .map(list -> list.size() + ": " + list)
      .forEach(e -> Assert.assertFalse(e.isEmpty()));
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public void parallel_lazy_jdk()
{
  Map<Alphagram, List<String>> groupBy = this.guavaWords.parallelStream().collect(Collectors.groupingBy(Alphagram::new));
  groupBy.entrySet()
      .parallelStream()
      .map(Map.Entry::getValue)
      .filter(list -> list.size() >= SIZE_THRESHOLD)
      .sorted(Comparator.<List<String>>comparingInt(List::size).reversed())
      .map(list -> list.size() + ": " + list)
      .forEach(e -> Assert.assertFalse(e.isEmpty()));
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public void parallel_lazy_streams_gsc()
{
  Map<Alphagram, List<String>> groupBy = this.gscWords.parallelStream().collect(Collectors.groupingBy(Alphagram::new));
  groupBy.entrySet()
      .parallelStream()
      .map(Map.Entry::getValue)
      .filter(list -> list.size() >= SIZE_THRESHOLD)
      .sorted(Comparator.<List<String>>comparingInt(List::size).reversed())
      .map(list -> list.size() + ": " + list)
      .forEach(e -> Assert.assertFalse(e.isEmpty()));
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public Map<Boolean, Set<Integer>> groupBy_2_keys_parallel_lazy_jdk()
{
  Map<Boolean, Set<Integer>> multimap = this.integersJDK.parallelStream().collect(Collectors.groupingBy(each -> each % 2 == 0, Collectors.toSet()));
  Verify.assertSize(2, multimap);
  return multimap;
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public Map<Integer, Set<Integer>> groupBy_100_keys_parallel_lazy_jdk()
{
  Map<Integer, Set<Integer>> multimap = this.integersJDK.parallelStream().collect(Collectors.groupingBy(each -> each % 100, Collectors.toSet()));
  Verify.assertSize(100, multimap);
  return multimap;
}

代码示例来源:origin: alibaba/Sentinel

private void applyAllRemainingMachineSet(String app, Set<String> remainingSet, Set<String> failedSet) {
  if (remainingSet == null || remainingSet.isEmpty()) {
    return;
  }
  remainingSet.parallelStream()
    .filter(Objects::nonNull)
    .map(MachineUtils::parseCommandIpAndPort)
    .filter(Optional::isPresent)
    .map(Optional::get)
    .map(ipPort -> {
      String ip = ipPort.r1;
      int commandPort = ipPort.r2;
      CompletableFuture<Void> f = modifyMode(app, ip, commandPort, ClusterStateManager.CLUSTER_NOT_STARTED);
      return Tuple2.of(ip + '@' + commandPort, f);
    })
    .forEach(t -> handleFutureSync(t, failedSet));
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public void parallel_lazy_jdk()
{
  long evens = this.integersJDK.parallelStream().filter(each -> each % 2 == 0).count();
  Assert.assertEquals(SIZE / 2, evens);
}

代码示例来源:origin: testcontainers/testcontainers-java

@Override
public void beforeEach(final ExtensionContext context) {
  collectParentTestInstances(context)
    .parallelStream()
    .flatMap(this::findRestartContainers)
    .forEach(adapter -> context.getStore(NAMESPACE)
      .getOrComputeIfAbsent(adapter.getKey(), k -> adapter.start()));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void toHashSet_with_size_parallel_stream() {
 assertThat(HUGE_SET.parallelStream().collect(toHashSet(HUGE_SET.size()))).isEqualTo(HUGE_SET);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void toSet_with_size_parallel_stream() {
 assertThat(HUGE_SET.parallelStream().collect(toSet(HUGE_SET.size()))).isEqualTo(HUGE_SET);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void toHashSet_parallel_stream() {
 assertThat(HUGE_SET.parallelStream().collect(toHashSet())).isEqualTo(HUGE_SET);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void toSet_parallel_stream() {
 assertThat(HUGE_SET.parallelStream().collect(toSet())).isEqualTo(HUGE_SET);
}

相关文章