RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
MapReduce引擎如何实现

今天就跟大家聊聊有关MapReduce引擎如何实现,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

顺德网站建设公司创新互联建站,顺德网站设计制作,有大型网站制作公司丰富经验。已为顺德数千家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的顺德做网站的公司定做!

MapReduce引擎怎么实现

使用例子见下,只需要import一个名即可。

#!/usr/bin/env python

import mincemeat

data = ["Humpty Dumpty sat on a wall",

"Humpty Dumpty had a great fall",

"All the King's horses and all the King's men",

"Couldn't put Humpty together again",

]

def mapfn(k, v):

for w in v.split():

yield w, 1

def reducefn(k, vs):

MapReduce引擎怎么实现

result = 0

for v in vs:

result += v

return result

s = mincemeat.Server()

# The data source can be any dictionary-like object

s.datasource = dict(enumerate(data))

s.mapfn = mapfn

s.reducefn = reducefn

results = s.run_server(password="changeme")

print results

然后将mincemeat.py 和example.py 放在同一个目录下,执行example.py

python example.py

这时程序会挂起一个daemon

然后另开一终端运行:

python mincemeat.py -p changeme localhost

就会看到刚才的daemon打印出了MapReduce结果并退出了。

{‘a’: 2, ‘on’: 1, ‘great’: 1, ‘Humpty’: 3, ‘again’: 1, ‘wall’: 1, ‘Dumpty’: 2, ‘men’: 1, ‘had’: 1, ‘all’: 1, ‘together’: 1, “King’s”: 2, ‘horses’: 1, ‘All’: 1, “Couldn’t”: 1, ‘fall’: 1, ‘and’: 1, ‘the’: 2, ‘put’: 1, ’sat’: 1}

看完上述内容,你们对MapReduce引擎如何实现有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。


网页题目:MapReduce引擎如何实现
网页网址:http://sczitong.cn/article/giojsp.html