- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Get ttl from HBase record
- Labels:
-
Apache HBase
Created on ‎09-23-2015 01:59 PM - edited ‎09-16-2022 02:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to understand how can I get ttl of HBase record using Java API 1.0.0-cdh5.4.5.
I can add ttl using Put.setTTL() function, which actually is defined in Mutation.
But how can I get back my TTL for this record?
Could you show me a snippet of the code to get a record by the key and get TTL for it.
Also I explicitly set TTL for some records and for some records I use table's default TTL.
Not sure if I should get ti the same way or they are different.
Created ‎09-24-2015 03:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To retrieve them back from their Cell, fetch the Cell via Get/etc. and then
use the available Tags-relevant APIs on the Cell object:
http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/Cell.html#getTagsArray(...
and deserialise the array of tags via
http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/CellUtil.html#tagsItera...
[1] -
https://github.com/cloudera/hbase/blob/cdh5.4.5-release/hbase-server/src/main/java/org/apache/hadoop...
Created ‎09-24-2015 03:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To retrieve them back from their Cell, fetch the Cell via Get/etc. and then
use the available Tags-relevant APIs on the Cell object:
http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/Cell.html#getTagsArray(...
and deserialise the array of tags via
http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/CellUtil.html#tagsItera...
[1] -
https://github.com/cloudera/hbase/blob/cdh5.4.5-release/hbase-server/src/main/java/org/apache/hadoop...
Created on ‎12-16-2015 08:42 AM - edited ‎12-16-2015 08:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
So the Cell TTL is stored via Cell TTL tags.When I retrive it fails to get Cell Tags for TTL but the Cell TTL feature does work . Can you point me to what I am doing wrong to retrieve the Cell TTL . We are using hbase-1.0.0-cdh5.4.2.
I fail to get the Cell Tag for TTL when I iterate over the cell Tags.
During PUT we do
put.setTTL( );
Table table..
Get get = new Get(Bytes.toBytes(<key>));
Result rs = table.get(get);
if (rs!=null) {
Cell cell = rs.getColumnCells(..);
Iterator<Tag> i = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
cell.getTagsLength());
while (i.hasNext()) {
Tag t = i.next();
if (TagType.TTL_TAG_TYPE == t.getType()) {
long ts = cell.getTimestamp();
assert t.getTagLength() == Bytes.SIZEOF_LONG;
long ttl = Bytes.toLong(t.getBuffer(), t.getTagOffset(), t.getTagLength());
System.out.println(ttl);
}
}
Thanks in advance.
