【发布时间】:2021-08-20 08:01:07
【问题描述】:
我想使用reducebykey,但是当我尝试使用它时,它显示错误:
type miss match required Nothing
问题:如何为reducebykey 创建自定义函数?
{(键,值)}
键:字符串 值:地图
示例:
rdd = {("a", "weight"->1), ("a", "weight"->2)}
expect{("a"->3)}
def combine(x: mutable.map[string,Int],y:mutable.map[string,Int]):mutable.map[String,Int]={
x.weight = x.weithg+y.weight
x
}
rdd.reducebykey((x,y)=>combine(x,y))
【问题讨论】:
标签: scala apache-spark