如何快速计算Hbase表中的大致行数?

如何快速计算Hbase表中的大致行数?,hbase,Hbase,计算Hbase中的行数可能需要很长时间(例如,请参见此示例)-对于相当大的表来说是不切实际的/ 然而,我不需要确切的数字——估计就足够了(主要是为了确保增长率如预期的那样) 是否有一些间接\不太精确的方法来计算表格大小? 可能是基于存储使用情况?(行大小大致相等)您可以使用HBase协处理器。它们从HBase 0.92开始提供 AggregationClient aggregationClient = new AggregationClient(conf); Scan scan

计算Hbase中的行数可能需要很长时间(例如,请参见此示例)-对于相当大的表来说是不切实际的/

然而,我不需要确切的数字——估计就足够了(主要是为了确保增长率如预期的那样)

是否有一些间接\不太精确的方法来计算表格大小?
可能是基于存储使用情况?(行大小大致相等)

您可以使用HBase协处理器。它们从HBase 0.92开始提供

    AggregationClient aggregationClient = new AggregationClient(conf);
    Scan scan = new Scan();
    scan.addFamily(Bytes.toBytes("provide_one_table_family_name"));
    long rowCount = aggregationClient.rowCount(Bytes.toBytes("your_table_name"), null, scan);
    log.info("row count is " + rowCount);
确保您的hbase-site.xml具有以下属性:

<property>
  <name>hbase.coprocessor.user.region.classes</name>
  <value>org.apache.hadoop.hbase.coprocessor.AggregateImplementation</value>
</property>

hbase.coprocessor.user.region.classes
org.apache.hadoop.hbase.coprocessor.AggregateImplementation

您可以使用HBase协处理器。它们从HBase 0.92开始提供

    AggregationClient aggregationClient = new AggregationClient(conf);
    Scan scan = new Scan();
    scan.addFamily(Bytes.toBytes("provide_one_table_family_name"));
    long rowCount = aggregationClient.rowCount(Bytes.toBytes("your_table_name"), null, scan);
    log.info("row count is " + rowCount);
确保您的hbase-site.xml具有以下属性:

<property>
  <name>hbase.coprocessor.user.region.classes</name>
  <value>org.apache.hadoop.hbase.coprocessor.AggregateImplementation</value>
</property>

hbase.coprocessor.user.region.classes
org.apache.hadoop.hbase.coprocessor.AggregateImplementation