aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/programming-guide.md17
1 files changed, 10 insertions, 7 deletions
diff --git a/docs/programming-guide.md b/docs/programming-guide.md
index 7b07018288..b5e04bd0c6 100644
--- a/docs/programming-guide.md
+++ b/docs/programming-guide.md
@@ -1336,25 +1336,28 @@ Accumulators do not change the lazy evaluation model of Spark. If they are being
<div data-lang="scala" markdown="1">
{% highlight scala %}
-val acc = sc.accumulator(0)
-data.map(x => acc += x; f(x))
-// Here, acc is still 0 because no actions have cause the `map` to be computed.
+val accum = sc.accumulator(0)
+data.map { x => accum += x; f(x) }
+// Here, accum is still 0 because no actions have caused the `map` to be computed.
{% endhighlight %}
</div>
<div data-lang="java" markdown="1">
{% highlight java %}
Accumulator<Integer> accum = sc.accumulator(0);
-data.map(x -> accum.add(x); f(x););
-// Here, accum is still 0 because no actions have cause the `map` to be computed.
+data.map(x -> { accum.add(x); return f(x); });
+// Here, accum is still 0 because no actions have caused the `map` to be computed.
{% endhighlight %}
</div>
<div data-lang="python" markdown="1">
{% highlight python %}
accum = sc.accumulator(0)
-data.map(lambda x => acc.add(x); f(x))
-# Here, acc is still 0 because no actions have cause the `map` to be computed.
+def g(x):
+ accum.add(x)
+ return f(x)
+data.map(g)
+# Here, accum is still 0 because no actions have caused the `map` to be computed.
{% endhighlight %}
</div>