diff options
author | Sean R. Owen <srowen@apache.org> | 2015-05-08 13:59:51 +0000 |
---|---|---|
committer | Sean R. Owen <srowen@apache.org> | 2015-05-08 13:59:51 +0000 |
commit | 090a6d74cea47ee2023e2f15aa207afe83194702 (patch) | |
tree | d9a77f60ec22facf4ea1740a0a50aee5804169aa /examples.md | |
parent | 89f7bb0ead0b91237b156377f12b0216347d5b75 (diff) | |
download | spark-website-090a6d74cea47ee2023e2f15aa207afe83194702.tar.gz spark-website-090a6d74cea47ee2023e2f15aa207afe83194702.tar.bz2 spark-website-090a6d74cea47ee2023e2f15aa207afe83194702.zip |
Reapply my past changes, which I had only applied to .html, to .md too, and add the changes from the regenerated .html too
Diffstat (limited to 'examples.md')
-rw-r--r-- | examples.md | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/examples.md b/examples.md index 3658d1788..18d869353 100644 --- a/examples.md +++ b/examples.md @@ -26,8 +26,8 @@ In this example, we search through the error messages in a log file: <div class="tab-content"> <div class="tab-pane tab-pane-python active"> <div class="code code-tab"> - file = spark.textFile(<span class="string">"hdfs://..."</span>)<br> - errors = file.<span class="sparkop">filter</span>(<span class="closure">lambda line: "ERROR" in line</span>)<br> + text_file = spark.textFile(<span class="string">"hdfs://..."</span>)<br /> + errors = text_file.<span class="sparkop">filter</span>(<span class="closure">lambda line: "ERROR" in line</span>)<br /> <span class="comment"># Count all the errors</span><br> errors.<span class="sparkop">count</span>()<br> <span class="comment"># Count errors mentioning MySQL</span><br> @@ -38,8 +38,8 @@ In this example, we search through the error messages in a log file: </div> <div class="tab-pane tab-pane-scala"> <div class="code code-tab"> - <span class="keyword">val</span> file = spark.textFile(<span class="string">"hdfs://..."</span>)<br> - <span class="keyword">val</span> errors = file.<span class="sparkop">filter</span>(<span class="closure">line => line.contains("ERROR")</span>)<br> + <span class="keyword">val</span> textFile = spark.textFile(<span class="string">"hdfs://..."</span>)<br> + <span class="keyword">val</span> errors = textFile.<span class="sparkop">filter</span>(<span class="closure">line => line.contains("ERROR")</span>)<br> <span class="comment">// Count all the errors</span><br> errors.<span class="sparkop">count</span>()<br> <span class="comment">// Count errors mentioning MySQL</span><br> @@ -50,8 +50,8 @@ In this example, we search through the error messages in a log file: </div> <div class="tab-pane tab-pane-java"> <div class="code code-tab"> - JavaRDD<String> file = spark.textFile(<span class="string">"hdfs://..."</span>);<br> - JavaRDD<String> errors = file.<span class="sparkop">filter</span>(<span class="closure">new Function<String, Boolean>() {<br> + JavaRDD<String> textFile = spark.textFile(<span class="string">"hdfs://..."</span>);<br> + JavaRDD<String> errors = textFile.<span class="sparkop">filter</span>(<span class="closure">new Function<String, Boolean>() {<br> public Boolean call(String s) { return s.contains("ERROR"); }<br> }</span>);<br> <span class="comment">// Count all the errors</span><br> @@ -112,8 +112,8 @@ In this example, we search through the error messages in a log file: <div class="tab-content"> <div class="tab-pane tab-pane-python active"> <div class="code code-tab"> - file = spark.textFile(<span class="string">"hdfs://..."</span>)<br> - counts = file.<span class="sparkop">flatMap</span>(<span class="closure">lambda line: line.split(" ")</span>) \<br> + text_file = spark.textFile(<span class="string">"hdfs://..."</span>)<br> + counts = text_file.<span class="sparkop">flatMap</span>(<span class="closure">lambda line: line.split(" ")</span>) \<br> .<span class="sparkop">map</span>(<span class="closure">lambda word: (word, 1)</span>) \<br> .<span class="sparkop">reduceByKey</span>(<span class="closure">lambda a, b: a + b</span>)<br> counts.<span class="sparkop">saveAsTextFile</span>(<span class="string">"hdfs://..."</span>) @@ -121,8 +121,8 @@ In this example, we search through the error messages in a log file: </div> <div class="tab-pane tab-pane-scala"> <div class="code code-tab"> - <span class="keyword">val</span> file = spark.textFile(<span class="string">"hdfs://..."</span>)<br> - <span class="keyword">val</span> counts = file.<span class="sparkop">flatMap</span>(<span class="closure">line => line.split(" ")</span>)<br> + <span class="keyword">val</span> textFile = spark.textFile(<span class="string">"hdfs://..."</span>)<br> + <span class="keyword">val</span> counts = textFile.<span class="sparkop">flatMap</span>(<span class="closure">line => line.split(" ")</span>)<br> .<span class="sparkop">map</span>(<span class="closure">word => (word, 1)</span>)<br> .<span class="sparkop">reduceByKey</span>(<span class="closure">_ + _</span>)<br> counts.<span class="sparkop">saveAsTextFile</span>(<span class="string">"hdfs://..."</span>) @@ -130,8 +130,8 @@ In this example, we search through the error messages in a log file: </div> <div class="tab-pane tab-pane-java"> <div class="code code-tab"> - JavaRDD<String> file = spark.textFile(<span class="string">"hdfs://..."</span>);<br> - JavaRDD<String> words = file.<span class="sparkop">flatMap</span>(<span class="closure">new FlatMapFunction<String, String>() {<br> + JavaRDD<String> textFile = spark.textFile(<span class="string">"hdfs://..."</span>);<br> + JavaRDD<String> words = textFile.<span class="sparkop">flatMap</span>(<span class="closure">new FlatMapFunction<String, String>() {<br> public Iterable<String> call(String s) { return Arrays.asList(s.split(" ")); }<br> }</span>);<br> JavaPairRDD<String, Integer> pairs = words.<span class="sparkop">mapToPair</span>(<span class="closure">new PairFunction<String, String, Integer>() {<br> |