sahu sahu - 13 days ago 5x
Java Question

Set TTL for a column family in HBase using shell and using Java API

I am new to HBase and I have searched at my end but I am unable to find a simple and straight forward way to set TTL attribute in a column family in HBase. Please specify both ways using shell and using Java API.


Using the Java API:

HColumnDescriptor cfDescriptor = new HColumnDescriptor(Bytes.toBytes("cfName"));
cfDescriptor.setTimeToLive(20); // in seconds


And using shell:

alter ‘tableName′, NAME => ‘cfname′, TTL => 20