Python Solution:
class WordCount:
def mapper(self, key, line):
# key我们可以当做是index,或者URL
for word in line.split():
yield word, key
# @param key is from mapper
# @param values is a set of value with the same key
def reducer(self, key, values):
# values 是一组index 或者 URL
indexes = []
for v in values:
indexes.append(v)
yield key, indexes