org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计hbase表的行数
来源:互联网 发布:帝国cms 调用相关内容 编辑:程序博客网 时间:2024/06/09 21:41
hbase自带了一个聚合coprocessor类:org.apache.hadoop.hbase.coprocessor.AggregateImplementation。使用该类可以count一张表的总记录数。
当然在hbase shell下面也可以count <table_name>来统计。我这里比较了一下两者的执行时间,我有一张表有700多万的数据,在hbase shell下count足足花费了我12分钟的时间,而用coprocessor来统计,只花费了78秒!!!由此可见coprocessor的强大。
hbase aip 添加协处理器:
- Configuration hbaseconfig = HBaseConfiguration.create();
- HBaseAdmin hbaseAdmin = new HBaseAdmin(hbaseconfig);
- hbaseAdmin.disableTable(TABLE_NAME);
- HTableDescriptor htd = hbaseAdmin.getTableDescriptor(TABLE_NAME);
- htd.addCoprocessor(AggregateImplementation.class.getName());
- hbaseAdmin.modifyTable(TABLE_NAME, htd);
- hbaseAdmin.enableTable(TABLE_NAME);
- hbaseAdmin.close();
使用hbase提供的聚合coprocessor:
- AggregationClient aggregationClient = new AggregationClient(hbaseconfig);
- Scan scan = new Scan();
- scan.addFamily(Bytes.toBytes("fr"));
- Date start = new Date();
- long rowcount = aggregationClient.rowCount(TABLE_NAME,
- new LongColumnInterpreter(), scan);
- Date end = new Date();
- System.out.println("rowcount:" + rowcount);
- System.out.println("timecost:" + (end.getTime() - start.getTime()));
hbase shell添加coprocessor:
disable 'member'
alter 'member',METHOD => 'table_att','coprocessor' => 'hdfs://master24:9000/user/hadoop/jars/test.jar|mycoprocessor.SampleCoprocessor|1001|'
enable 'member'
hbase shell 删除coprocessor:
disable 'member'
alter 'member',METHOD => 'table_att_unset',NAME =>'coprocessor$1'
enable 'member'
0 0
- org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计hbase表的行数
- org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计表的行数
- org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计表的行数
- HBase源码分析之org.apache.hadoop.hbase.coprocessor包
- 【HBase】1009-HBase的协处理器(coprocessor)统计行数
- HBase源码分析之org.apache.hadoop.hbase.client.coprocessor包
- HBase学习之三: hbase filter(过滤器)和coprocessor(协处理器)统计行数的简单应用
- hbase协处理器coprocessor 统计行数量 案例
- trafodion Exception ERROR Class org.apache.hadoop.hbase.coprocessor.transactional.TrxRegionEndpoint
- hbase filter(过滤器)和coprocessor(协处理器)统计行数的简单应用
- 【HBase】org.apache.hadoop.hbase包及其类的说明
- Hbase 创建表出现异常 org.apache.hadoop.hbase.TableExist
- hbase org.apache.hadoop.hbase.ClockOutOfSyncException
- org.apache.hadoop.hbase.ClockOutOfSyncException
- org.apache.hadoop.hbase.ClockOutOfSyncException
- HBase Coprocessor的分析
- hbase coprocessor的分析
- hbase的coprocessor使用
- 机房收费总结之硕果累累
- java别名机制
- 介绍一种新的集成学习框架--grading classifiers
- cocos2D(九)---- CCAction
- iOS8 Could not inspect the application package.问题解决方法
- org.apache.hadoop.hbase.coprocessor.AggregateImplementation 来统计hbase表的行数
- Android drawable-nodpi 的作用
- android安装包apk的秘密
- JAVA监听磁盘文件状态的变化
- 高斯滤波(opencv)
- IOS TableView的Cell高度自适应,UILabel自动换行适应
- sqlite时间类型
- Oracle Job 语法和时间间隔的设定
- C++运算符学习笔记之++i与i++