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. ios7新特性3-Map Kit新特性

    Map Kit 框架 (MapKit.framework) 包含了大量的改进以及为基于地图的程序提供了新特性.利用地图显示位置信息的应用现在可以使用Maps这个程序用到的3D地图,包括控制程序控制视线 ...

  2. OneAlert 入门(一)——事件流

    OneAlert 入门(一)--事件流 OneAlert 是国内首个 SaaS 模式的云告警平台,集成国内外主流监控/支撑系统,实现一个平台上集中处理所有 IT 事件,提升 IT 可靠性.它能以史上第 ...

  3. 【POJ1067】取石子游戏 (威佐夫博弈)

    [题目] Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的 ...

  4. 报错java.net.SocketException: Software caused connection abort: recv failed 怎么办

    产生这个异常的原因有多种方面,单就如 Software caused 所示, 是由于程序编写的问题,而不是网络的问题引起的. 已知会导致这种异常的一个场景如下: 客户端和服务端建立tcp的短连接,每次 ...

  5. [cocos2d] 谁摸了我一下----触摸事件处理

    1. 设置接受触摸事件,可在init方法里面写上 [self setTouchEnabled: YES]; 旧版为self.isTouchEnabled = YES; xcode会报Deprecati ...

  6. 14.5.5 Deadlocks in InnoDB

    14.5.5 Deadlocks in InnoDB 14.5.5.1 An InnoDB Deadlock Example 14.5.5.2 Deadlock Detection and Rollb ...

  7. BZOJ1613: [Usaco2007 Jan]Running贝茜的晨练计划

    1613: [Usaco2007 Jan]Running贝茜的晨练计划 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1138  Solved: 554[ ...

  8. Win32中常用消息

    一 .WM_PAINT消息 1 WM_PAINT的产生   由于窗口的互相覆盖等,产生需要绘制的区域,那么会产生WM_PAINT消息. 一般情况下,不直接发送WM_PAINT消息,通过API声明需要绘 ...

  9. Git error: hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused b

    hint: Updates were rejected because the remote contains work that you dohint: not have locally. This ...

  10. JavaScript 设计风格&模式 概览 20140418

    基本的概念 在JavaScript中,一旦定义好一个变量,该变量会自动成为内置对象的一个属性,(如果该变量是全局变量,那么会成为全局对象的一个属性). 定义的变量实际上也是一个伪类,拥有自身的属性,该 ...