How to add the keys and values separately from the keys and value pairs generated in spark scala?
Given the following input
(5,1),(6,1),(8,1)
I'd like to get to the following output
(19,3)
This is what I've tried so far:
val spark = SparkSession.builder.appName("myapp").getOrCreate()
val data = spark.read.textFile(args(0)).rdd
val result =
data.map { line => {
val tokens = line.split("\t")
(Float.parseFloat(tokens(4)),1)
}}.
reduceByKey( _+ _)