Spark Java: GroupByKey(Function1<Row,K>func, Encoder<K>) dataset example

I am new to spark. I am trying to use groupByKey on a dataSet. But seems like there are not many examples of how to use that method. For example: I have DataSet. The dataSet contain jsons read from a file. Now I will want to convert the DataSet to Map>. For that, I am trying to use GroupByKey. But, I am not understanding the parameters passed to groupbyKey. It would be of great help if someone can provide me with an example.