region预切割 SPLITS => ['row20000','row25000','row50000','row75000']

 
创建命名空间
create_namespace 'test'
 
 
建表时  预切割region
create 'test:t1','f1',SPLITS => ['row20000','row25000','row50000','row75000']
 
 
16010 查看预切分的region
 
 
 
 1 @Test
 2 public void putData2() throws Exception {
 3  
 4     //初始化hbase 的conf
 5     Configuration conf = HBaseConfiguration.create();
 6  
 7     //通过连接工厂创建连接
 8     Connection conn = ConnectionFactory.createConnection(conf);
 9     //得到相应数据库的表
10     HTable table = (HTable) conn.getTable(TableName.valueOf("test:t1"));
11  
12     //设置自动刷写为false
13     table.setAutoFlush(false,false);
14  
15     //put列表
16     List<Put> list = new LinkedList<Put>();
17  
18     long start = System.currentTimeMillis();
19     for (int i = 1; i < 100000; i++) {
20         //Bytes.toBytes()可以将任意类型转换成字节数组
21         Put put = new Put(Bytes.toBytes("row" + i));//    Put( 键值row-key )
22  
23         put.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("name"), Bytes.toBytes("tom"+i));//   向当前row-key的列族添加数据 addColumn(列族,列限定符,值)
24         put.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("id"), Bytes.toBytes(i+""));
25         put.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("age"), Bytes.toBytes(i % 100 +""));
26         list.add(put); //把一条数据加载放到list集合中
27     }
28  
29     table.put(list);//把集合中的数据上传到表中
30     table.flushCommits();//表提交刷新
31  
32     table.close();
33     conn.close();
34  
35     System.out.println(System.currentTimeMillis() - start);
36  
37 }

 

刷新到磁盘
hbase(main):005:0> flush 'test:t1'
 
16010查看传入数据后的 region 和regionserver

 

 
50070 查看Store 
 
 
分别查看5个region的大小  
[centos@s101 ~]$ hadoop dfs -du  /user/hbase/data/test/t1/33488729d265256907af7e03682078a1
 
 
 
 
 
 
posted @ 2018-08-23 21:41  star521  阅读(154)  评论(0编辑  收藏  举报