Skip to content

Commit eea16a7

Browse files
author
Davies Liu
committed
refactor
1 parent f6ce899 commit eea16a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/src/main/python/streaming/kafka_wordcount.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@
4545
ssc = StreamingContext(sc, 1)
4646

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

0 commit comments

Comments
 (0)