Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. show_views_file = sc.textFile("input/join2_gennum?.txt")
  2.  
  3. show_views_file.take(2)
  4.  
  5. def split_show_views(line):
  6. #<INSERT_CODE_HERE_1>
  7. show, views = line.split(',')
  8. views = int(views)
  9. #
  10. return (show, views)
  11.  
  12. # map 2
  13. show_views = show_views_file.map(split_show_views)
  14.  
  15. #check
  16. show_views.collect()
  17.  
  18. show_channel_file = sc.textFile("input/join2_genchan?.txt")
  19.  
  20. def split_show_channel(line):
  21. #<INSERT_CODE_HERE 3>
  22. show, channel = line.split(',')
  23. #
  24. return (show, channel)
  25.  
  26. #filter =='BAT' 4
  27. show_channel = show_channel_file.map(split_show_channel)
  28.  
  29. # join 5
  30. joined_dataset = show_channel.join(show_views)
  31.  
  32. def extract_channel_views(show_views_channel):
  33. # 6
  34. channel = show_views_channel[1][0]
  35. views = int(show_views_channel[1][1])
  36. #
  37. return (channel, views)
  38.  
  39. #map 7
  40. channel_views = joined_dataset.map(extract_channel_views)
  41.  
  42. def some_function(a, b):
  43. # 8
  44. some_result = a + b
  45. #
  46. return some_result
  47.  
  48. # 9
  49. channel_views.reduceByKey(some_function).collect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement