Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed Sep 26, 2014
1 parent eec401e commit bd13026
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
8 changes: 4 additions & 4 deletions examples/src/main/python/streaming/network_wordcount.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys

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

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

lines = ssc.socketTextStream(sys.argv[1], int(sys.argv[2]))
counts = lines.flatMap(lambda line: line.split(" "))\
Expand Down
8 changes: 4 additions & 4 deletions examples/src/main/python/streaming/wordcount.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import sys

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

if __name__ == "__main__":
if len(sys.argv) != 2:
print >> sys.stderr, "Usage: wordcount <directory>"
exit(-1)

ssc = StreamingContext(appName="PythonStreamingWordCount",
duration=Seconds(1))
sc = SparkContext(appName="PythonStreamingWordCount")
ssc = StreamingContext(sc, 1)

lines = ssc.textFileStream(sys.argv[1])
counts = lines.flatMap(lambda line: line.split(" "))\
Expand Down
19 changes: 19 additions & 0 deletions python/pyspark/streaming/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from pyspark.streaming.context import StreamingContext
from pyspark.streaming.dstream import DStream
2 changes: 2 additions & 0 deletions python/pyspark/streaming/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from py4j.java_collections import ListConverter

__all__ = ["StreamingContext"]


class StreamingContext(object):
"""
Expand Down

0 comments on commit bd13026

Please sign in to comment.