MapReduce 中的地图有何意义?

What's the point of the map in MapReduce?

地图的意义何在?例如,为什么不使用下面的而不是:reducer = (accum, x) => accum + (x + 2)?

或者 mapper 和 reducer 分开:

mapper = (x) => x + 2
reducer = (accum, y) => accum + y

所以:

//  x     y     
//  0     2
//  1     3

[0, 1].map(mapper).reduce(reducer, 0) // result == 5

在 "big data technologies" 中是否有像 Hadoop 这样的示例,其中将所有功能移动到 reducer 中是不可取的/会导致一些损失,而通过使用单独的映射器可以避免这些损失。

我能想到在 reducer 中实际需要知道初始值的示例;使 "purely map" mapper 函数的使用变得不可能或至少毫无意义,因为您必须映射到包含初始值的值,例如来自 mapper,返回包含初始值的元组,以便 reducer 可以访问它:

mapper = (x) => [x, lookupValue1[x] * lookupValue2[x]]
reducer = (accum, y) => { accum[y[0]] = y[1]; return accum; }

//  x          y
//  'alex'    ['alex',  -41]
//  'chris'   ['chris', 102]
['alex', 'chris'].map(mapper).reduce(reducer, {})

// result = { 'alex': -41, 'chris': 102 }

恕我直言,我建议您从 MR 的基础知识开始,不要急于下结论。

请关注以下内容link。 http://bytepadding.com/big-data/map-reduce/understanding-map-reduce-the-missing-guide/

Just to provide some pointers. 
 1. Reducer canot read directly from HDFS, it has to read data from Mappers. 
 2. One has to minimise data trasfer from Mapper to reducer hence choice of combiner. 
 3. Less data sent from mapper to reducer, faster is the job, so we try to filter as early as possible.
 4.  The chances that all the keys will be read by the same mapper are very low, hence to reduce data needs to be sent to the reducer. 
 5. Alway imagine of a 1 TB file with key1 occuring twice and located at the beginning of the file and end of file. Apply all your logics for this and will realize what MR, spark is all about.

MapReduce 视为一种有效处理 "suitable" 数据的设计模式。通过这个,我想说两件事:

1) MapReduce 不是处理所有 "type" 数据的有效方法。可以有特定类型的数据和处理步骤;它可以利用 HDFS 和分布式处理。 MapReduce 只是该联盟中最适合特定算法的工具。

2) 并不是所有的算法都适合mapreduce。因为它是一种设计模式,所以它最适合与特定设计内联的特定算法。这就是为什么 mapreduce 核心库允许您跳过 mapper(使用身份映射)或 reducer(只需将 reducer 数量设置为零)。 mapreduce可以根据需要多跳过一期

如果您了解 map-combine - sort + shuffle - reduce 的工作原理,请将这两点放在中心位置;它可以帮助您实现比使用任何其他工具更有效的算法。同时,如果您的数据和算法真的不是 'fit' 到 mapreduce,您最终可能会得到一个非常低效的 mapreduce 程序。

如果您想研究 mapreduce 中映射器的重要性,只需研究 wordcount 程序示例(与 mapreduce 捆绑在一起)。尝试实施它 with/without mapper(或完全 reducermapreduce)并测试性能。希望你能找到答案。