首页 > 数据库技术 > 详细

Why Sqls can be run via MapReduce?

时间:2015-03-25 23:21:19      阅读:259      评论:0      收藏:0      [点我收藏+]

  in 《Core Model of Sql》, I showed that there are three driven operations in SQL: Group, Filter, Join. In this article, I‘ll illustrate why sqls can be executed by a MapReduce engine, by showing that all the 3 operations can be implemented via MapReduce.  A typical MapReduce goes this way:

  Map:       each file row                                                -> (intermediary key, intermediary value)

  Reduce:  (intermediary key, List of intermediary value) -> (final key, final value)

Now I show the 3 operations one by one.

Group:

  Map:      each table row                                               ->(columns of "group by", other columns)

  Reduce: (columns of "group by", List of other columns)  ->(columns of "group by", apply aggregate function to "List of other columns")

Filter:

  Map:      each table row -> if this row does not pass the where condition, then drop it

                                              else (1, selected columns)

  Reduce:  No reduce is needed

Join:

  Split tableA into N partitions, split tableB into M partitions. Then there are N*M input pairs

  For each input pair(part_i_A,part_j_B):

    for rowA in part_i_A:

      for rowB in part_j_B:

        generate (1, rowA+rowB)

Why Sqls can be run via MapReduce?

原文:http://www.cnblogs.com/linghuaichong/p/4366996.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!