Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- show_views_file = sc.textFile("input/join2_gennum?.txt")
- show_views_file.take(2)
- def split_show_views(line):
- #<INSERT_CODE_HERE_1>
- show, views = line.split(',')
- views = int(views)
- #
- return (show, views)
- # map 2
- show_views = show_views_file.map(split_show_views)
- #check
- show_views.collect()
- show_channel_file = sc.textFile("input/join2_genchan?.txt")
- def split_show_channel(line):
- #<INSERT_CODE_HERE 3>
- show, channel = line.split(',')
- #
- return (show, channel)
- #filter =='BAT' 4
- show_channel = show_channel_file.map(split_show_channel)
- # join 5
- joined_dataset = show_channel.join(show_views)
- def extract_channel_views(show_views_channel):
- # 6
- channel = show_views_channel[1][0]
- views = int(show_views_channel[1][1])
- #
- return (channel, views)
- #map 7
- channel_views = joined_dataset.map(extract_channel_views)
- def some_function(a, b):
- # 8
- some_result = a + b
- #
- return some_result
- # 9
- channel_views.reduceByKey(some_function).collect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement