MapReduce引擎如何实现

发布时间:2021-06-26 14:09:23 作者:Leah
来源:亿速云 阅读:161

今天就跟大家聊聊有关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引擎如何实现有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

推荐阅读:
  1. MapReduce on Hbase
  2. MapReduce 调优

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mapreduce

上一篇:EurekaServer自动装配方法及启动流程

下一篇:sql查询报错:[Err] ORA-00913: too many values怎么解决

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》