row keys through the hbase shell?

2019-03-09 10:05发布

I am using

 scan 'table_name', { COLUMNS => 'column_family:column_qualifier', LIMIT => 2 }

to list 2 rows in a hbase table but I would like to know if it is possible to achieve following using hbase shell:

Questions

  1. list all row keys through the hbase shell?
  2. list only those rows, whose row keys have a particular word in it?

标签: hbase
3条回答
可以哭但决不认输i
2楼-- · 2019-03-09 10:26

A1. hbase(main):015:0> count 'table_name', INTERVAL => 1

A2. Use RowKey filter with SubstringComparator.

Usage :

hbase(main):003:0> import org.apache.hadoop.hbase.filter.CompareFilter
hbase(main):005:0> import org.apache.hadoop.hbase.filter.SubstringComparator
hbase(main):006:0> scan 'test', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new("word_by_which_you_want_to_search"))}
查看更多
家丑人穷心不美
3楼-- · 2019-03-09 10:34

Earlier solution would be:

scan 'test', { 
  COLUMNS => ['col_family_name:col_name'], 
  FILTER => "RowFilter(=, 'substring:the_string_to_be_compared')" 
}
查看更多
狗以群分
4楼-- · 2019-03-09 10:40

KeyOnlyFilter - takes no arguments. Returns the key portion of each key-value pair.

Syntax: KeyOnlyFilter ()

查看更多
登录 后发表回答