d********i 发帖数: 582 | 1 题目:MapReduce(filter a collection of documents, the words which occur more
than 5000 times)
小弟从来没学过mapreduce, 不知道从何下手写这个代码? 有大牛帮忙吗? |
c*****a 发帖数: 808 | 2 就是word count的变形,reduce时看interator size > 5000就行了吧 |
d********i 发帖数: 582 | 3 我连word count都写不出来。 Google paper太理论化了。。我写不出java code来。 |
s******c 发帖数: 1920 | 4 参考hadoop的mapreduce
https://developer.yahoo.com/hadoop/tutorial/module4.html
【在 d********i 的大作中提到】 : 我连word count都写不出来。 Google paper太理论化了。。我写不出java code来。
|
d********i 发帖数: 582 | 5 请问有不用hadoop libary的代码? 面试也不会直接用到hadoop lib那么深吧。。
【在 s******c 的大作中提到】 : 参考hadoop的mapreduce : https://developer.yahoo.com/hadoop/tutorial/module4.html
|
f******n 发帖数: 279 | |
c*****a 发帖数: 808 | 7 来个spark的
val file = spark.textFile("hdfs://documents")
val words = file.flatMap(l=> l.split(" ")).map(w => (w, 1)).groupByKey(10000
).filter(p => p._2.size>5000).map(_._1)
|
s******c 发帖数: 1920 | 8 用起来区别不大。
Hadoop mr就是山寨Google mr的
【在 d********i 的大作中提到】 : 请问有不用hadoop libary的代码? 面试也不会直接用到hadoop lib那么深吧。。
|
s******t 发帖数: 229 | 9 先生成key-value pair,key=every word, value=1, 再把相同key的value都combine,
sum>5000的key都输出 |
f******n 发帖数: 279 | |
|
|
m*********y 发帖数: 111 | |
o*****n 发帖数: 189 | 12 以前看过MR, 都不记得了。瞎写一个
#MapReduce(filter a collection of documents, the words which occur more than
5000 times)
n=5000
dic=dict()
with open('.\MapReduce_filter_repeating_words.txt', 'r') as f:
for line in f:
A=line.split()
for a in A:
if a in dic.keys():
dic[a] +=1
else: dic[a]=1
for k in dic.keys():
if dic[k] >= n: print('-', k,'-' ,'show up ' , dic[k],' times') |
Z**0 发帖数: 1119 | 13 是问你mapreduce的idea。
map, reduce, filter/emit. |
d********t 发帖数: 9628 | 14 G家给用python吗?
than
【在 o*****n 的大作中提到】 : 以前看过MR, 都不记得了。瞎写一个 : #MapReduce(filter a collection of documents, the words which occur more than : 5000 times) : n=5000 : dic=dict() : with open('.\MapReduce_filter_repeating_words.txt', 'r') as f: : for line in f: : A=line.split() : for a in A: : if a in dic.keys():
|
m*****l 发帖数: 95 | 15 这题两年前我被面过,直接伪java代码过了。。。hadoop in action第一章就有样板。 |
s*****B 发帖数: 32 | |