1
SparkのmapPartitionsWithIndex
を理解しようとしています。強調表示され、差がショー機能発生器またはイテレータを返すかどうかにあるようmapPartitionsWithIndex - 出力の合成方法
parallel = sc.parallelize(range(1,10),2)
def show(index, iterator): yield 'index: '+str(index)+" values: "+
str(list(iterator))
parallel.mapPartitionsWithIndex(show).collect()
parallel = sc.parallelize(range(1,10),2)
def show(index, iterator): return 'index: '+str(index)+" values: "+
str(list(iterator))
parallel.mapPartitionsWithIndex(show).collect()
:私は、以下の2つの例は、非常に異なる出力を生成することを見出しました。
私はmapPartitionsWithIndex
がどのように個々のパーティションからの結果を組み合わせるのか分かりません。
この現象がどのように発生するか教えてください。