How can we fetch the data for a given condition in HBase?



0
e.g :

In hbase i have created the data for table called 'Student' :
put 'student', 'first', 'details:name', 'prashanth'
put 'student', 'first', 'details:age', '39'
put 'student', 'first', 'details:gender', 'M'
put 'student', 'second', 'details:name', 'Mary'
put 'student', 'second', 'details:name', '35'

How can i fetch the data for 'Mary' only or anybody who has age less than '38'?

3 Answer(s)


0

Hey Swati,
Use query (get '', '', ':') to get any particular row in Hbase table, showed table contents and then query used in my system:

============================
hbase(main):013:0> scan 'student'
ROW COLUMN+CELL
first column=details:age, timestamp=1445562227112, value=39
first column=details:gender, timestamp=1445562236261, value=M
first column=details:name, timestamp=1445562205022, value=prashanth
second column=details:name, timestamp=1445562317027, value=Mary
2 row(s) in 0.0110 seconds

hbase(main):014:0> get 'student', 'second', 'details:name'
COLUMN CELL
details:name timestamp=1445562317027, value=Mary
1 row(s) in 0.0100 seconds
==========================

For complex or conditional queries normally we have to write small java functions.

Hope this helps!

Thanks!
Surendra

0

sorry in last reply as I used Less than and Greater than symbols, all values are not showing in generic query.. below is the generic query I tried to sent:

Generic query to get any particular row in Hbase table:

get 'tablename', 'rowid', 'columnFamily:columnName'

0

you can use STARTROW and STOPROW to fetch records between ranges.