zoukankan      html  css  js  c++  java
  • Why Sqls can be run via MapReduce?

      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)

  • 相关阅读:
    【NOI2015】品酒大会 SAM
    4566: [Haoi2016]找相同字符 SAM
    3709: [PA2014]Bohater 贪心
    1925: [Sdoi2010]地精部落 dp, 抖动子序列
    4205: 卡牌配对 最大流+建图技巧
    留言板
    self-introduction
    最近比赛
    STOI补番队胡策
    BZOJ 3503: [Cqoi2014]和谐矩阵( 高斯消元 )
  • 原文地址:https://www.cnblogs.com/linghuaichong/p/4366996.html
Copyright © 2011-2022 走看看