【问题标题】:Reducer Selection in HiveHive 中的减速器选择
【发布时间】:2020-05-09 22:52:55
【问题描述】:

我有以下记录集来处理

 1000, 1001, 1002 to 1999,
 2000, 2001, 2002 to 2999,
 3000, 3001, 3002 to 3999

我想使用 HIVE 处理以下记录集,以便 reducer-1 处理数据 1000 到 1999,reducer-2 处理数据 2000 到 2999,reducer-3 处理数据 3000 到 3999。请帮我解决以上问题。

【问题讨论】:

    标签: hadoop hive hiveql reduce hadoop-partitioning


    【解决方案1】:

    使用DISTRIBUTE BY,mappers输出正在根据distribute by子句进行分组传送到reducers进行处理:

    select ...
      from ...
    distribute by case when col between 1000 and 1999 then 1
                       when col between 2000 and 2999 then 2
                       when col between 3000 and 3999 then 3
                   end
    

    或者干脆

    distribute by floor(col/1000)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多