Created
July 24, 2016 23:00
-
-
Save Krasnyanskiy/7289cc1beca9c5725b1b0d4b43e3c8d4 to your computer and use it in GitHub Desktop.
-scala: spark: accumulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val acc = sc.accumulator(0) | |
sc.parallelize(Seq(1, 2, 3)).map(acc += _).count() // count to start computation and increment accumulator | |
println(acc.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
foreach
instead ofmap