Spark性能优化之foreach与foreachPartition

首先,我们对比一下foreachPartition和foreach两个方法的实现,有什么不同的地方: 123456789def foreach(f: T => Unit): Unit = withScope { val cleanF = sc.clean(f) sc.runJob(this, (iter: Iterator[T]) => iter.foreach(cleanF))}def foreachPartition(f: Iterator[T] => Unit): Unit = withScope { val cleanF = sc.clean(f) sc.runJob(this, (iter: Iterator[T]) => cleanF(iter))}

BigData

站内搜索

没有找到内容!