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 通过协调器进行表的行数统计的更多相关文章

  1. DM存储过程示例子-表的行数对比

    1.DM存储过程示例子,表的行数对比 1 --1. ================全量 2 --select * from DM_VERI where c2 != c3; 3 --drop tabl ...

  2. 【SQL】统计所有表的行数

    环境:mssql ent 2k8 r2 原理:遍历所有用户表,用sp_spaceused过程分别获取每张表的行数并写入临时表,最后返回临时表 IF OBJECT_ID('tempdb..#TableR ...

  3. 查看SqlAzure和SQLServer中的每个表数据行数

    SqlAzure中的方式: select t.name ,s.row_count from sys.tables t join sys.dm_db_partition_stats s ON t.obj ...

  4. sqlserver查询所有表的行数的sql语句

    原文:sqlserver查询所有表的行数的sql语句 select object_name(id),rowcnt from sysindexes where indid<2 and object ...

  5. 查询sql server 2008所有表和行数

    查询sql server 2008所有表和行数 SELECT a.name, b.rows FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.i ...

  6. 统计sql server 2012表的行数

    --功能:统计sql server 2012表的行数 SELECT a.name, a.object_id, b.rows, b.index_id FROM sys.tables AS a INNER ...

  7. 「日志」Navicat统计的行数竟然和表实际行数不一致

    背景 近期为了保障线上数据库的稳定性,我决定针对一些大表的历史数据有计划地进行备份迁移,但是呢,发现一个奇特的现象,Navicat统计行数和表自身count统计数竟然不一致!?0.0 Navicat ...

  8. Oracle 表的行数、表占用空间大小,列的非空行数、列占用空间大小 查询

    --表名,表占用空间大小(MB),行数select table_name, round(num_rows * avg_row_len /1024/1024, 8) as total_len, num_ ...

  9. 【MySQL】MySQL查询数据库各表的行数

    #倒序查询数据库[各表记录数] use information_schema; select table_name,table_rows from tables where TABLE_SCHEMA ...

随机推荐

  1. 用 Webgoat 撬动地球,看安全测试的引路石!

    测试工程师是很多人迈进软件行业的起点.从负责很小的局部到把握整个产品的质量,每个人花费的时间长短不一--从功能到性能.可用性到容错性.从兼容性到扩展性.稳定性到健壮性--方方面面逐渐做广做深. 不过, ...

  2. 关于Cookie跨域操作的一些总结

    正常的cookie只能在一个应用中共享,即一个cookie只能由创建它的应用获得. 1.可在同一应用服务器内共享方法:设置cookie.setPath("/");     本机to ...

  3. servlet和struts2一起使用,实现绝对路径下的图片输出到jsp页面

    如果我们在web.xml中配置的struts2的接收请求的路径为: <filter-mapping> <filter-name>struts2</filter-name& ...

  4. Delphi 记事本 TMemo(5篇)

    模仿的很不错,在本质上与windows记事本使用了同一个Edit. http://www.cnblogs.com/xe2011/category/524758.htmlhttp://www.cnblo ...

  5. 【HDOJ】1924 CIVIC DILL MIX

    简单字符串. #include <cstdio> #include <cstring> #define MAXN 55 char srca[MAXN], cas[MAXN], ...

  6. 用Robotium 去实现点击imageview

    今天用rototium做自动化遇到imageview无法点击的问题,最终解决如下: 有两种方法: 1.View v = solo.getView(R.id.iv_main_setting);      ...

  7. BZOJ1606: [Usaco2008 Dec]Hay For Sale 购买干草

    1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 612  Solved: 46 ...

  8. ServiceStack.Redis 之 IRedisTypedClient

    IRedisTypedClient IRedisTypedClient类相当于IRedicClient的强类型版,其方法与属性大多数与IRedisClient类似. 它支持在Redis中使用Linq查 ...

  9. 【转】VC++ MFC 常用技巧(一)

    原文网址:http://www.lewensky.cn/read.php/106.htm (-). 下面是常见的Afx全局函数: AfxFormatString1:类似printf一般地将字符串格式化 ...

  10. oracle查询语句2【转载】

    本文使用的实例表结构与表的数据如下: scott.emp员工表结构如下:   SQL> DESC SCOTT.EMP; Name     Type         Nullable Defaul ...