A simple java class to calculate the number of rows for a table.
public class RowCount {
private static final byte[] TABLE_NAME = Bytes.toBytes("userdigest");
private static final byte[] CF = Bytes.toBytes("cf");
public static void main(String[] args) throws Throwable {
Configuration conf = new Configuration();
conf.set("hbase.rpc.timeout", "1000000");
conf.set("zookeeper.session.timeout", "300000");
conf.setLong("hbase.client.scanner.caching", 10000);
Configuration configuration = HBaseConfiguration.create(conf);
AggregationClient aggregationClient = new AggregationClient(configuration);
Scan scan = new Scan();
scan.addFamily(CF);
long rowCount = aggregationClient.rowCount(TABLE_NAME, null, scan);
System.out.println("row count is " + rowCount);
}
}
It didn't finish even after 2 hours.
Any insight on this?
The total number of rows for the table is about 2G(2,000,000,000).
Thanks,
Lei
[email protected]