我是新来的火花。我在这里提到我的代码,我不确定它是怎么回事。
val file = context.textFile("testing2.txt")
val mapped = file.map(x => (x.length,x))
val com = mapped.combineByKey(
(v : String) => (v,1),
(acc : (String,Int),v) => (acc._1+v,acc._2+1),
(acc1 : (String,Int), acc2 : (String,Int)) => (acc1._1+acc2._1)
)