Reputation: 3426
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?
Upvotes: 0
Views: 1461
Reputation: 3426
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!
Upvotes: 2