Reputation: 8449
Counting the number of rows in Hbase can take a long time (see this question for example) - impractical for reasonably large tables/
However, I don't need the exact number - an estimate is enough (mainly to ensure the growth rate is as expected)
Is there some indirect \ less exact method to calculate table size? maybe based on storage usage? (the row sizes are more or less even)
Upvotes: 1
Views: 1503
Reputation: 378
You can use HBase coprocessors. They are available since 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);
make sure your hbase-site.xml have this property:
<property>
<name>hbase.coprocessor.user.region.classes</name>
<value>org.apache.hadoop.hbase.coprocessor.AggregateImplementation</value>
</property>
Upvotes: 4