在RDD斯卡拉地图功能 [英] Scala map function over RDD

查看:132
本文介绍了在RDD斯卡拉地图功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在RDD以下结构

((字符串,字符串)(INT,INT)),我想映射到(字符串,字符串,INT,INT)

rdd.map((a, b) => "%s|%s|%s|%s".format(a._1, a._2, b._1, b._2))

我收到以下错误:
 错误:错误的参数数量;预计= 1

I get the following error: error: wrong number of parameters; expected = 1

我也试过,但得到编译错误。

I also tried, but got compilation error.

rdd.map((a), (b)) => "%s|%s|%s|%s".format(a._1, a._2, b._1, b._2))

rdd.map((tuple1._1, tuple1._2), (tuple2._1, tuple2._2)) => "%s|%s|%s|%s".format(tuple1._1, tuple1._2, tuple2._1, tuple2._2))

将是巨大的得到一些帮助。

Would be great to get some help on this.

推荐答案

不知道为什么你想使一个字符串,但我认为这是你想要的
rdd.map {案((A,B),(C,D))=> (A,B,C,D))} 。斯卡拉提取物规则!!

Not sure why you're trying to make a string, but I think this is what you want rdd.map{case ((a,b),(c,d)) => (a,b,c,d))}. Scala extractor objects rule!!

这篇关于在RDD斯卡拉地图功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