如何使用mapPartition执行涉及执行程序内部的rdd的操作?

时间:2018-05-17 21:23:30

标签: scala apache-spark

我想做那样的事情:

val myBigRdd2: RDD[_] = ???
myBigRdd1.mapPartition{ dataBlock => 
    // operation involving dataBlock and an other RDD
    // like myBigRdd2.multiply(dataBlock) 
    // if myBigRdd2 is a matrix. Or something similar.
}

有没有办法给执行者一个RDD?

我认为Broadcast rdd2上的collect不会起作用,因为它太大了。

grouped上执行rdd1cartesian会因为驱动程序内存爆炸而无法正常工作。

还有其他方法吗?

library(data.table) myID <- c(1,1,1,1,1,1,2,2,2,2,2,2) BST <- c("2017-06-01 00:00:01", "2017-06-01 00:00:02", "2017-06-02 00:00:01", "2017-06-02 00:00:02", "2017-06-03 00:00:01", "2017-06-03 00:00:02", "2017-06-01 00:00:01", "2017-06-01 00:00:02", "2017-06-03 00:00:01", "2017-06-03 00:00:02", "2017-06-05 00:00:01", "2017-06-05 00:00:02") V3 <- c("a", "a", "a", "a", "a", "a", "b", "b", "b","b", "b", "b") dt1 <- data.table(myID, BST, V3) 工作但需要永远。

1 个答案:

答案 0 :(得分:0)

您无法将RDD传递给mapPartition,因为这是仅为驱动程序所知的结构。执行者不能使用RDD结构。