Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

row keys through the hbase shell?

Tags:

hbase

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?
like image 661
user2360096 Avatar asked May 31 '13 04:05

user2360096


People also ask

What is row key in HBase?

A row key is a unique identifier for the table row. An HBase table is a multi-dimensional map comprised of one or more columns and rows of data. You specify the complete set of column families when you create an HBase table.

How do I insert a row in HBase?

To insert data into an HBase table, the add() method and its variants are used. This method belongs to Put, therefore instantiate the put class. This class requires the row name you want to insert the data into, in string format. You can instantiate the Put class as shown below.

Which command gives a row or cell contents present in the table in HBase?

Put command, puts a cell 'value' at specified table/row/column and optionally timestamp coordinates. This command disables, drops and recreates the specified table. Make sure, the schema will be present but not the records, just after truncate of an HBase table.


2 Answers

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"))}
like image 70
Tariq Avatar answered Dec 29 '22 02:12

Tariq


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

Syntax: KeyOnlyFilter ()

like image 44
Ashwin91 Avatar answered Dec 29 '22 04:12

Ashwin91