Search code examples
javahadoophbase

How to get an HBase row using just they key?


I have a question which my be very basic, but I am new to HBase. I want to get a row (eg. []byte) using just the row key.

I am looking at the Get object, but the constructor expects the entire row: https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Get.html which says "To get everything for a row, instantiate a Get object with the row to get. To further narrow the scope of what to Get, use the methods below."

More specifically, I am trying to use the output from HRegionLocator.getStartEndKeys() to get the entire row.


Solution

  • You can just use org.apache.hadoop.hbase.Get for this. Although the general Javadoc of the class and the constructor loosely speak of specifying the "row", it means "row key". You can find the specifics in the description of the constructor parameter row:

    Parameters:

    row - row key

    So the parameter specific the key of the row, not the entire data of the row. With the other arguments to Get, you can be more specific about the columns that you want to retrieve from the row.