使用纯 Python 编写多步的 MapReduce 作业
在本机上进行测试
在 Hadoop 集群上运行
使用 Amazon Elastic MapReduce (EMR) 在云上运行
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()
Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务