zoukankan      html  css  js  c++  java
  • Hbase 统计行数的四种方式

    1.shell中执行count的命令:

        count ‘t1′, INTERVAL => 10, CACHE => 1000     

        INTERVAL为统计的行数间隔,默认为1000,CACHE为统计的数据缓存。这种方式效率很低,如果表行数很大的话不建议采用这种方式。

    2.Hbase自带 mapreduce 工具类:

        shell 中执行 :$HBASE_HOME/bin/hbase   org.apache.hadoop.hbase.mapreduce.RowCounter ‘tablename’

    3.使用 coprocessor 新特性:

         Configuration conf = HBaseConfiguration.create();
            HTable hTable = new HTable(conf, TableName.valueOf("T_REVIEW_MODULE"));
            LongColumnInterpreter columnInterpreter = new LongColumnInterpreter();
            AggregationClient aggregationClient = new AggregationClient(conf);
    
            Scan scan = new Scan( Bytes.toBytes("2018-07-01 12:12:12"), Bytes.toBytes("2018-07-27 12:12:12"));
    
            Long count = aggregationClient.rowCount(hTable, columnInterpreter, scan);

    4.hive over hbase:用hive的语句创建hbase的关联表,可以直接在hive中执行sql语句统计hbase表的行数。创建关联表的语句:

    CREATE TABLE hive_hbase_1(key INT,value STRING)  
    STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  
    WITH SERDEPROPERTIES ("hbase.columns.mapping"=":key,cf:val")  
    TBLPROPERTIES("hbase.table.name"="t_hive","hbase.table.default.storage.type"="binary");  
  • 相关阅读:
    Oracle 实现数据表插入时主键列自增
    Java BigDecimal 加减乘除用法
    php最常见最经典的算法题(1)
    2、php-选择排序方法
    1、php-冒泡排序方法
    65G-一系列Go语言课程Go基础知识高级Go项目战斗New Go语言和区块链开发实践课程
    css
    python基础
    SEO优化指南
    转载GXT之旅
  • 原文地址:https://www.cnblogs.com/malcolmfeng/p/9370118.html
Copyright © 2011-2022 走看看