`
yaojingguo
  • 浏览: 208106 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Reading Note of MapReduce: Simplified Data Processing on Large Clusters

阅读更多
=======================================================================
Reading Note of MapReduce: Simplified Data Processing on Large Clusters
=======================================================================

------
Origin
------
``map`` and ``reduce`` are primitives in Lisp.

``map`` example
::
    (map 'list #'- '(1 2 3 4)) =>  (-1 -2 -3 -4)
   
``reduce`` example
::
    (reduce #'* '(1 2 3 4 5)) =>  120

Haskell has the same functions.
``map`` example
::
    Prelude> map negate [1, 2, 3]
    [-1,-2,-3]
In Haskell, reduce is called fold. Haskell has 2 kinds of folds: foldl and
foldr.
::
    Prelude> foldl (+) 0 [1, 2, 3]
    6

-------
Example
-------
::
    map(String key, String value);
    // key: document name
    // value: document contents
    for each word w in value:
        EmitIntermeidate(w, "1");

    reduce(String key, Iterator values):
        // key: a word
        // values: a list of counts
        int result = 0;
        for each v in values:
            result += ParseInt(v);
        Emit(AsString(result));
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics