v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
wgx
wgx
2
67
2016-04-02T15:15:00Z
2016-04-02T15:15:00Z
1
233
1332
11
3
1562
15.00
Clean
Clean
false
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-font-kerning:1.0pt;}
table.MsoTableGrid
{mso-style-name:网格型;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-priority:39;
mso-style-unhide:no;
border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-border-insideh:.5pt solid windowtext;
mso-border-insidev:.5pt solid windowtext;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-font-kerning:1.0pt;}
table.MsoTable15Grid1LightAccent1
{mso-style-name:"网格表 1 浅色 - 着色 1";
mso-tstyle-rowband-size:1;
mso-tstyle-colband-size:1;
mso-style-priority:46;
mso-style-unhide:no;
border:solid #BDD6EE 1.0pt;
mso-border-themecolor:accent1;
mso-border-themetint:102;
mso-border-alt:solid #BDD6EE .5pt;
mso-border-themecolor:accent1;
mso-border-themetint:102;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-border-insideh:.5pt solid #BDD6EE;
mso-border-insideh-themecolor:accent1;
mso-border-insideh-themetint:102;
mso-border-insidev:.5pt solid #BDD6EE;
mso-border-insidev-themecolor:accent1;
mso-border-insidev-themetint:102;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-font-kerning:1.0pt;}
table.MsoTable15Grid1LightAccent1FirstRow
{mso-style-name:"网格表 1 浅色 - 着色 1";
mso-table-condition:first-row;
mso-style-priority:46;
mso-style-unhide:no;
mso-tstyle-border-bottom:1.5pt solid #9CC2E5;
mso-tstyle-border-bottom-themecolor:accent1;
mso-tstyle-border-bottom-themetint:153;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15Grid1LightAccent1LastRow
{mso-style-name:"网格表 1 浅色 - 着色 1";
mso-table-condition:last-row;
mso-style-priority:46;
mso-style-unhide:no;
mso-tstyle-border-top:.75pt double #9CC2E5;
mso-tstyle-border-top-themecolor:accent1;
mso-tstyle-border-top-themetint:153;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15Grid1LightAccent1FirstCol
{mso-style-name:"网格表 1 浅色 - 着色 1";
mso-table-condition:first-column;
mso-style-priority:46;
mso-style-unhide:no;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15Grid1LightAccent1LastCol
{mso-style-name:"网格表 1 浅色 - 着色 1";
mso-table-condition:last-column;
mso-style-priority:46;
mso-style-unhide:no;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List5DarkAccent1
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-tstyle-rowband-size:1;
mso-tstyle-colband-size:1;
mso-style-priority:50;
mso-style-unhide:no;
border:solid #5B9BD5 3.0pt;
mso-border-themecolor:accent1;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-tstyle-shading:#5B9BD5;
mso-tstyle-shading-themecolor:accent1;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
color:white;
mso-themecolor:background1;
mso-font-kerning:1.0pt;}
table.MsoTable15List5DarkAccent1FirstRow
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:first-row;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-bottom:2.25pt solid white;
mso-tstyle-border-bottom-themecolor:background1;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List5DarkAccent1LastRow
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:last-row;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-top:.5pt solid white;
mso-tstyle-border-top-themecolor:background1;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List5DarkAccent1FirstCol
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:first-column;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-right:.5pt solid white;
mso-tstyle-border-right-themecolor:background1;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List5DarkAccent1LastCol
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:last-column;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-left:.5pt solid white;
mso-tstyle-border-left-themecolor:background1;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List5DarkAccent1OddColumn
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:odd-column;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-left:.5pt solid white;
mso-tstyle-border-left-themecolor:background1;
mso-tstyle-border-right:.5pt solid white;
mso-tstyle-border-right-themecolor:background1;}
table.MsoTable15List5DarkAccent1EvenColumn
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:even-column;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-left:.5pt solid white;
mso-tstyle-border-left-themecolor:background1;
mso-tstyle-border-right:.5pt solid white;
mso-tstyle-border-right-themecolor:background1;}
table.MsoTable15List5DarkAccent1OddRow
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:odd-row;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-top:.5pt solid white;
mso-tstyle-border-top-themecolor:background1;
mso-tstyle-border-bottom:.5pt solid white;
mso-tstyle-border-bottom-themecolor:background1;}
table.MsoTable15List5DarkAccent1NECell
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:ne-cell;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-left:cell-none;}
table.MsoTable15List5DarkAccent1NWCell
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:nw-cell;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-right:cell-none;}
table.MsoTable15List5DarkAccent1SECell
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:se-cell;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-top:cell-none;
mso-tstyle-border-left:cell-none;}
table.MsoTable15List5DarkAccent1SWCell
{mso-style-name:"清单表 5 深色 - 着色 1";
mso-table-condition:sw-cell;
mso-style-priority:50;
mso-style-unhide:no;
mso-tstyle-border-top:cell-none;
mso-tstyle-border-right:cell-none;}
table.MsoTable15List6ColorfulAccent4
{mso-style-name:"清单表 6 彩色 - 着色 4";
mso-tstyle-rowband-size:1;
mso-tstyle-colband-size:1;
mso-style-priority:51;
mso-style-unhide:no;
border-top:solid #FFC000 1.0pt;
mso-border-top-themecolor:accent4;
border-left:none;
border-bottom:solid #FFC000 1.0pt;
mso-border-bottom-themecolor:accent4;
border-right:none;
mso-border-top-alt:solid #FFC000 .5pt;
mso-border-top-themecolor:accent4;
mso-border-bottom-alt:solid #FFC000 .5pt;
mso-border-bottom-themecolor:accent4;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
color:#BF8F00;
mso-themecolor:accent4;
mso-themeshade:191;
mso-font-kerning:1.0pt;}
table.MsoTable15List6ColorfulAccent4FirstRow
{mso-style-name:"清单表 6 彩色 - 着色 4";
mso-table-condition:first-row;
mso-style-priority:51;
mso-style-unhide:no;
mso-tstyle-border-bottom:.5pt solid #FFC000;
mso-tstyle-border-bottom-themecolor:accent4;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List6ColorfulAccent4LastRow
{mso-style-name:"清单表 6 彩色 - 着色 4";
mso-table-condition:last-row;
mso-style-priority:51;
mso-style-unhide:no;
mso-tstyle-border-top:1.5pt double #FFC000;
mso-tstyle-border-top-themecolor:accent4;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List6ColorfulAccent4FirstCol
{mso-style-name:"清单表 6 彩色 - 着色 4";
mso-table-condition:first-column;
mso-style-priority:51;
mso-style-unhide:no;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List6ColorfulAccent4LastCol
{mso-style-name:"清单表 6 彩色 - 着色 4";
mso-table-condition:last-column;
mso-style-priority:51;
mso-style-unhide:no;
mso-ansi-font-weight:bold;
mso-bidi-font-weight:bold;}
table.MsoTable15List6ColorfulAccent4OddColumn
{mso-style-name:"清单表 6 彩色 - 着色 4";
mso-table-condition:odd-column;
mso-style-priority:51;
mso-style-unhide:no;
mso-tstyle-shading:#FFF2CC;
mso-tstyle-shading-themecolor:accent4;
mso-tstyle-shading-themetint:51;}
table.MsoTable15List6ColorfulAccent4OddRow
{mso-style-name:"清单表 6 彩色 - 着色 4";
mso-table-condition:odd-row;
mso-style-priority:51;
mso-style-unhide:no;
mso-tstyle-shading:#FFF2CC;
mso-tstyle-shading-themecolor:accent4;
mso-tstyle-shading-themetint:51;}
优雅的将hbase的数据导入hive表
背景
Hive是一个构建在Hadoop基础设施之上的数据仓库。通过Hive可以使用HQL语言查询存放在HDFS上的数据。HQL是一种类SQL语言,这种语言最终被转化为Map/Reduce.
HBase是一种Key/Value系统,它运行在HDFS之上。和Hive不一样,Hbase的能够在它的数据库上实时运行,而不是运行MapReduce任务。
hive帮助熟悉SQL的人运行MapReduce任务。因为它是JDBC兼容的,同时,它也能够和现存的SQL工具整合在一起。HBase通过存储key/value来工作。它支持四种主要的操作:增加或者更新行,查看一个范围内的cell,获取指定的行,删除指定的行、列或者是列的版本。
由于hive目前不支持更新操作(非实时性)。所以在生产环境上不能直接将数据写入hive表,一般都是先将数据写到hbase上,而在大数据的计算及统计的时候,hive的读写速率大大优于hbase表,在处理大数据时(几TB的数据量),将会大大的提高挖掘的效率。
所以,比较常规的做法都是在生产环境下,将数据写入hbase表,再在数据挖掘的时候,将数据导入hive表,进行数据分析统计操作。
那怎么将数据从hbase表转入hive表里面呢,本文将介绍以下几种办法。
转换
将hbase的数据转换成hive,笔者知道的就有以下几种转换方式,下面一一道来。
创建hive外部关联表
在创建hive表的时候,指定与hbase某个表做为关联,如下所示的建表语句:
CREATE TABLE hive_table_hbase(key int, value1 string, value2 int, value3 int) STORED BY ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘ WITH SERDEPROPERTIES ( "hbase.columns.mapping"=":key,a:b,a:c,d:e" ) TBLPROPERTIES("hbase.table.name" = |
上面的语句翻译为:创建一个hive_table_hbase为名称的hive表,与hbase的some_existing_table表作关联,具体关联方式为字段对应:
hive_table_hbas |
some_existing_table |
key |
:key |
value1 |
a:b |
value2 |
a:c |
value3 |
d:e |
此种关联的好处是,将hbase与hive实时关联,hbase只要有数据更新,hive表当然就有了更新,不过要说明的时,此时,hive并没有分配空间去存储数据,仅仅只是做了一个映射。当然了,在使用大数据分析的时候,效率是很不好的。
从hbase将数据导入hive
此种实现思路是将hbase表的数据转成RDD(可查看上篇文章)模型,在将RDD转成DataFrame模型,注册Shark临时表,在就数据一次从临时表中,导入到hive表中
如下所示
<![endif]>
Shark临时表 |
<![if !vml]><![endif]>
Hive数据 |
<![ !><!<![if !vml]><>
RDD |
![f<!
此种转换,只是在hbase表数据导入到hive表的时候,会花费一定时间,但为后面的密集的hive表查询,大大增加了效率。
结论
在数据量比较小的时候,比如只有10几个G以下时,第一种效率比较高,因为没有转换的时间,当数据量超过10几个G后,且后续需要很密集的查询,当然要选第二种转换方式,一次转换,终生无忧!!
极点科技
诚信 专注 创新