Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving timestamp from hbase row

Tags:

java

hbase

flume

Using Hbase API (Get/Put) or HBQL API, is it possible to retrieve timestamp of a particular column?

like image 399
Abhijeet Pathak Avatar asked Nov 30 '11 05:11

Abhijeet Pathak


People also ask

What is timestamp in HBase?

Timestamp can be set in write request to HBase. By default HBase sets timestamp at server to the current value of epoch time in milliseconds. Versions count stored by HBase can be set per column family.

How do I get all the HBase versions?

While I am not familiar with Nifi to provide an exact answer, HBase allows VERSION to fetch all versions of a Table. Assuming a Table has been configured with VERSION => 5, We can use Command "scan 'Table_Name', {VERSIONS => 5}" to fetch all Versions from the Table.


1 Answers

Assuming your client is configured and you have a table setup. Doing a get returns a Result

Get get = new Get(Bytes.toBytes("row_key"));
Result result_foo = table.get(get);

A Result is backed by a KeyValue. KeyValues contain the timestamps. You can get either a list of KeyValues with list() or get an array with raw(). A KeyValue has a get timestamp method.

result_foo.raw()[0].getTimestamp()
like image 186
codingFoo Avatar answered Sep 20 '22 17:09

codingFoo