如何打印星火特别RDD分区的要素是什么? [英] How to print elements of particular RDD partition in Spark?
本文介绍了如何打印星火特别RDD分区的要素是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何打印特定分区的元素,比方说5,一个人吗?
VAL distData = sc.parallelize(1到50,10)
解决方案
使用星火/斯卡拉:
VAL数据= 1到50
VAL distData = sc.parallelize(数据,10)
distData.mapPartitionsWithIndex((索引:诠释,它:迭代器[INT])=> it.toList.map(X =>如果(指数== 5){的println(X)})迭代器).collect
生产:
26
27
28
29
三十
How to print the elements of a particular partition, say 5th, alone?
val distData = sc.parallelize(1 to 50, 10)
解决方案
Using Spark/Scala:
val data = 1 to 50
val distData = sc.parallelize(data,10)
distData.mapPartitionsWithIndex( (index: Int, it: Iterator[Int]) =>it.toList.map(x => if (index ==5) {println(x)}).iterator).collect
produces:
26
27
28
29
30
这篇关于如何打印星火特别RDD分区的要素是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文