Using MapReduce

In the MapReduce pattern we express two sets of operations, one to perform on each element in a collection and one to combine these results to arrive at a final result. This pattern is gaining attention due to its simplicity and power to exploit multicore processors.

The JVM is all geared up to utilize multicore processors. To fully benefit from the true power of the JVM and multicore processors, however, we have to change the way we code. In this section we’ll explore the MapReduce pattern with an example, and in the next section we’ll build on that example to parallelize it.

Let’s continue with the example we’ve been using. Given a list of ticker symbols, let’s pick the highest-priced stock whose value is less than $500. Let’s ...

Get Functional Programming in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.