-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Raja Kolli edited this page Apr 3, 2017
·
8 revisions
Welcome to the StreamsLearning Wiki!
A stream is a sequence of data values supporting sequential and parallel aggregate operations.
- Using aggregate functions we can sum all sales figures for a month, region or product.
- Aggregate operations work on a list of items and produces a single value.
- The result of an aggregate operation on stream may be primative value, an object or a void for Stream.
- Java Collections focus on how to store data elements for efficient access.
Java Collection is an in-memory data structure that stores all its elements.
Java Collection cannot reprsent a group of infinate elements
- Java Streams focus on aggregate operations on data elements from a data source.
Java Streams has no storage. Java stream pulls elements from a data source on-demand and passes them to a pipeline of operations for processing. Java Streams we focus on operations Example (Aggregates)
Java Streams can reprsent a group of infinate elements Java Streams can pull its elements from data source. The data sourse can be a collection, a function that generates data, an I/O channel, etc. A Java Stream can pull data from a function which generates infinate number of elements.
Java Streams cannot be reusable after calling a teriminal operation. To perform a computation on the same elements from the data source, we have to recrete the stream pipeline. Java Streams can throw an illegalStateException in case of reusing
use parallelStream() instead stream() Easy to use when using internal iteration provided by stream.
Intermediate operation is also called lazy operations. Intermediate operation on a stream produces another stream. filter(), map() are lazy operations.
Terminal operations are also called eager operations reduce() is a eager operation.
Raja Kolli
Raja Kolli