I am running the below code and getting error message as : Cannot use map-side combining with array keys for the code
val lines = sc.textFile("../book.txt")
val line = lines.Map(x => (x.split(" ")))
val tense = line.map(x => (x,1)).reduceByKey((x,y) => x + y)
tense.foreach(println)
But when I use flatMap instead of map in line 2 it works perfectly. Why?