Re: How to calculate average from multiple values

2015-09-17 Thread diplomatic Guru
Hi Robin, You are a star! Thank you for the explanation and example. I converted your code into Java without any hassle. It is working as I expected. I carried out the final calculation (5th/6th) using mapValues and it is working nicely. But I was wondering is there a better way to do it other

How to calculate average from multiple values

2015-09-16 Thread diplomatic Guru
have a mapper that emit key/value pairs(composite keys and composite values separated by comma). e.g *key:* a,b,c,d *Value:* 1,2,3,4,5 *key:* a1,b1,c1,d1 *Value:* 5,4,3,2,1 ... ... *key:* a,b,c,d *Value:* 5,4,3,2,1 I could easily SUM these values using reduceByKey. e.g. reduceByKey(new