【发布时间】:2016-07-27 01:24:54
【问题描述】:
我是 spark 及其相关概念的新手,所以请善待我并帮助我解决我的疑问,我会给你一个例子来帮助你理解我的问题。
我有一个 javaPairRDD "rdd",其中包含像这样的元组
Tuple2 <Integer,String[]>
让我们假设 String[].length =3,意味着它除了键之外还包含 3 个元素,我想要做的是使用 3 个 RDD 和 3 个操作“R1”和“operation1”更新向量的每个元素用于修改第一个元素,“R2”和“operation2”用于修改第二个元素,“R3”和“operation3”用于修改第三个元素,
R1、R2、R3是提供元素新值的RDD
我知道 spark 将数据(在这个例子中是“rdd”)分成许多分区,但我要问的是:是否可以在同一个分区中同时执行不同的操作?
根据我的例子,因为我有3个操作,这意味着我可以同时取3个元组而不是只取一个来操作它:
我想要的治疗是:(t指时间)
at t=0:
*tuple1=use operation1 to modify the element 1
*tuple2=use operation2 to modify the element2
*tuple3=use operation3 to modify the element 3
在 t=1:
*tuple1=use operation2 to modify the element 2
*tuple2=use operation3 to modify the element3
*tuple3=use operation1 to modify the element 1
在 t=2:
*tuple1=use operation.3 to modify the element 3
*tuple2=use operation1 to modify the element1
*tuple3=use operation2 to modify the element 2
完成更新前 3 个元组后,我从同一个分区中取出其他(3 个元组)来处理它们,依此类推..
请善待,这只是我脑海中闪过的一个想法,我想知道是否可以这样做,谢谢您的帮助
【问题讨论】:
-
看看
mapPartitions- 它可能对你有点帮助 -
我投了反对票,因为我认为您需要花更多时间阅读 spark 文档和概念。在这种状态下,这个问题在imo中几乎没有意义。
标签: java scala apache-spark key-value rdd