0
votes

I created a HBase table via Java API and added data via a Put. I can also read the data in Java with a corresponding Get. The HBase documentation says that a cell value also can be read by using a GET request e.g. in browser, see documentation.

The following request works for me, which returns the whole row:

http://my_hbase_url:12345/dm-table/exampleRow/family:html?v=1

The result is an xml and looks following:

<CellSet>
  <Row key="ZXhhbXBsZVJvdw==">
    <Cell column="ZmFtaWx5Omh0bWw=" timestamp="1466667016879">PGh0bWw+Li4uTXkgSFRNTC4uLjwvaHRtbD4=</Cell>
  </Row>
</CellSet>

If you have a look at the timestamp it is 1466667016879, but when I call

http://my_hbase_url:12345/dm-table/exampleRow/family:html/1466667016879

I get a not found result! Also the Java code works and gives me this timestamp:

HTable table = new HTable(config, TABLE_NAME.getBytes());

Get g = new Get("exampleRow".getBytes());
g.setTimeStamp(1466667016879L);

Result r = table.get(g);
System.out.println("Timestamp: " + r.rawCells()[0].getTimestamp());

byte[] value = r.getValue(CF_DEFAULT.getBytes(), "html".getBytes());
String valueStr = new String(value);
System.out.println("GET: " + valueStr);

this prints:

Timestamp: 1466667016879
GET: <html>...My HTML...</html>

So timestamp does exist, but the http GET request won't work with the timestamp, can someone help?

1
I looked into it but I can't use family:html. Is it for HBase 2.0 only?Whitefret
The column-familiy "family" and the column "html" are just from my table example, I created the table with this structure. I use HDP 2.4 with HBase 1.1.2D. Müller
I am dumb :/... I get to download a file instead of having a nice Xml answer. WIll try to look into it againWhitefret
okay, reproduced the same error, maybe there is a JIRA about it. What is your HBase version?Whitefret
This is definitly a bug, try a put on the same row/column, and query the current timestamp. Do you also get the previous data and not the current?Whitefret

1 Answers

1
votes

The timestamp in the URL looks for the newest data set with an EARLIER timestamp!

So have a look at following example:

When you call e.g. http://my_hbase_url:12345/dm-table/exampleRow/family:html you get the following result:

<CellSet>
  <Row key="ZXhhbXBsZVJvdw==">
    <Cell column="ZmFtaWx5Omh0bWw=" timestamp="1466667016879">PGh0bWw+Li4uTXkgSFRNTC4uLjwvaHRtbD4=</Cell>
  </Row>
</CellSet>

So if you want to get this result via timestamp (e.g. because you have different versions of the data saved), you can add the timestamp to the URL to get the latest dataset with an earlier timestamp. So, to get the data-set shown above you have to add /<timestamp + 1> to the URL:

http://my_hbase_url:12345/dm-table/exampleRow/family:html/1466667016880

This brings the same result as shown above. If this is the only or earliest version, calling http://my_hbase_url:12345/dm-table/exampleRow/family:html/1466667016879 wouldn't find any result and would end in a not found result, as described in the question above.

However, you have to use <timestamp + 1> (or higher) to get the expected data!

Thank you @Whitefret for this solving hint!