1. specifying string literals
hbase(main):019:0> create 't4','f1',SPLITS=>['10','20','30']
Created table t4
Took 2.3882 seconds
image-20200630152538595.png
2. from a file corresponding to the local path on the local filesystem
# Each line in the file specifies a split point key.
[root@host-10-1-236-145 hbase_test]# cat splits.txt
10
20
30
hbase(main):021:0> create 't5','f1',SPLITS_FILE=>'/root/jiazz/hbase_test/splits.txt'
Created table t5
Took 1.5613 seconds
=> Hbase::Table - t5
3. splits based on a desired number of regions and a splitting algorithm
hbase(main):039:0> create 't2','f1', { NUMREGIONS => 4 , SPLITALGO => 'UniformSplit' }
Created table t2
Took 2.2856 seconds
=> Hbase::Table - t2
image-20200630153243626.png
hbase(main):040:0> create 't3','f1', { NUMREGIONS => 5, SPLITALGO => 'HexStringSplit' }
Created table t3
Took 2.3487 seconds
=> Hbase::Table - t3
image-20200630153356604.png
4. simple Ruby scripts to compute splits algorithmically
hbase(main):049:0> def gen_splits(start_key,end_key,num_regions)
hbase(main):050:1> results=[]
hbase(main):051:1> range=end_key-start_key
hbase(main):052:1> incr=(range/num_regions).floor
hbase(main):054:1> for i in 1 .. num_regions-1
hbase(main):055:2> results.push([i*incr+start_key].pack("N"))
hbase(main):056:2> end
hbase(main):057:1> return results
hbase(main):058:1> end
=> :gen_splits
hbase(main):059:0> splits=gen_splits(1,2000000,10)
=> ["\x00\x03\r@", "\x00\x06\x1A\x7F", "\x00\t'\xBE", "\x00\f4\xFD", "\x00\x0FB<", "\x00\x12O{", "\x00\x15\\\xBA", "\x00\x18i\xF9", "\x00\ew8"]
hbase(main):060:0> create 'test_splits','f',SPLITS=>splits
Created table test_splits
Took 2.3220 seconds
=> Hbase::Table - test_splits
hbase(main):061:0>
image-20200630154151420.png
网友评论