Summary

In this chapter, we used the different versions of the collect() method provided by the Stream framework to transform and group the elements of a Stream. This and Chapter 7, Processing Massive Datasets with Parallel Streams – The Map and Reduce Model, teach you how to work with the whole stream API.

Basically, the collect() method needs a collector that processes the data of the stream and generates a data structure returned by the set of aggregate operations that forms the stream. A collector works with three different data structures—the class of the input elements, an intermediate data structure used while processing the input elements, and a final data structure that is returned.

We used the different versions of the collect() method to implement a search tool that must look for a query in a set of files without an inverted index, a recommendation system, and a tool to calculate the common contacts between two users in a social network.

In the next chapter, we will take a deep look at the concurrent data structures and synchronization mechanisms provided by the Java concurrent API.

..................Content has been hidden....................

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