Examly題庫立即開始練習
國營聯招 統計資訊統計學、巨量資料概論10450單選題

在Spark大數據分析平台上執行下列的Python程式碼: file=spark.textFile("hdfs://…") //opens a file counts=file.flatMap(lambda line: line.split(" ")) //iterate over the lines, split each line by space into words .map(lambda word: (word, 1)) //for each word, create the tuple (word, 1) .reduceByKey(lambda a, b: a+b) //go over the tuples "by key" (first element) and sum the second elements counts.saveAsTextFile("hdfs://…") 當輸入短文: a spark can start a fire that burns the entire prairie 請問最後存入到 HDFS 檔案的(key, value)一共有多少對?

A8
B9
C10正確答案
D11
答案與詳解
C
正確答案
MapReduce WordCount:統計不重複單字數,輸入句子共10個不重複單字,故輸出10對(key,value)。

為什麼答案是 C

句子共11個單字(a出現2次),去除重複後有10個不重複單字,reduceByKey合併同key後輸出10對,正確。

考點:單字計數錯誤考點:空格數混淆考點:不重複單字數考點:忽略reduceByKey
載入中…

想練更多統計學、巨量資料概論考古題?

Examly 收錄 38 萬+ 道歷屆題目,每題都有像這樣的精選詳解。免費下載,立即開練。

Download on theApp Store即將推出Google Play
黑皮