Why are aggregate and fold two different APIs in Spark?
问题 When using the Scala standard lib, I can do somthing like this: scala> val scalaList = List(1,2,3) scalaList: List[Int] = List(1, 2, 3) scala> scalaList.foldLeft(0)((acc,n)=>acc+n) res0: Int = 6 Making one Int out of many Ints. And I can do something like this: scala> scalaList.foldLeft("")((acc,n)=>acc+n.toString) res1: String = 123 Making one String out of many Ints. So, foldLeft could be either homogeneous or heterogeneous, whichever we want, it's in one API. While in Spark, if I want one