Map --映射

Reduce -- 归纳

将大数据标准化的处理

Map 拆封任务,Reduce将结果合并

这样是不是能够将很多计算机组成一台超级计算机呢?

一些问题:如果任务本身就很复杂,那么拆解任务本身就是一个很打的难题。

python 在2.6 的时候 增加了 map reduce函数

例如我们可以这样写

import urllib2
urls = [
'https://www.baidu.com',
'http://www.douban.com'
] resurt = map(urllib2.urlopen,urls) #等价于 resurt = []
for url in urls:
resurt.append(urllib2.urlopen(url))

 当然我们也可以加上多线程的

import urllib2
from multiprocessing.dummy import Pool as ThreadPool
urls = [
'https://www.baidu.com',
'http://www.douban.com'
] def get_html(url):
res = urllib2.urlopen(url)
html = res.read()
return html pool = ThreadPool(4)
results = pool.map(get_html,urls) pool.close()
pool.join() print results

  

04-python进阶-map&reduce的更多相关文章

  1. python基础——map/reduce

    python基础——map/reduce Python内建了map()和reduce()函数. 如果你读过Google的那篇大名鼎鼎的论文“MapReduce: Simplified Data Pro ...

  2. 使用Python实现Map Reduce程序

    使用Python实现Map Reduce程序 起因 想处理一些较大的文件,单机运行效率太低,多线程也达不到要求,最终采用了集群的处理方式. 详细的讨论可以在v2ex上看一下. 步骤 MapReduce ...

  3. Demo of Python "Map Reduce Filter"

    Here I share with you a demo for python map, reduce and filter functional programming thatowned by m ...

  4. Python: lambda, map, reduce, filter

    在学习python的过程中,lambda的语法时常会使人感到困惑,lambda是什么,为什么要使用lambda,是不是必须使用lambda? 下面就上面的问题进行一下解答. 1.lambda是什么? ...

  5. Python语言——map/reduce的用法

    Python内建了map()和reduce()函数. 如果你读过Google的那篇大名鼎鼎的论文“MapReduce: Simplified Data Processing on Large Clus ...

  6. python filter map reduce

    filter(function, iterable): Construct a list from those elements of iterable for which function retu ...

  7. python 学习 map /reduce

    python 内建了map()和reduce()函数 map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回. ...

  8. Python基础-map/reduce/filter

    一.map Python内置函数,用法及说明如下: class map(object): """ map(func, *iterables) --> map obj ...

  9. python的map,reduce函数与pandas的apply,filter函数

    1. python自带的apply.filter.map函数.reduce函数,很多情况下可以代替for循环: map(func,list),对list的每个元素分别执行func函数操作,显然func ...

随机推荐

  1. python的subprocess模块(写的不错留作查询)

    python的subprocess模块 subprocess模块是python从2.4版本开始引入的模块.主要用来取代 一些旧的模块方法,如os.system.os.spawn*.os.popen*. ...

  2. git remote add 用法

    前一阵子,对于git remote add 的内容一直调错,现在明确一下: 这里是gitStack的用法:git remote add gitServerName http://ip/name(这里没 ...

  3. SQL 中的group by (转载)

    概述 原始表 简单Group By Group By 和 Order By Group By中Select指定的字段限制 Group By All Group By与聚合函数 Having与Where ...

  4. [nmon]使用nmon工具监控系统资源

    1.下载nmon 下载正确的nmon版本, 查看linux服务器版本,命令:lsb_release -a,查看到当前系统为RedHat 6.4 然后我们根据我们的linux版本,下载相应nmon版本, ...

  5. ASP.NET WebForm & MongoDB

    ASP.NET WebForm & MongoDB 最近在朋友介绍下,也跟着看AngularJS 买了一本三合一的书,Node.JS+MongoDB+AngularJS http://www. ...

  6. SAP标准培训课程C4C10学习笔记(一)第一单元

    C4C10:SAP Hybris Cloud for Customer Administration 课程目录: 第一单元是C4C的简介. 作为SAP推出的一个SaaS(Software as a s ...

  7. Spark Job调优(Part 1)

    原文链接:https://wongxingjun.github.io/2016/05/11/Spark-Job%E8%B0%83%E4%BC%98-Part-1/ Spark应用的执行效率是所有程序员 ...

  8. 绘制方式和OpenGL枚举对应关系

    绘制方式和OpenGL枚举对应关系 图元类型 OpenGL枚举量 点 GL_POINTS 线 GL_LINES 条带线 GL_LINE_STRIP 循环线 GL_LINE_LOOP 独立三角形 GL_ ...

  9. Git初始化仓库

    Git global setup: git config --global user.name "再见理想" git config --global user.email &quo ...

  10. Dojo的on函数(以前的dojo.connect)

    ​同jQuery的on函数: require(["esri/map", "dojo/on"], function(Map, on) { // ... on(my ...