已知電影資料集movie_metadata.csv,其包含28列,每列資料用","分隔,每一列的資料含義可通過列名自行判斷。
采用Spark讀取該檔案的方式為:
// 將檔案讀取為RDD,并過濾掉第一行元資訊
val rdd = sc.textFile("movie_metadata.csv").filter(!_.startsWith("color,director_name"))
// 將每一行按照","分割
val movieRdd = rdd.map(_.split(","))
請根據以上提示,在spark-shell中(或IDE中)利用RDD API撰寫代碼實作如下功能:
1、請輸出該資料集包含的所有不同國家的名稱(用到country一列)(country在第20列)
2、請輸出該資料集中包含的中國電影的數目(用到country一列)
3、請輸出最受關注的三部中國電影的電影名稱、導演以及放映時間(用到movie_title、director_name、num_voted_users、country以及title_year五列)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/49064.html
標籤:Spark
上一篇:An unexpected error prevented the server from fulfilling your request. (HTTP 500
