Hunting with Stream Gatherers
summary
Java 24 adds Stream Gatherers as a real extension point to replace collector-only hacks and clumsy intermediate workarounds: an integrator-driven API with supplier/combiner/finisher lets code emit zero‑to‑N elements, suspend, short‑circuit and keep state. Demos include a unique-by-length gatherer replacing nested collectors, sliding/fixed windows and an n‑gram generator that matches Elasticsearch tokenization, plus gather-map-concurrent that uses virtual threads to handle 100 concurrent IO tasks in ≈1s instead of 9s on a 12‑core machine.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:48Upgrading to Java 24
- 5:02Java 8 streams limits
- 10:18Problem with collectors
- 17:19Stream gatherers solution
- 20:54Stream gatherers in Java 24
- 23:44Gatherer interface
- 26:34Built-in gatherers use cases
- 29:02Windowing and palindromes
- 34:39Concurrent mapping with threads
- 39:16N-gram tokenizer
- 43:15Closing
related talks
51mHunting with Stream Gatherers
40mStream Gathers - The biggest change to Java Streams since 10 years
45mStream Gatherers
43mStream Gatherers - Deep Dive with the Expert
44mLevel Up Your Java Streams with Gatherers
48mWe Are All Gathered — We Are All to Gather
52mThe Gatherer API: the tool that was missing in the Stream API
46mJEP 461: Breathing New Life into Java Stream API
