一、


  1.预切割:在创建表的时候,预先对表进行region切割。切割线就是rowkey

$hbase> create 't1', 'f1', SPLITS => ['', '', '', '']
$hbase>create 'ns2:t3',SPLITS=>['row3000','row6000']  //创建表t3,并且进行预先切割
$hbase>desc 'ns2:t3'   //查看列族信息
$hbase>scan 'hbase:meta'   //查看切片信息
$hbaes>put 'ns2:t3','row5000','f1:name','tom'  //向表中添加数据
$hbase>flush 'ns2:t3'        //从内存中清理数据到磁盘中去
$hbase>create 'ns2:t4',{NAME=>'f1',VERSIONS=>3}  //创建表的时候指定列族的版本数,同一个列族下的所有列具有相同的版本数
$hbase>put 'ns2:t4','row1','f1:name','tom'    //向表中添加元素
$hbase>put 'ns2:t4','row1','f1:name','tomas'  //向表中添加元素
$hbase>put 'ns2:t4','row1','f1:name','tomson'
$hbase>get 'ns2:t4','row1'    //我们刚插入了三个数据,但是我们get数据的时候只能看到一个数据,默认查询的时候只显示最新的数据
$hbase>get 'ns2:t4','row1',{COLUMN=>f1,VERSIONS=>3}  //查看最近3个版本的数据
$hbase>get 'ns2:t4','row1',{COLUMN=>f1,VERSION=>2}    //在进行查询的时候可以指定显示的版本数为2
$hbase>get 'ns2:t4','row1',{COLUMN=>'f1',TIMESTAMP=>1531882253591} ############################################接下来演示原生扫描######################################
$hbase>scan 'ns2:t4',{COLUMN=>'f1',RAW=>true,VERSIONS=>10}  //进行原生扫描,扫描的版本数为10,可以将所有的历史版本数的数据都扫描出来
$hbase>scan 'ns2:t4',{COLUMN=>'f1',TTL=>10,VERSIONS=>3}      //创建一个表,存活时间为10秒,版本数为3

  2.创建文件的时候进行预切割,结果如下图,查看WEBUI16010

  

  3.批量与缓存

    1)扫描器缓存,是面向行一级的

 @Test
public void testScanCaching() throws Exception {
Configuration conf =HBaseConfiguration.create();
Connection conn = ConnectionFactory.createConnection(conf);
TableName tname = TableName.valueOf("ns1:t1");
Scan scan = new Scan();
scan.setCaching();
System.out.println(scan.getCaching());
Table table =conn.getTable(tname);
ResultScanner rs = table.getScanner(scan);
Iterator<Result> it= rs.iterator();
long start= System.currentTimeMillis();
while(it.hasNext()){
Result r = it.next();
System.out.println(r.getColumnLatestCell(Bytes.toBytes("f1"),Bytes.toBytes("name"))); }
System.out.println(System.currentTimeMillis()-start);
}

  2)批量扫描是面向列一级的,批量可以让用户选择每次ResultScanner实例的next()操作要返回多少列。比如在扫描中设置setBatch(5),则一次next()返回的Result实例会包括5列

    scan.setBatch(5);//每次next()都返回5列

  

最新文章

  1. STM32环境搭建/学习观点/自学方法 入门必看
  2. PDO的一些操作
  3. Java处理Excel整理篇
  4. js根据className获取元素封装
  5. python基础整理笔记(二)
  6. php 分页类
  7. 《javascript高级程序设计》第21章 Ajax和Comet
  8. 业务gis 搭建一个skyline 的js模板 (一)
  9. 雪花降落CAEmitterLayer粒子效果
  10. netty-all maven中 缺少jzlib
  11. oracle删除字段中的空格、回车及指定字符
  12. hibernate flushMode 错误
  13. HttpClient4.2 Fluent API学习
  14. 简单使用WebSocket实现聊天室
  15. Linux 设置最大链接
  16. abstract class和interface有什么区别?
  17. 01:MongoDB基础
  18. vue-router2.0
  19. mysql日期时间函数使用总结
  20. 异常之交叉编译---arm-vfp-linux-gnu/bin/ld: cgic.o: Relocations in generic ELF (EM: 3)

热门文章

  1. LibreOJ NOI Round #2 Day 1
  2. 分布式-信息方式-ActiveMQ的静态网络连接
  3. JavaWeb--Servlet 详解
  4. 15个流行的python框架
  5. 云服务器搭建anaconda pytorch torchvision
  6. 前端学习框架之layui
  7. AndroidStudio 插件 之 Findbugs 安装与简单使用教程
  8. 如何在Ubuntu / CentOS 6.x上安装Bugzilla 4.4
  9. Python学习之==&gt;面向对象编程(二)
  10. python一些包