You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by "ashish.usoni" <as...@gmail.com> on 2015/03/24 18:31:13 UTC
CombineByKey - Please explain its working
I am reading about combinebyKey and going through below example from one of
the blog post but i cant understand how it works step by step , Can some one
please explain
Case class Fruit ( kind : String , weight : Int ) {
def makeJuice : Juice = Juice ( weight * 100 )
}
Case class Juice ( volumn : Int ) {
def add ( J : Juice ) : Juice = Juice ( volumn + J . volumn )
}
Val apple1 = Fruit ( "Apple" , 5 )
Val Apple2 = Fruit ( "Apple" , 8 )
Val orange1 = Fruit ( "orange" , 10 )
Val Fruit = sc . Parallelize ( List (( "Apple" , apple1 ) , ( "orange"
, orange1 ) , ( "Apple" , Apple2 )))
*Val Juice = Fruit . combineByKey (
f => f . makeJuice ,
( J : Juice , f ) => J . add ( f . makeJuice ),
( J1 : Juice , J2 : Juice ) => J1 . add ( J2 )
)*
--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/CombineByKey-Please-explain-its-working-tp22203.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org