HBase0.98.1 通过协调器进行表的行数统计
1. 启用表aggregation,只对特定的表生效。通过HBase Shell 来实现
(1)disable指定表。hbase> disable 'student'
(2)添加aggregation hbase> alter 'student', METHOD => 'table_att','coprocessor'=>'|org.apache.hadoop.hbase.coprocessor.AggregateImplementation||'
(3)重启指定表 hbase> enable 'student'
2. Eclipse Code
package com.sc.hbase;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.coprocessor.AggregationClient;
import org.apache.hadoop.hbase.client.coprocessor.LongColumnInterpreter;
import org.apache.hadoop.hbase.util.Bytes;
public class HbaseTest {
private static final byte[] TABLE_NAME = Bytes.toBytes("student");
private static final byte[] CF = Bytes.toBytes("info");
public static void main(String[] args) {
Configuration configuration = HBaseConfiguration.create();
LongColumnInterpreter columnInterpreter = new LongColumnInterpreter();
AggregationClient aggregationClient = new AggregationClient(configuration);
Scan scan = new Scan();
// 指定扫描列族,唯一值
scan.addFamily(CF);
long rowCount;
try {
rowCount = aggregationClient.rowCount(TableName.valueOf(TABLE_NAME), columnInterpreter, scan);
System.out.println("row count is " + rowCount);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
HBase0.98.1 通过协调器进行表的行数统计的更多相关文章
- DM存储过程示例子-表的行数对比
1.DM存储过程示例子,表的行数对比 1 --1. ================全量 2 --select * from DM_VERI where c2 != c3; 3 --drop tabl ...
- 【SQL】统计所有表的行数
环境:mssql ent 2k8 r2 原理:遍历所有用户表,用sp_spaceused过程分别获取每张表的行数并写入临时表,最后返回临时表 IF OBJECT_ID('tempdb..#TableR ...
- 查看SqlAzure和SQLServer中的每个表数据行数
SqlAzure中的方式: select t.name ,s.row_count from sys.tables t join sys.dm_db_partition_stats s ON t.obj ...
- sqlserver查询所有表的行数的sql语句
原文:sqlserver查询所有表的行数的sql语句 select object_name(id),rowcnt from sysindexes where indid<2 and object ...
- 查询sql server 2008所有表和行数
查询sql server 2008所有表和行数 SELECT a.name, b.rows FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.i ...
- 统计sql server 2012表的行数
--功能:统计sql server 2012表的行数 SELECT a.name, a.object_id, b.rows, b.index_id FROM sys.tables AS a INNER ...
- 「日志」Navicat统计的行数竟然和表实际行数不一致
背景 近期为了保障线上数据库的稳定性,我决定针对一些大表的历史数据有计划地进行备份迁移,但是呢,发现一个奇特的现象,Navicat统计行数和表自身count统计数竟然不一致!?0.0 Navicat ...
- Oracle 表的行数、表占用空间大小,列的非空行数、列占用空间大小 查询
--表名,表占用空间大小(MB),行数select table_name, round(num_rows * avg_row_len /1024/1024, 8) as total_len, num_ ...
- 【MySQL】MySQL查询数据库各表的行数
#倒序查询数据库[各表记录数] use information_schema; select table_name,table_rows from tables where TABLE_SCHEMA ...
随机推荐
- AWK 简明教程
AWK 简明教程 转自:http://coolshell.cn/articles/9070.html 有一些网友看了前两天的<Linux下应该知道的技巧>希望我能教教他们用awk和sed, ...
- java 表格项的删除、编辑、增加 修改版
修改之后的java 代码: package com.platformda.optimize; import java.awt.BorderLayout; import java.awt.Button; ...
- Android textView 动态设置代码字号大小,支持单位选项 dp,sp or px
setTextSize(TypedValue.COMPLEX_UNIT_PX,22); //22像素 setTextSize(TypedValue.COMPLEX_UNIT_SP,22); //22S ...
- R语言 多元线性回归分析
#线性模型中有关函数#基本函数 a<-lm(模型公式,数据源) #anova(a)计算方差分析表#coef(a)提取模型系数#devinace(a)计算残差平方和#formula(a)提取模型公 ...
- php5.4下安装ECshop出现错误的解决办法
转:http://www.programmernote.com/?p=65 1.安装是会提示 Warning: date_default_timezone_get(): It is not safe ...
- 怎样打开64位 Ubuntu 的32位支持功能?
怎样打开64位 Ubuntu 的32位支持功能? 现在有一个让你可以在64位系统中使用32位软件的方法,就在你读了这篇文章然后照着做了之后就可以了.如果你有一个13.10或更高版本的Ubuntu/De ...
- CentOS添加swap分区
在多个VPS上尝试. 1.进入目录 cd /var/ 2.获取要增加的SWAP文件块(这里以1GB为例) dd if=/dev/zero of=swapfile bs=1024 count=10383 ...
- 佛山Uber优步司机奖励政策(1月25日~1月31日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 关于android 自己实现 back键 home键
今天在被问到一个问题的时候突然想要看看这些东西了.因为一直以来,我返回上个界面,和大家普遍的方法都是一样的. 1. finish()本页面. 2. intent 跳转到上个页面. 一 ,在 按下手机上 ...
- Node.js学习(12)----Web应用开发
1.使用http模块 Node.js 由于不需要另外的 HTTP 服务器,因此减少了一层抽象,给性能带来不少提升, 但同时也因此而提高了开发难度.举例来说,我们要实现一个 POST 数据的表单,例如: ...