|NO.Z.00024|——————————|BigDataEnd|——|Hadoop&Hive.V24|——|Hive.v24|Hive存储机制之行列存储及TextFile.v02|
一、文件存储格式对比测试
### --- 说明:
~~~ 给 linux123 分配合适的资源。2core;2048G内存
~~~ 适当减小文件的数据量(现有数据约800W,根据自己的实际选择处理100-300W条数据均可)
~~~ # 压缩的资源位置
[root@linux123 ~]# hdfs dfs -ls /user/hive/warehouse/mydb.db/uaction*
~~~ # 检查文件行数
[root@linux123 ~]# wc -l uaction.dat
[root@linux123 ~]# head -n 1000000 uaction.dat > uaction1.dat
[root@linux123 ~]# tail -n 1000000 uaction.dat > uaction2.dat
### --- 文件压缩比
[root@linux123 ~]# hdfs dfs -ls /user/hive/warehouse/mydb.db/uaction*
# ORC
40638630 /user/hive/warehouse/mydb.db/uaction_orc/000000_0
40638631 /user/hive/warehouse/mydb.db/uaction_orc/000001_0
# Parquet
40638630 /user/hive/warehouse/mydb.db/uaction_parquet/000000_0
40638631 /user/hive/warehouse/mydb.db/uaction_parquet/000001_0
# TextFile
355573332 /user/hive/warehouse/mydb.db/uaction_text/useraction.dat
### --- ORC > Parquet > text
~~~ 执行查询
0: jdbc:hive2://linux123:10000> SELECT COUNT(*) FROM uaction_text;
0: jdbc:hive2://linux123:10000> SELECT COUNT(*) FROM uaction_orc;
0: jdbc:hive2://linux123:10000> SELECT COUNT(*) FROM uaction_parquet;
-- text : 14.446
-- orc: 0.15
-- parquet : 0.146
### --- orc 与 parquet类似 > txt
~~~ 在生产环境中,Hive表的数据格式使用最多的有三种:TextFile、ORCFile、Parquet。
~~~ TextFile文件更多的是作为跳板来使用(即方便将数据转为其他格式)
~~~ 有update、delete和事务性操作的需求,通常选择ORCFile
~~~ 没有事务性要求,希望支持Impala、Spark,建议选择Parquet
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
浙公网安备 33010602011771号