hive中order by、distribute by、sort by和cluster by的区别和联系
来源:互联网 发布:紫金银交易软件 编辑:程序博客网 时间:2024/05/19 09:12
order by
order by 会对数据进行全局排序,和oracle和mysql等数据库中的order by 效果一样,
它只在一个reduce中进行所以数据量特别大的时候效率非常低。
而且当设置 :set hive.mapred.mode=strict的时候不指定limit,执行select会报错,如下:
LIMIT must also be specified.
sort by
sort by 是单独在各自的reduce中进行排序,所以并不能保证全局有序,一般和distribute by 一起执行,而且distribute by 要写在sort by前面
如果mapred.reduce.tasks=1和order by效果一样,如果大于1会分成几个文件输出每个文件会按照指定的字段排序,而不保证全局有序。
sort by 不受 hive.mapred.mode 是否为strict ,nostrict 的影响
distribute by
用distribute by 会对指定的字段按照hashCode值对reduce的个数取模,然后将任务分配到对应的reduce中去执行
就是在mapreduce程序中的patition分区过程,默认根据指定key.hashCode()&Integer.MAX_VALUE%numReduce 确定处理该任务的reduce
示例如下:
public class myPartitioner extends Partitioner<TextPair, Text>{ @Override public int getPartition(TextPair key, Text value, int num) { // TODO Auto-generated method stub if(num == 0 ){ return 0; } int a = (key.getFirst().hashCode()&Integer.MAX_VALUE)%num; return a; }}
Cluster By
distribute by 和 sort by 合用就相当于cluster by,但是cluster by 不能指定排序为asc或 desc 的规则,只能是desc倒序排列。
1 0
- hive中order by、distribute by、sort by和cluster by的区别和联系
- Hive-2.HiveQL查询中ORDER BY 和SORT BY 语句|包含SORT BY 的DISTRIBUTE BY|CLUSTER BY
- Hive中order by,sort by,distribute by,cluster by
- hive中order by,distribute by,sort by,cluster by
- hive中order by,sort by,distribute by,Cluster By的区别
- Hive中order by,sort by,distribute by,cluster by的区别
- Hive中order by,sort by,distribute by,cluster by的区别
- Hive中order by,sort by,distribute by,cluster by的区别
- Hive中order by,sort by,distribute by,cluster by的区别
- Hive中order by,sort by,distribute by,cluster by的区别
- Hive中order by、sort by、distribute by、cluster by的区别
- 关于Hive中order by,Sort by,Distribute by和Cluster By介绍
- hive中order by 和sort by与distribute by
- Hive 区分cluster by、distribute by + sort by、order by以及创建表带有clustered by和sort by
- hive Sort By/Order By/Cluster By/Distribute By
- hive中的order by+sort by+distribute by+cluster by
- Hive Sort by/Order By/Cluster By/Distribute By
- hive sort by,order by ,distribute by,cluster by
- Python字符串的encode与decode研究心得乱码问题解决方法
- androidManifest
- 微信公众号开发_ReceiveXmlEntity的代码(八)
- 怎么在迷茫中走出
- HTTP简介,http是一个属于应用层的面向对象的协议
- hive中order by、distribute by、sort by和cluster by的区别和联系
- NOIP 2013 火柴排队
- CSS中星号(*)影响的样式继承性问题
- 转利用_DATE_和_TIME_宏在keil中添加编译日期和时间到C51程序中
- First Blood By Now
- hdu 1150 二分图的最大匹配 hopcroft-karp算法
- 微信公众号开发_ReceiveXmlProcess的代码(九)
- 在Kisso里,找出的防SQL注入 - 过滤 XSS SQL 注入
- Swift 学习笔记 UITableView (二)Overview of the table View API