sahu sahu - 1 year ago 99
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download