zz:http://blog.csdn.net/chaolovejia/article/details/46328983
Sometimes we need to count the number of rows in a hbase table, because the hbase itself does not support the SQL language and can only be implemented in other ways. There are several ways to implement the HBase table statistics work:
1.count Command
The most straightforward way to do this is to count the number of rows in a command that executes count in the HBase shell.
[HTML] view plain copy hbase> count ' t1′hbase> count ' t1′, INTERVAL => 100000 hbase> count ' t1 ′, Cache => 1000 hbase> count ' t1′, INTERVAL =>, Cache => 1000
Where the interval is a statistical row number interval, the default is 1000,cache for the statistical data cache. This approach is inefficient and is not recommended in the case of a large number of table rows.
2. Call MapReduce [Plain]View plain copy $HBASE _home/bin/hbase org.apache.hadoop.hbase.mapreduce.RowCounter ' tablename ' This way is much more efficient than the previous one, calling the HBA The class of the number of statistical rows that are brought in the SE jar.
3.hive over HBaseIf you have already seen the associated tables for hive and HBase, you can execute SQL statement statistics hbase table rows directly in hive. The Hive over HBase Table statement is:/* Create the Hive and HBase Association table * *
[SQL]View plain copy CREATE TABLE hive_hbase_1 (key Int,value STRING) STORED by ' Org.apache.hadoop.hive.hbase.HBaseStorageHan Dler ' with serdeproperties ("hbase.columns.mapping" = ": Key,cf:val") tblproperties ("hbase.table.name" = "t_hive", " Hbase.table.default.storage.type "=" binary "); /*hive Association already exists hbase*/
[SQL] View Plain copy create external 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 ");