Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Deep Dive into Gatherers - JEP Cafe 24

Java via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Explore the comprehensive capabilities of Gatherers, a powerful new feature added to JDK 24 and available in JDK 25 for business applications. Master the fundamentals of mapping and filtering operations while learning to create and manage internal mutable states for stream limitation and sorting. Discover proper techniques for interrupting streams when necessary and avoid common pitfalls like resource leaking and race conditions when using the API. Learn to leverage performance optimizations by declaring integrators as greedy when appropriate. Understand how to implement parallel Gatherers and use non-parallel Gatherers effectively within parallel streams. Gain hands-on experience writing various types of Gatherers including mapping, filtering, flat-mapping, skipping, limiting, distinct, and sorting implementations. Learn to work with the Downstream object, handle rejecting states, ensure thread safety, and properly close streams. Explore advanced topics such as using Finishers with TreeSet implementations, creating parallel Gatherers with Combiners, chaining Gatherers with the andThen() method, and utilizing the mapConcurrent() factory method. By the end of this comprehensive tutorial, develop the expertise to write efficient and correct Gatherers while understanding when to use them and when alternative approaches are more appropriate.

Syllabus

00:00 Intro
01:22 Modeling intermediate operations with Gatherers
04:36 Gatherer interface, gather method and Gatherers factor class
05:43 Writing a mapping Gatherer
10:14 Writing a filtering Gatherer
11:50 Writing a first, simple, but buggy flat-mapper
13:12 Exploring the Downstream object
16:28 Checking the rejecting state of a Downstream
18:45 Warning about the non-thread safety of Downstream
20:07 Checking the rejecting state for each push in the flat-mapping Gatherer
22:38 Closing properly your stream in the flat-mapping Gatherer
24:00 Fixing the race condition in the flat-mapping Gatherer
25:16 Protecing the flat-mapping Gatherer against NullPointerException
26:05 Writing a skipping Gatherer with an internal mutable state
29:21 Writing a limiting Gatherer
29:40 Writing a distinct Gatherer with an internal HashSet
30:30 Declaring the distinct Gatherer a Greedy Gatherer
32:26 Writing a sorting Gatherer with an internal TreeSet and a Finisher
35:06 Checking the rejecting state of a Downstream in a Finisher
36:53 Using a sequential Gatherer in a parallel stream
40:59 Creating parallel Gatherers with an internal state and a Combiner
44:24 Chaining Gatherer with the andThen method
45:45 Using mapConcurrent from the Gatherers factory class
49:12 That's it for today, talk to you soon!

Taught by

Java

Reviews

Start your review of Deep Dive into Gatherers - JEP Cafe 24

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.