既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
8 tony 33 CC
9 lelisy 99 DD
10 chery 88 AA
![在这里插入图片描述](https://img-blog.csdnimg.cn/20191215144924751.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0JlaWlzQmVp,size_16,color_FFFFFF,t_70)
### 二、分区
>
> hive表就是hdfs的上的一个目录
> hive表中的数据,其实就是对应了HDFS上的一个目录下的数据
> 概念:对hive表的数据做分区管理
>
>
>
创建分区表
create table student_ptn(stuid int,stuname string)
partitioned by(stuage int,department string)
row format delimited fields terminated by ’ ';
添加分区
// 添加一个分区
alter table student_ptn add partition(stuage=33,department=“CC”);
// 同时添加多个分区
alter table student_ptn add partition(stuage=77,department=“AA”) partition(stuage=66,department=“DD”);
// 添加成功,但是我们可以看到分区字段的顺序是在创建分区表的时候决定的
alter table student_ptn add partition(department=“CC”,stuage=44);
![在这里插入图片描述](https://img-blog.csdnimg.cn/20191215150114937.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0JlaWlzQmVp,size_16,color_FFFFFF,t_70)
// 添加分区时,指定分区的数据存储目录
alter table student_ptn add partition(stuage=88,department=“AA”) location “/ptn_input1” partition(age=99,department=“DD”) location “/ptn_input2”;
查询分区
show partitions student_ptn;
OK
stuage=33/department=CC
stuage=44/department=CC
stuage=66/department=DD
stuage=77/department=AA
修改分区
alter table student_ptn partition(age=44,department=“AA”) set location “hdfs://hadoop01:9000/ptn_input3”;
// 往某个特定的分区导入数据
load data local inpath “/opt/soft/student.txt” into table student_ptn partition(age=55,department=“BB”);
// 不能直接往分区表导入数据
load data local inpath “/opt/soft/student.txt” into table student_ptn; //XXXXX
删除分区
alter table student_ptn drop partition(age=44,department=“AA”);
// 删除分区的时候,包括分区的元数据信息和分区的数据及目录
// 清空分区表的时候,分区还在,数据被清空
导入数据,大体上说,总共有三种方式:
1、hadoop fs
2、load
3、insert …select…
// 使用insert…values… 的方法是导入数据,主要用于测试
insert into table student_ptn values (101,“ning”);
insert into table student_ptn partition(stuage=33,department=“CC”) values (101,“ning”);
使用单重或者多重模式进去插入
from student
insert … select …
insert … select …
from student
insert into table student_ptn partition(stuage=18,department=“AA”) select id,name where age = 18
insert into table student_ptn partition(stuage=18,department=“BB”) select id,name where age = 19;
// 验证多重分区的插入是否成功
select id, name from student_ptn where stuage= 18 and department = “AA”;
select id, name from student_ptn where stuage= 18 and department = “BB”;
关于静态分区和动态分区,可以参考我的这篇博客,里面例子非常详细,这里就不再赘述:
[【Hive】(五)Hive 中动态分区与静态分区详解](https://bbs.csdn.net/topics/618545628)
**动态分区的效果:**
按照动态分区的字段的值做划分,一个值就是一个分区
该studnet表当中的分区字段department有多少个值,就有多少个分区
每个分区就存一个分区字段值的所有数据
### 三、分桶
概念:对分区的进一步的 更细粒度的划分,与分区类似。
>
> 分桶的核心思想跟 MR程序的默认分区组件HashParititioner的原理一致
> 原理:根据key的hash值去模除以reduceTask的个数/mapreduce的分区个数/hive表的分桶个数
>
>
>
**分桶的原理:**
对分桶字段的值进行hash,然后模除以桶的个数,得到一个余数,该余数就是分桶的编号000000\_0
MR 分区 mapper的outKey reduceTask的个数
hive 分桶 分桶字段的值 分桶的个数
![img](https://img-blog.csdnimg.cn/img_convert/77000a243e7ec95891d109b83a6c61dc.png)
![img](https://img-blog.csdnimg.cn/img_convert/550bf766aa154a61bf241a310d250f28.png)
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**