Hbase quickly count number of rows

前端 未结 12 1583
轮回少年
轮回少年 2020-12-04 13:25

Right now I implement row count over ResultScanner like this

for (Result rs = scanner.next(); rs != null; rs = scanner.next()) {
    number++;
}         


        
12条回答
  •  醉酒成梦
    2020-12-04 13:54

    Two ways Worked for me to get count of rows from hbase table with Speed

    Scenario #1

    If hbase table size is small then login to hbase shell with valid user and execute

    >count ''
    

    Example

    >count 'employee'
    
    6 row(s) in 0.1110 seconds
    

    Scenario #2

    If hbase table size is large,then execute inbuilt RowCounter map reduce job: Login to hadoop machine with valid user and execute:

    /$HBASE_HOME/bin/hbase org.apache.hadoop.hbase.mapreduce.RowCounter ''
    

    Example:

     /$HBASE_HOME/bin/hbase org.apache.hadoop.hbase.mapreduce.RowCounter 'employee'
    
         ....
         ....
         ....
         Virtual memory (bytes) snapshot=22594633728
                    Total committed heap usage (bytes)=5093457920
            org.apache.hadoop.hbase.mapreduce.RowCounter$RowCounterMapper$Counters
                    ROWS=6
            File Input Format Counters
                    Bytes Read=0
            File Output Format Counters
                    Bytes Written=0
    

提交回复
热议问题