I'm looking for an HBase shell command that will count the number of records in a specified column family. I know I can run:
echo "scan 'table_name'" | hbase shell | grep column_family_name | wc -l
however this will run much slower than the standard counting command:
count 'table_name' , CACHE => 50000 (because the use of the CACHE=>50000)
and worse - it doesn't return the real number of records, but something like the total number of cells (if I'm not mistaken?) in the specified column family. I need something of the sort:
count 'table_name' , CACHE => 50000 , {COLUMNS => 'column_family_name'}
Thanks in advance,
Michael
Here is Ruby code I have written when needed thing like you need. Appropriate comments are provided. It provides you with
HBase
shellcount_table
command. First parameter is table name and second is array of properties, the same as forscan
shell command.Direct answer to your question is
I also recommend to add cache, like for scan:
And here you go with sources: