Skip to content

Commit bd13026

Browse files
committed
fix examples
1 parent eec401e commit bd13026

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import sys
22

3-
from pyspark.streaming.context import StreamingContext
4-
from pyspark.streaming.duration import *
3+
from pyspark import SparkContext
4+
from pyspark.streaming import StreamingContext
55

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

1313
lines = ssc.socketTextStream(sys.argv[1], int(sys.argv[2]))
1414
counts = lines.flatMap(lambda line: line.split(" "))\

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import sys
22

3-
from pyspark.streaming.context import StreamingContext
4-
from pyspark.streaming.duration import *
3+
from pyspark import SparkContext
4+
from pyspark.streaming import StreamingContext
55

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

11-
ssc = StreamingContext(appName="PythonStreamingWordCount",
12-
duration=Seconds(1))
11+
sc = SparkContext(appName="PythonStreamingWordCount")
12+
ssc = StreamingContext(sc, 1)
1313

1414
lines = ssc.textFileStream(sys.argv[1])
1515
counts = lines.flatMap(lambda line: line.split(" "))\

python/pyspark/streaming/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
from pyspark.streaming.context import StreamingContext
19+
from pyspark.streaming.dstream import DStream

python/pyspark/streaming/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
from py4j.java_collections import ListConverter
2424

25+
__all__ = ["StreamingContext"]
26+
2527

2628
class StreamingContext(object):
2729
"""

0 commit comments

Comments
 (0)