I have a multiple HBase tables. Each table is having Millions of records. What is the best or fastest way to count the number of records. Through below program i will get the count but i want some some fastest way to count the records.
def getTotalRecords(connection: Connection, tableName: String): Long = {
val startTime = System.currentTimeMillis();
val table = connection.getTable(TableName.valueOf(Bytes.toBytes(tableName)))
var resultScanner: ResultScanner = table.getScanner(new Scan());
var count: Long = 0;
while (resultScanner.next() != null) {
count = count + 1;
}
val endTime = System.currentTimeMillis();
val timeDiff = endTime - startTime
println(s"$tableName - Time taken $timeDiff")
count
}