KeyOnlyFilter(2)
2024-09-06 12:41:12
主要用来过滤剩下行键计数一类
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实例代码如下,比较简单,意思到就行
- <span style="font-size:12px;">public int getCount1() {
- long bef = System.currentTimeMillis();
- int i = 0;
- ResultScanner rs = null;
- try {
- Scan s = new Scan();
- s.setCaching(500);
- s.setCacheBlocks(false);
- s.setFilter(new KeyOnlyFilter());
- rs = tableKeyword.getScanner(s);
- } catch (IOException e) {
- log.warn(e);
- e.printStackTrace();
- }
- for (org.apache.hadoop.hbase.client.Result r : rs) {
- i++ ;
- }
- long now = System.currentTimeMillis();
- log.warn("keyword表中数据总数 :" + i + ", 所用时间 : " + (now - bef)/1000.0);
- rs.close();
- return i;
- }</span>
最好设置tableKeyword.setScannerCaching(500);
s.setCaching(500);
s.setCacheBlocks(false);这三个参数,否则速度会降下来很多
总的来说,可以节省很多时间
最新文章
- 邮件群发工具(C#版)
- Interview----判断两个链表是否相交?
- 《MORE EFFECTIVE C++》条款27 要求或者禁止对象分配在堆上
- ios特性访问器方法(setter和getter)
- 学习笔记_Java_day13_三层的HelloWorld程序(15)--不错,整体三层架构学习
- DontDestroyOnLoad
- 面向对象设计模式之Interpreter解释器模式(行为型)
- 在ASP.NET MVC自定义错误页面
- start.sh
- [HDU 4741]Save Labman No.004[计算几何][精度]
- Codeforces 320A Magic Numbers
- 一个简单的php站点配置
- yii2.0使用之缓存
- Vue.js优雅的实现列表清单
- Windbg+VirtualBox双机调试环境配置(XP/Win7/Win10)
- FastDFS使用
- Android获取网络状态
- vue confirm确认
- spring boot + mybatis + druid + redis
- Hive SQL 编译过程
热门文章
- 基于token的验证
- day 1 预习
- 洛谷P3239 [HNOI2015]亚瑟王
- Ascii码 、16进制与 char
- var、fucntion关键字优先级问题
- Atcoder arc085
- CSS3 学习笔记(动画 多媒体查询)
- pixi.js 学习
- mysql插入数据显示:Incorrect datetime value: &#39;0000-00-00 00:00:00&#39;
- Netty SimpleChannelInboundHandler和ChannelInboundHandler区别