WEBVTT

00:00.760 --> 00:01.400
Hi everyone.

00:01.400 --> 00:01.960
Welcome back.

00:01.960 --> 00:08.400
In this lecture we will go and learn about how to combine multiple gatherers together and execute a

00:08.400 --> 00:09.920
business functionality.

00:10.080 --> 00:11.760
So here is a use case.

00:12.000 --> 00:17.600
The first step is we would like to filter the movies that have a rating greater than eight, and then

00:17.600 --> 00:24.080
group the filtered results with a window size of two, and have this logic as part of gatherer one.

00:24.080 --> 00:26.080
So that is the first part of the logic.

00:26.120 --> 00:32.400
The next thing is we need to calculate the average of each window using the scan operation.

00:32.400 --> 00:35.200
So we are going to combine these two gatherers.

00:35.200 --> 00:39.960
And the concept of combining these two gatherers is called a composite gatherer.

00:40.000 --> 00:42.520
Let's go back to the code and start coding this one.

00:42.520 --> 00:43.920
So there you go I'm back in the code.

00:43.920 --> 00:47.240
So what I'm going to do is I'm going to comment out these two things.

00:47.440 --> 00:50.120
And I have this demonstrate composite gatherers.

00:50.120 --> 00:53.040
So if we go here so this is what the code is.

00:53.040 --> 00:54.200
It is an empty function.

00:54.760 --> 00:59.880
So now what I'm going to leverage is that I'm going to leverage the a coding assistant since we have

00:59.950 --> 01:07.710
already explored the windows fixed and scan operation using stream gatherers, I'm going to use the

01:07.830 --> 01:09.470
prompt to make the changes for me.

01:09.470 --> 01:14.830
So I'm going to go back to the Stream Gatherers demo and you will have something called The Composite

01:14.830 --> 01:15.510
Gatherers.

01:15.670 --> 01:16.950
Let's go to that one.

01:16.950 --> 01:23.190
And in here we can see that it says like create a method demonstrating how to combine multiple gatherer

01:23.190 --> 01:25.070
operations in sequence.

01:25.070 --> 01:27.030
So this is the input for that function.

01:27.230 --> 01:29.630
And we are printing the section header.

01:29.990 --> 01:31.430
And the first gatherer.

01:31.430 --> 01:33.110
As you can see this is our code.

01:33.110 --> 01:34.190
This is a filter.

01:34.230 --> 01:39.190
High rated movies and group the filtered movies into fixed windows of size two.

01:39.230 --> 01:41.350
So that's what we are saying over here.

01:41.350 --> 01:44.870
So filter the movie and then group them by a windows of two.

01:44.910 --> 01:49.590
And then apply scanning to calculate average duration.

01:49.630 --> 01:49.830
Right.

01:49.870 --> 01:51.950
So we know this scanning operator.

01:52.190 --> 01:57.070
This produces the intermediate results after each accumulation of results.

01:57.070 --> 02:03.150
And then display the average duration in this format, which is high rated movie window, average duration,

02:03.150 --> 02:04.630
which is this and this minutes.

02:04.790 --> 02:12.510
So what we'll do is we'll copy this prompt, and then we are going to be creating a new chat and then

02:12.550 --> 02:13.590
ask you to create it for me.

02:13.590 --> 02:17.990
And the model that I'm using is called sonnet 4.5 and agent mode.

02:18.030 --> 02:20.630
If you don't have this model, use the other models.

02:20.630 --> 02:24.830
You are welcome to try it out, but different module produces different results.

02:24.830 --> 02:27.870
So I'm expecting the code changes to be done over here.

02:27.910 --> 02:29.710
Now let's go ahead and press enter.

02:29.710 --> 02:31.990
So it is first reading the movie Java.

02:32.630 --> 02:37.430
And then it's going to be implementing the demonstrate composite gatherers.

02:37.670 --> 02:41.750
So basically it is able to identify the function where it's going to make the change.

02:41.750 --> 02:44.390
And it's going to edit the changes for us.

02:49.270 --> 02:49.710
There you go.

02:49.710 --> 02:50.830
It made the change for me.

02:50.830 --> 02:56.590
So here we have a gather on the top which takes care of actually applying the filtered movies which

02:56.590 --> 03:01.540
are of greater than 8.0 and grouped them into window size of two.

