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 11import 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
66if __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 (" " ))\
Original file line number Diff line number Diff line change 11import 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
66if __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 (" " ))\
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 2222
2323from py4j .java_collections import ListConverter
2424
25+ __all__ = ["StreamingContext" ]
26+
2527
2628class StreamingContext (object ):
2729 """
You can’t perform that action at this time.
0 commit comments