Stream Gathers - The biggest change to Java Streams since 10 years
summary
Java 22 adds Stream Gatherers as a new intermediate-operation API that lets code define a gatherer API with initializer integrator combiner and finisher, so custom ops actually transform streams. Built-in gatherers include mapConcurrent (uses virtual threads to run mapping tasks concurrently with a configurable parallelism), fault and scan for reductions, and windowFixed/windowSliding that produce sublists (e.g. 1..8 into [1,2,3][4,5,6][7,8]). Example code shows a stateless uppercase mapper, a stateful limit returning first N elements, and a finisher that emits leftover windows.
AI-written summary · about
chapters (7)
- 0:00Introduction to Stream Gathers
- 9:47What are Stream Gatherers
- 16:10Custom Gatherer API explained
- 20:45Stateless gatherer example
- 24:18Stateful gatherer with limit
- 30:24Fixed window gatherer demo
- 33:36Q&A on gatherers
related talks
44mLevel Up Your Java Streams with Gatherers
43mStream Gatherers - Deep Dive with the Expert
45mStream Gatherers
46mJEP 461: Breathing New Life into Java Stream API
48mWe Are All Gathered — We Are All to Gather
52mThe Gatherer API: the tool that was missing in the Stream API
39mLevel Up Your Java Streams with Gatherers
51mHunting with Stream Gatherers
