0. 说明

  全排序(order by) | 部分排序(sort by) | hash 分区(distribute by)  | cluster by


1. 前期准备

  1.1 建表

create table user_order(id int, name string, age int, province string, city string)
row format delimited
fields terminated by '\t';

  1.2 设置 reduce 个数

set mapreduce.job.reduces=2;

2. 全排序(order by)

  使用一个 reduce,在真实使用中,需要加 limit 限制。

truncate table user_order;
insert into user_order select * from user_par order by id;

3. 部分排序(sort by )

  在每个 reduce 中分别排序

truncate table user_order;

insert into user_order select * from user_par sort by id;

4. hash 分区(distribute by )

  未排序

truncate table user_order;

insert into user_order select * from user_par distribute by id;

5. cluster by

  cluster by = distribute by + sort by

truncate table user_order;

insert into user_order select * from user_par cluster by id;

[Hive_9] Hive 的排序的更多相关文章

  1. hive 分组排序,topN

    hive 分组排序,topN 语法格式:row_number() OVER (partition by COL1 order by COL2 desc ) rankpartition by:类似hiv ...

  2. hive的排序,分組练习

    hive的排序,分組练习 数据: 添加表和插入数据(数据在Linux本地中) create table if not exists tab1( IP string, SOURCE string, TY ...

  3. Hive 的 排序

    全排序:order by对全部所有的数据进行排序,在实现的时候是放到一个reduce中进行的,可以想象这样做效率是比较低的: 局部排序:sort by对数据进行分组,然后在组内进行排序,每个reduc ...

  4. hive:排序分析函数

    基本排序函数 语法: rank()over([partition by col1] order by col2) dense_rank()over([partition by col1] order ...

  5. hive分组排序 取top N

    pig可以轻松获取TOP n.书上有例子 hive中比较麻烦,没有直接实现的函数,可以写udf实现.还有个比较简单的实现方法: 用row_number,生成排名序列号.然后外部分组后按这个序列号多虑, ...

  6. Hive中排序和聚集

    //五种子句是有严格顺序的: where → group by → having → order by → limit ; //distinct关键字返回唯一不同的值(返回age和id均不相同的记录) ...

  7. hive 分组排序函数 row_number() over(partition by " " order by " "desc

    语法:row_number() over (partition by 字段a order by 计算项b desc ) rank --这里rank是别名 partition by:类似hive的建表, ...

  8. hive的排序 order by和sort by

    在算法中,各个排序算法的复杂度都比较高,正常情况下为O (nlogn) ,所以当数据量特别大的时候,对数组进行排序消耗都很大. 因为hive的计算引擎MapReduce是分布式系统, 利用分布式的特点 ...

  9. hive 全局排序

    不分发数据,使用单个reducer ; select * from dw.dw_app where dt>='2016-09-01' and dt <='2016-09-18' order ...

随机推荐

  1. [转]Redis配置文件详解

    本文转自http://blog.csdn.net/neubuffer/article/details/17003909 redis是一款开源的.高性能的键-值存储(key-value store),和 ...

  2. 网络协议抓包分析——IP互联网协议

    前言 IP协议是位于OSI模型的第三层协议,其主要目的就是使得网络间可以相互通信.在这一层上运行的协议不止IP协议,但是使用最为广泛的就是互联网协议. 什么是IP数据报 TCP/IP协议定义了一个在因 ...

  3. https://finance.sina.com.cn/realstock/company/sh600522/nc.shtml

    https://finance.sina.com.cn/realstock/company/sh600522/nc.shtml http://hq.sinajs.cn/list=sh601006

  4. 网络爬虫之html2md

    前言 上周利用java爬取的网络文章,一直未能利用java实现html转化md,整整一周时间才得以解决. 虽然本人的博客文章数量不多,但是绝不齿于手动转换,毕竟手动转换浪费时间,把那些时间用来做些别的 ...

  5. man rpcbind(rpcbind中文手册)

    本人译作集合:http://www.cnblogs.com/f-ck-need-u/p/7048359.html RPCBIND() BSD System Manager's Manual RPCBI ...

  6. mysql数据库中的数据导入与导出

    需求: 在本地电脑上的mysql中创建了一个数据库,并且在该数据库中创建了很多表,表中数据比较多: 现在想换一台电脑,但是又不想重新建数据库.建表.造数据. 解决方案: 利用mysql提供的命令,在本 ...

  7. npm install -g @angular/cli@latest 失败

    一开始的ERROR信息是 error "@angular/compiler-cli" package was not properly installed 尝试方案二时又出现了以下 ...

  8. Winform下KeyDown,KeyPress,KeyUp事件的总结(转)

    原文: http://www.cnblogs.com/xiashengwang/archive/2011/09/15/2578798.html 在winform程序中,经常会用到这几个事件用于控制数字 ...

  9. [PHP] 算法-将一个字符串转换成一个整数的PHP实现

    题目描述 将一个字符串转换成一个整数(实现Integer.valueOf(string)的功能,但是string不符合数字要求时返回0),要求不能使用字符串转换整数的库函数. 数值为0或者字符串不是一 ...

  10. tomcat端口修改以及jvm启动参数设置

    1.端口更改:找到config目录下server.xml文件 如下 <?xml version='1.0' encoding='utf-8'?> <!-- Licensed to t ...