Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Davies Liu committed Jan 8, 2015
1 parent f6ce899 commit eea16a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/src/main/python/streaming/kafka_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
ssc = StreamingContext(sc, 1)

zkQuorum, topic = sys.argv[1:]
lines = KafkaUtils.createStream(ssc, zkQuorum, "spark-streaming-consumer", {topic: 1})
counts = lines.map(lambda x: x[1]).flatMap(lambda line: line.split(" ")) \
kvs = KafkaUtils.createStream(ssc, zkQuorum, "spark-streaming-consumer", {topic: 1})
lines = kvs.map(lambda x: x[1])
counts = lines.flatMap(lambda line: line.split(" ")) \
.map(lambda word: (word, 1)) \
.reduceByKey(lambda a, b: a+b)
counts.pprint()
Expand Down

0 comments on commit eea16a7

Please sign in to comment.