Questions tagged [parallelstream]

41 questions
4
votes
1 answer

Unexpected behavior for the reduce() operation for the Set-backed parallel Stream

When I am reducing the Set-backed stream, the identity element appears on the right of the result: import java.util.Collection; import java.util.List; import java.util.Set; public class StreamReduce { public static void main(String[] args) { …
Barat Sahdzijeu
  • 1,683
  • 1
  • 18
  • 29
3
votes
4 answers

Java ParallelStream: several map or single map

Introduction I'm currently developing a program in which I use Java.util.Collection.parallelStream(), and wondering if it's possible to make it more Multi-threaded. Several small map I was wondering if using multiple map might allow the…
ThrowsError
  • 1,169
  • 1
  • 11
  • 43
3
votes
1 answer

Bug in parallelStream in java

Can someone tell me why this is happening and if it's expected behaviour or a bug List a = Arrays.asList(1,1,3,3); a.parallelStream().filter(Objects::nonNull) .filter(value -> value > 2) .reduce(1,Integer::sum) Answer:…
2
votes
1 answer

List of Strings is not running in parallel - Java 8 parallel streams

I got a requirement to run a collection using parallel stream and it is always running in sequence, here in the below example List is always running in sequence where as IntStream is running in parallel. could some please help me to understand the…
1
vote
1 answer

Java Flux Exception Handling?

Can someone please guide me as I am new to the flux and trying to understand how to handle this scenario? Issue: I am getting readTimeout exception in one of the flux responses from getResp() method below and then all the prior successful responses…
1
vote
0 answers

Why does PBEWithMD5AndDES mess up encryption in parallelStream in Java?

I am working in a Spring Boot project where we use the PBEWithMD5AndDES encryption algorithm. We use the javax.crypto.Cipher class library like the code below. When we process single requests it works fine, but in a new feature we need our server to…
1
vote
0 answers

How parallel stream works in Java after increasing ForkJoinPool?

I see that the default ForkJoinPool.commonPool size is one less thread than number of CPU cores. And also to make custom pool we can either use follows, 1. java.util.concurrent.ForkJoinPool.common.parallelism=30 2. ForkJoinPool fjp = new…
Dave
  • 123
  • 1
  • 11
1
vote
2 answers

How to handle more Files Handling in Java 8 in parallel

In my java web application is a file based integration. They used to send the bunch of xml files (example: 10000) in our production server opt/app/proceed/ folder. But as per the current configuration our application able to handle 200 files in a…
1
vote
0 answers

ParallelStream gives inconsistent results in JPA Springboot Postgres DB

I am using parallel stream to process large dataset. But it gives inconsistent results. The database used is Postgres. I have hierarchical data with levels defined. For example, I have 5 levels of data in a hierarchy. I am processing the lowest…
0
votes
0 answers

processing large files in parallel using java

I am attempting to process ten files, with some being smaller and others containing up to three million records. I have grouped the files into five groups based on logical dependencies, with variable file counts in each group. Group 1 has one file,…
0
votes
0 answers

ParallelStream and multiple calls in the mapper

I am trying to build a list of responses from a list of entities (DB). To construct my list of responses, I am using parallelStream and in the mapper, I am trying to call another microservice but the problem is that only one result is injected into…
b-user
  • 97
  • 1
  • 3
  • 10
0
votes
0 answers

When using parallelStream, a child thread throws an exception

In a Spring Boot application, I'm writing files to S3 using list.stream().parallel().forEach. When trying to get the resource using resourceLoader.getResource(filePath), it throws the exception 'com.amazonaws.services.s3.AmazonS3 referenced from a…
0
votes
2 answers

why parallel streams will only perform a concurrent reduction if either (not both) the stream is unordered, or the collector is UNORDERED?

I'm struggling understanding the rule mentioned in Java docs (https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html) related to parallel stream stating that "The Stream.collect(Collector) implementation will only perform a…
0
votes
1 answer

Why does skip() in this parallel stream expression in Java 19 cause an OOM even with 8GB?

I get an OOM in Java 19 even with 8GB if I do this: IntStream .iterate(0, i -> i + 1) .skip(2) .limit(10_000_000) .filter(i -> checkSum(i) <= 20) .parallel() .count(); However, I don't get any OOM if I omit skip(2): IntStream .iterate(0, i -> i +…
mmirwaldt
  • 843
  • 7
  • 17
0
votes
2 answers

How to achieve Parallel Authentication using Kerberos?

I have a requirement to make multiple independent micro service calls in parallel in Spring Boot (Java) in order to address the performance issue in making sequential calls and these micro services are authenticated using Kerberos. When I initially…
1
2 3