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 8, Processing Massive Datasets with Parallel Streams - the Map and Reduce Model, teach you how to work with the whole stream API.
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...