File tree Expand file tree Collapse file tree 4 files changed +29
-8
lines changed
examples/src/main/python/streaming Expand file tree Collapse file tree 4 files changed +29
-8
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
2
3
- from pyspark . streaming . context import StreamingContext
4
- from pyspark .streaming . duration import *
3
+ from pyspark import SparkContext
4
+ from pyspark .streaming import StreamingContext
5
5
6
6
if __name__ == "__main__" :
7
7
if len (sys .argv ) != 3 :
8
8
print >> sys .stderr , "Usage: wordcount <hostname> <port>"
9
9
exit (- 1 )
10
- ssc = StreamingContext (appName = "PythonStreamingNetworkWordCount" ,
11
- duration = Seconds ( 1 ) )
10
+ sc = SparkContext (appName = "PythonStreamingNetworkWordCount" )
11
+ ssc = StreamingContext ( sc , 1 )
12
12
13
13
lines = ssc .socketTextStream (sys .argv [1 ], int (sys .argv [2 ]))
14
14
counts = lines .flatMap (lambda line : line .split (" " ))\
Original file line number Diff line number Diff line change 1
1
import sys
2
2
3
- from pyspark . streaming . context import StreamingContext
4
- from pyspark .streaming . duration import *
3
+ from pyspark import SparkContext
4
+ from pyspark .streaming import StreamingContext
5
5
6
6
if __name__ == "__main__" :
7
7
if len (sys .argv ) != 2 :
8
8
print >> sys .stderr , "Usage: wordcount <directory>"
9
9
exit (- 1 )
10
10
11
- ssc = StreamingContext (appName = "PythonStreamingWordCount" ,
12
- duration = Seconds ( 1 ) )
11
+ sc = SparkContext (appName = "PythonStreamingWordCount" )
12
+ ssc = StreamingContext ( sc , 1 )
13
13
14
14
lines = ssc .textFileStream (sys .argv [1 ])
15
15
counts = lines .flatMap (lambda line : line .split (" " ))\
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 22
22
23
23
from py4j .java_collections import ListConverter
24
24
25
+ __all__ = ["StreamingContext" ]
26
+
25
27
26
28
class StreamingContext (object ):
27
29
"""
You can’t perform that action at this time.
0 commit comments