WEBVTT

00:00.320 --> 00:00.830
Hi everyone.

00:00.830 --> 00:02.060
Welcome back to this tutorial.

00:02.060 --> 00:09.050
In this tutorial we will code and explore the three argument version of grouping by So in the previous

00:09.050 --> 00:14.210
two tutorials we explored the one argument version and the two argument version.

00:14.210 --> 00:14.750
Right.

00:14.750 --> 00:17.150
Let's go ahead and explore the three argument version.

00:17.150 --> 00:21.740
Before I do that, I would like to explore what is happening with the two argument version.

00:21.770 --> 00:27.530
If we go and take a look at the two argument version, here we are passing the classifier and downstream.

00:27.530 --> 00:33.440
But internally what this does is it passes the third argument here.

00:33.440 --> 00:39.590
So the classifier is passed as a first argument and the HashMap knew this is a supplier which they are

00:39.590 --> 00:40.190
passing.

00:40.190 --> 00:48.350
So the output is always going to be HashMap because here they are performing this internally.

00:48.380 --> 00:54.290
So what we are going to do is we are going to override this and then pass the supplier from our end.

00:54.320 --> 00:59.750
That's what we are going to do as part of the three argument version of grouping by.

01:03.810 --> 01:06.960
That's going to be public static.

01:07.780 --> 01:08.380
Wide.

01:10.080 --> 01:11.640
Three argument.

01:13.530 --> 01:14.310
Group by.

01:15.970 --> 01:17.680
And in here it accepts.

01:17.680 --> 01:24.040
It accepts student database dot get all students dot stream.

01:24.160 --> 01:27.220
And then we're going to call the collect method.

01:27.220 --> 01:33.550
In the collect method, we're going to perform the group by of name.

01:33.550 --> 01:35.110
I'm going to copy this from here.

01:35.110 --> 01:40.380
That is the first argument, which is a classifier and followed by that what are we going to do?

01:40.390 --> 01:46.270
We are going to use the linked hash map, colon, colon, new, that is a supplier.

01:46.270 --> 01:52.330
And the third one is going to be we are going to use the another collector, which is going to be to

01:52.360 --> 01:53.980
set because we have seen.

01:56.530 --> 02:02.590
We have seen lists throughout all these examples, but here we are going to override that and then use

02:02.590 --> 02:04.870
to set as a collector.

02:04.870 --> 02:06.850
So what is the output?

02:06.850 --> 02:11.080
It is going to be linked hash map and the key, what is a key?

02:11.080 --> 02:14.770
The key is going to be the name.

02:15.920 --> 02:17.540
It is of type string.

02:17.540 --> 02:22.820
And then this is going to be set of student.

02:24.890 --> 02:26.200
So let's give it a name.

02:26.210 --> 02:27.890
Let's import the set here.

02:29.550 --> 02:33.720
The name is going to be student.

02:35.330 --> 02:36.800
Linked hash map.

02:39.050 --> 02:39.260
Good.

02:40.040 --> 02:40.610
There you go.

02:40.810 --> 02:42.110
Then I'm going to print this.

02:45.310 --> 02:47.330
And let's revisit this again.

02:47.350 --> 02:49.540
The first one determines the key here.

02:49.540 --> 02:52.510
The second parameter determines the output.

02:52.540 --> 02:57.790
What kind of output it is, what kind of connection it is going to return.

02:57.790 --> 03:05.170
And this two set determines what is a value for the output that it is going to generate.

03:05.500 --> 03:09.520
Let's run this example and then validate the result.

03:11.280 --> 03:12.270
Let's run this.

03:12.640 --> 03:16.380
Going to have a name and their student as a.

03:17.870 --> 03:18.440
Value.

03:18.440 --> 03:21.590
So Adam and the whole student object mapped out.

03:21.740 --> 03:23.540
Jenny And the whole student.

03:23.570 --> 03:24.650
Object mapped to it.

03:25.190 --> 03:30.200
So this is all about the three argument version of grouping by.

03:30.230 --> 03:32.340
But this we came to the end of this tutorial.

03:32.360 --> 03:33.590
Thank you for watching.
