<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Get ttl from HBase record in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-ttl-from-HBase-record/m-p/32249#M7426</link>
    <description>The TTL values are stored as Cell-level tags [1].&lt;BR /&gt;&lt;BR /&gt;To retrieve them back from their Cell, fetch the Cell via Get/etc. and then&lt;BR /&gt;use the available Tags-relevant APIs on the Cell object:&lt;BR /&gt;&lt;A href="http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/Cell.html#getTagsArray()," target="_blank"&gt;http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/Cell.html#getTagsArray(),&lt;/A&gt;&lt;BR /&gt;and deserialise the array of tags via&lt;BR /&gt;&lt;A href="http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/CellUtil.html#tagsIterator(byte[],%20int,%20int)" target="_blank"&gt;http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/CellUtil.html#tagsIterator(byte[],%20int,%20int)&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;[1] -&lt;BR /&gt;&lt;A href="https://github.com/cloudera/hbase/blob/cdh5.4.5-release/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java#L3483-L3486" target="_blank"&gt;https://github.com/cloudera/hbase/blob/cdh5.4.5-release/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java#L3483-L3486&lt;/A&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 24 Sep 2015 10:58:45 GMT</pubDate>
    <dc:creator>Harsh J</dc:creator>
    <dc:date>2015-09-24T10:58:45Z</dc:date>
    <item>
      <title>Get ttl from HBase record</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-ttl-from-HBase-record/m-p/32224#M7425</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand how can I get ttl of HBase record using Java API 1.0.0-cdh5.4.5.&lt;/P&gt;&lt;P&gt;I can add ttl using Put.setTTL() function, which actually is defined in Mutation.&lt;/P&gt;&lt;P&gt;&lt;A href="http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/client/Mutation.html#setTTL%28long%29" target="_blank"&gt;http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/client/Mutation.html#setTTL%28long%29&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But how can I get back my TTL for this record?&lt;/P&gt;&lt;P&gt;Could you show me a snippet of the code to get a record by the key and get TTL for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I explicitly set TTL for some records and for some records I use&amp;nbsp;table's default TTL.&lt;/P&gt;&lt;P&gt;Not sure if I should get ti the same way or they are different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:41:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-ttl-from-HBase-record/m-p/32224#M7425</guid>
      <dc:creator>Timur</dc:creator>
      <dc:date>2022-09-16T09:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get ttl from HBase record</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-ttl-from-HBase-record/m-p/32249#M7426</link>
      <description>The TTL values are stored as Cell-level tags [1].&lt;BR /&gt;&lt;BR /&gt;To retrieve them back from their Cell, fetch the Cell via Get/etc. and then&lt;BR /&gt;use the available Tags-relevant APIs on the Cell object:&lt;BR /&gt;&lt;A href="http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/Cell.html#getTagsArray()," target="_blank"&gt;http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/Cell.html#getTagsArray(),&lt;/A&gt;&lt;BR /&gt;and deserialise the array of tags via&lt;BR /&gt;&lt;A href="http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/CellUtil.html#tagsIterator(byte[],%20int,%20int)" target="_blank"&gt;http://archive.cloudera.com/cdh5/cdh/5/hbase/apidocs/org/apache/hadoop/hbase/CellUtil.html#tagsIterator(byte[],%20int,%20int)&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;[1] -&lt;BR /&gt;&lt;A href="https://github.com/cloudera/hbase/blob/cdh5.4.5-release/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java#L3483-L3486" target="_blank"&gt;https://github.com/cloudera/hbase/blob/cdh5.4.5-release/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java#L3483-L3486&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Sep 2015 10:58:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-ttl-from-HBase-record/m-p/32249#M7426</guid>
      <dc:creator>Harsh J</dc:creator>
      <dc:date>2015-09-24T10:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get ttl from HBase record</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-ttl-from-HBase-record/m-p/35329#M7427</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I fail to get the Cell Tag for TTL when I iterate over the cell Tags.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;During PUT we do&lt;/P&gt;&lt;P&gt;put.setTTL( );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table table..&lt;/P&gt;&lt;P&gt;Get get = new Get(Bytes.toBytes(&amp;lt;key&amp;gt;));&lt;/P&gt;&lt;P&gt;Result rs = table.get(get);&lt;/P&gt;&lt;P&gt;if (rs!=null) {&lt;/P&gt;&lt;P&gt;Cell cell = rs.getColumnCells(..);&lt;/P&gt;&lt;P&gt;Iterator&amp;lt;Tag&amp;gt; i = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),&lt;/P&gt;&lt;P&gt;cell.getTagsLength());&lt;/P&gt;&lt;P&gt;while (i.hasNext()) {&lt;/P&gt;&lt;P&gt;Tag t = i.next();&lt;/P&gt;&lt;P&gt;if (TagType.TTL_TAG_TYPE == t.getType()) {&lt;/P&gt;&lt;P&gt;long ts = cell.getTimestamp();&lt;/P&gt;&lt;P&gt;assert t.getTagLength() == Bytes.SIZEOF_LONG;&lt;/P&gt;&lt;P&gt;long ttl = Bytes.toLong(t.getBuffer(), t.getTagOffset(), t.getTagLength());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.out.println(ttl);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 16:54:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Get-ttl-from-HBase-record/m-p/35329#M7427</guid>
      <dc:creator>Shefali</dc:creator>
      <dc:date>2015-12-16T16:54:01Z</dc:date>
    </item>
  </channel>
</rss>

