主要用来过滤剩下行键计数一类

KeyOnlyFilter

官方API解释如下:

A filter that will only return the key component of each KV (the value will be rewritten as empty).

This filter can be used to grab all of the keys without having to also grab the values.

此filter可以用来计数,但是效率没有FirstKeyOnlyFilter高

如果需要用FirstKeyOnlyFilter 可以参考我这篇关于FirstKeyOnlyFilter的文章,地址如下

http://blog.csdn.NET/liuxiaochen123/article/details/7878580

KeyOnlyFilter实例代码如下,比较简单,意思到就行

  1. <span style="font-size:12px;">public int getCount1() {
  2. long bef = System.currentTimeMillis();
  3. int i = 0;
  4. ResultScanner rs = null;
  5. try {
  6. Scan s = new Scan();
  7. s.setCaching(500);
  8. s.setCacheBlocks(false);
  9. s.setFilter(new KeyOnlyFilter());
  10. rs = tableKeyword.getScanner(s);
  11. } catch (IOException e) {
  12. log.warn(e);
  13. e.printStackTrace();
  14. }
  15. for (org.apache.hadoop.hbase.client.Result r : rs) {
  16. i++ ;
  17. }
  18. long now = System.currentTimeMillis();
  19. log.warn("keyword表中数据总数 :" + i + ", 所用时间 : " + (now - bef)/1000.0);
  20. rs.close();
  21. return i;
  22. }</span>

最好设置tableKeyword.setScannerCaching(500);

s.setCaching(500);
s.setCacheBlocks(false);这三个参数,否则速度会降下来很多

总的来说,可以节省很多时间

最新文章

  1. 邮件群发工具(C#版)
  2. Interview----判断两个链表是否相交?
  3. 《MORE EFFECTIVE C++》条款27 要求或者禁止对象分配在堆上
  4. ios特性访问器方法(setter和getter)
  5. 学习笔记_Java_day13_三层的HelloWorld程序(15)--不错,整体三层架构学习
  6. DontDestroyOnLoad
  7. 面向对象设计模式之Interpreter解释器模式(行为型)
  8. 在ASP.NET MVC自定义错误页面
  9. start.sh
  10. [HDU 4741]Save Labman No.004[计算几何][精度]
  11. Codeforces 320A Magic Numbers
  12. 一个简单的php站点配置
  13. yii2.0使用之缓存
  14. Vue.js优雅的实现列表清单
  15. Windbg+VirtualBox双机调试环境配置(XP/Win7/Win10)
  16. FastDFS使用
  17. Android获取网络状态
  18. vue confirm确认
  19. spring boot + mybatis + druid + redis
  20. Hive SQL 编译过程

热门文章

  1. 基于token的验证
  2. day 1 预习
  3. 洛谷P3239 [HNOI2015]亚瑟王
  4. Ascii码 、16进制与 char
  5. var、fucntion关键字优先级问题
  6. Atcoder arc085
  7. CSS3 学习笔记(动画 多媒体查询)
  8. pixi.js 学习
  9. mysql插入数据显示:Incorrect datetime value: &#39;0000-00-00 00:00:00&#39;
  10. Netty SimpleChannelInboundHandler和ChannelInboundHandler区别