Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/830#discussion_r12822300
--- Diff: docs/streaming-programming-guide.md ---
@@ -105,23 +104,22 @@ generating multiple new records from each record in
the source DStream. In this
each line will be split into multiple words and the stream of words is
represented as the
`words` DStream. Next, we want to count these words.
+The `words` DStream is further mapped (one-to-one transformation) to a
DStream of `(word,
+1)` pairs, which is then reduced to get the frequency of words in each
batch of data.
+Finally, `wordCounts.print()` will print the first ten counts generated
every second.
+
{% highlight scala %}
-import org.apache.spark.streaming.StreamingContext._
// Count each word in each batch
-val pairs = words.map(word => (word, 1))
-val wordCounts = pairs.reduceByKey(_ + _)
+val pairs: DStream[(String, Int)] = words.map((_, 1))
--- End diff --
Same as above.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---