mrjob 可以让用 Python 2.5+ 来编写 MapReduce 作业,并在多个不同平台上运行,你可以:
pip 的安装方法:pip install mrjob
示例代码:
from mrjob.job import MRJob class MRWordCounter(MRJob): def mapper(self, key, line): for word in line.split(): yield word, 1 def reducer(self, word, occurrences): yield word, sum(occurrences) if __name__ == '__main__': MRWordCounter.run()