Summary of the number of Hbase statistics in 3 ways __hbase

Source: Internet
Author: User

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 ");  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.