• 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");  
  • 相关阅读:
    Python 进程管理工具 Supervisor 使用教程
    Python cx_Oracle 安装小记
    使用 IIS 过程中遇到的一些问题
    http请求的post提交数据的四种格式form-data,row,binary,urlencode
    sqlmap 笔记
    数据库服务器及命令行相关操作
    SDL应用软件安全研发周期
    ldap目录访问协议
    计算机行业证书解释
    gunicorn Python部署应用
  • 原文地址:https://www.cnblogs.com/malcolmfeng/p/9370118.html
Copyright © 2020-2023  润新知