使用HBase Shell建表的時候,除了一些常用的option以外,我們還可以同時建立一些預分區,這樣可以預防初次插入數據時熱點問題。
通過直接輸入create,我們可以看到有如下提示:
1
2
3
4
5
6
7
8
9
10
11
12
|
Examples: hbase> create
't1' , {NAME =>
'f1' , VERSIONS => 5} hbase> create
't1' , {NAME =>
'f1' }, {NAME =>
'f2' }, {NAME =>
'f3' } hbase>
# The above in shorthand would be the following: hbase> create
't1' , 'f1' ,
'f2' , 'f3' hbase> create
't1' , {NAME =>
'f1' , VERSIONS => 1, TTL => 2592000, BLOCKCACHE =>
true } hbase> create
't1' , 'f1' , {SPLITS => [ '10' ,
'20' , '30' ,
'40' ]} hbase> create
't1' , 'f1' , {SPLITS_FILE =>
'splits.txt' } hbase>
# Optionally pre-split the table into NUMREGIONS, using hbase>
# SPLITALGO ("HexStringSplit", "UniformSplit" or classname) hbase> create
't1' , 'f1' , {NUMREGIONS => 15, SPLITALGO =>
'HexStringSplit' } |
例子中僅給出了要麼有普通option,要麼是有指定分區等選項,但是沒有給出既有普通option(例如VERSIONS,COMPRESSION等),又創建預分區的例子。
如果有這個需求呢?如下對嗎?
create 't', {NAME => 'f', VERSIONS => 1, COMPRESSION => 'SNAPPY', SPLITS => ['10','20','30']}
運行後發現肯定是不行的。正確的寫法應該是這樣的:
1
2
|
create 't' , {NAME =>
'f' , VERSIONS => 1, COMPRESSION =>
'SNAPPY' },
{SPLITS => [ '10' , '20' , '30' ]} |
因爲分區時針對全表而非某個Column Family的。
轉載地址:http://shitouer.cn/2013/05/hbase-create-table-with-pre-splitting-and-other-options/