Parallelizing the collector – BinaryOperator<A> combiner();

If the stream is processed in parallel, then different threads (accumulators) will produce partial result containers. In the end, these partial results must be merged in a single one. This is exactly what combiner() does. In this case, the combiner() method needs to merge two maps by adding all the values from the two lists of the second Map to the corresponding lists in the first Map:

@Override
public BinaryOperator<Map<Boolean, List<Melon>>> combiner() {

return (var map, var addMap) -> {
map.get(true).addAll(addMap.get(true));
map.get(false).addAll(addMap.get(false));

return map;
};
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.134.151