Skip to content

Commit

Permalink
fixed typo of network_workdcount.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Takagiwa committed Jul 17, 2014
1 parent 4b7c08b commit e604fcb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/src/main/python/streaming/network_wordcount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
from operator import add

from pyspark.streaming.context import StreamingContext
from pyspark.streaming.duration import *

if __name__ == "__main__":
if len(sys.argv) != 3:
print >> sys.stderr, "Usage: wordcount <hostname> <port>"
exit(-1)
ssc = StreamingContext(appName="PythonStreamingNetworkWordCount", duration=Seconds(1))

lines = ssc.socketTextStream(sys.argv[1], int(sys.argv[2]))
fm_lines = lines.flatMap(lambda x: x.split(" "))
filtered_lines = fm_lines.filter(lambda line: "Spark" in line)
mapped_lines = fm_lines.map(lambda x: (x, 1))

fm_lines.pyprint()
filtered_lines.pyprint()
mapped_lines.pyprint()
ssc.start()
ssc.awaitTermination()

0 comments on commit e604fcb

Please sign in to comment.