03:01.740 --> 03:07.420
And then we have the scan operation, where once the results are grouped, it's going to be computing

03:07.420 --> 03:11.140
the average duration and then printing the results in the console.

03:11.140 --> 03:16.460
So this is the beauty of using gatherers and combining them in your whole code logic.

03:16.500 --> 03:17.900
So if we take a look at the code.

03:17.940 --> 03:20.100
So this is how the code looks like.

03:20.140 --> 03:28.740
And we created this whole code logic, writing almost 10 to 15 lines of code by just prompting, okay,

03:28.780 --> 03:31.660
so now what I'm going to do, I'm going to be running this code.

03:31.660 --> 03:34.380
So it has the ability to run the code also for you.

03:34.420 --> 03:35.860
Click on continue over here.

03:36.020 --> 03:37.460
Now what this is going to do.

03:37.660 --> 03:39.900
This is going to be running the program for you.

03:39.900 --> 03:42.660
As you can see, you don't have to go and click on the run button.

03:42.660 --> 03:46.300
You can actually run the program also directly from the console.

03:46.300 --> 03:50.060
But I believe this needs to be changed to Java 25.

03:50.100 --> 03:52.580
Let me see what is a Java version that I'm using?

03:52.740 --> 03:54.100
Okay, I'm using Java 25.

03:54.100 --> 03:56.460
For some reason it gave me an error.

03:56.460 --> 03:59.650
So what I'm going to do, I'm going to ask you to look into this error.

03:59.650 --> 04:01.170
So I'm going to pass this error back.

04:01.450 --> 04:04.570
Or it might be already trying to do some other activity here.

04:04.570 --> 04:07.890
So if you go here so let's compile and run the code directly.

04:07.890 --> 04:09.130
Let's give it a try one more time.

04:09.130 --> 04:12.730
If it doesn't work then we will go ahead and manually execute the program.

04:12.730 --> 04:14.410
I'm going to continue okay.

04:14.450 --> 04:16.210
So now it compile the program.

04:16.370 --> 04:20.170
The next step is to run the compiled stream demo class.

04:20.210 --> 04:24.130
To test the Demonstrate Composite Gatherers method click on continue.

04:24.370 --> 04:25.970
So now you can see that right.

04:26.010 --> 04:29.410
We were able to run the actual code directly over here.

04:29.410 --> 04:29.930
So there you go.

04:29.970 --> 04:32.650
This is a composite gatherers chaining operation.

04:32.890 --> 04:37.210
And it gave you that high rated movie average duration.

04:37.210 --> 04:38.130
That's over here.

04:38.130 --> 04:44.850
So this is again you have the ability to create the program, execute the program and test the result

04:44.850 --> 04:47.370
directly from our AI coding assistant.

04:47.370 --> 04:50.210
So it said that perfect the implementation is working correctly.

04:50.210 --> 04:53.010
Let me verify the output to ensure everything meets the requirement.

04:53.010 --> 04:54.250
So let's continue this.

04:54.250 --> 04:58.450
So it's going to actually look into the console and then validate the result.

04:58.450 --> 05:04.050
So now it actually looked into the console, gathered the result, and then finally the agent also showed

05:04.050 --> 05:04.730
up over here.

05:04.730 --> 05:08.410
That means that this is the output that's been shown in the console.

05:08.410 --> 05:14.890
And this implementation successfully demonstrate how multiple gather operations can be chained together

05:14.890 --> 05:18.050
to create a sophisticated data processing pipelines.

05:18.050 --> 05:24.370
So this is a lecture where we completely leveraged the AI coding assistant to write the logic for us.

05:24.690 --> 05:29.650
All we did was we started with the prompt, and then we were able to execute the prompt.

05:29.650 --> 05:37.210
And also we were able to successfully implement the logic, validate the logic by running the code through

05:37.210 --> 05:38.210
the AI assistant.

05:38.730 --> 05:45.610
So this is a power of this AI coding assistant where you can actually instruct and watch the code changes

05:45.610 --> 05:46.570
that's been made.

05:46.610 --> 05:52.810
If the code looks good, then you approve and ship the feature as a deliverable in your application.

05:52.810 --> 05:54.330
Well, this marks the end of this lecture.

05:54.490 --> 05:55.530
Thank you for watching.
