是否可以在Python中廣播RDD?如何在PySpark中廣播RDD?
我正在關注「高級分析與Spark:規模化數據學習模式」一書,第3章需要廣播RDD。我試圖用Python代替Scala來追蹤這些例子。
無論如何,就算在這個簡單的例子我有一個錯誤:
my_list = ["a", "d", "c", "b"]
my_list_rdd = sc.parallelize(my_list)
sc.broadcast(my_list_rdd)
錯誤時正在:
"It appears that you are attempting to broadcast an RDD or reference an RDD from an "
Exception: It appears that you are attempting to broadcast an RDD or reference an RDD from an
action or transformation. RDD transformations and actions can only be invoked by the driver, n
ot inside of other transformations; for example, rdd1.map(lambda x: rdd2.values.count() * x) i
s invalid because the values transformation and count action cannot be performed inside of the
rdd1.map transformation. For more information, see SPARK-5063.
我真的不明白什麼是「行動或改造」錯誤是指至。我正在使用spark-2.1.1-hadoop2.7
。
重要編輯:這本書是正確的。我只是沒有看到它不是正在播放的RDD,而是通過collectAsMap()獲得的地圖版本。
謝謝!
很好的答案,但對於使用大型RDD收集警告,特別是針對新用戶的警告總是必不可少的。 – eliasah