Created on 09-23-2015 01:59 PM - edited 09-16-2022 02:41 AM
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
Created 09-24-2015 03:58 AM
Created on 12-16-2015 08:42 AM - edited 12-16-2015 08:54 AM
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.