...

Cloud Computing - RDD SPARK

Back to Course

Lesson Description


Lession - #1482 groupByKey Function


Spark groupByKey Function

In Spark, the groupByKey work is a regularly utilized change activity that performs rearranging of information. It gets key-esteem matches (K, V>
as an information, bunch the qualities in view of key and produces a dataset of (K, Iterable>
matches as a result.

Example of groupByKey function
In this example, we group the values based on the key.
  • To open the Spark in Scala mode, follow the below command.

$ spark-shell



  • create a RDD utilizing the parallelized assortment.

scala> val information = sc.parallelize(Seq(("C",3>
,("A",1>
,("B",4>
,("A",2>
,("B",5>
>
>

  • Presently, we can peruse the created outcome by utilizing the accompanying order.


scala> data.collect



  • Apply groupByKey(>
    capacity to bunch the qualities.

scala> val groupfunc = data.groupByKey(>

  • Presently, we can peruse the created outcome by utilizing the accompanying order.

scala> groupfunc.collect