Hbase quickly count number of rows

前端 未结 12 1568
轮回少年
轮回少年 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

    Use RowCounter in HBase RowCounter is a mapreduce job to count all the rows of a table. This is a good utility to use as a sanity check to ensure that HBase can read all the blocks of a table if there are any concerns of metadata inconsistency. It will run the mapreduce all in a single process but it will run faster if you have a MapReduce cluster in place for it to exploit.

    $ hbase org.apache.hadoop.hbase.mapreduce.RowCounter 
    
    Usage: RowCounter [options] 
         [          
            --starttime=[start] 
            --endtime=[end] 
            [--range=[startKey],[endKey]] 
            [ ...]
        ]
    

提交回复
热议问题