Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the row key from hbase scan result

Tags:

java

hbase

when scan the hbase table row by row, how can i get the row key? here is my code:

for (Result rr : scanner) {
   System.out.println(rr);
}

is there any method like getKey() that i can use? thanks.

like image 717
user468587 Avatar asked Aug 02 '12 23:08

user468587


1 Answers

If you want the row key in a string format, use the getRow and the Bytes.toString methods :

for (Result rr : scanner) {
   String key = Bytes.toString(rr.getRow())
}

HBase API - Result object

getRow() Method for retrieving the row key that corresponds to the row from which this Result was created.

like image 134
Jean-Philippe Bond Avatar answered Sep 23 '22 10:09

Jean-Philippe Bond