Overview
Scenarios
Product Architecture
Instance Types
Compatibility Notes
Usage specification recommendations
HColumnDescriptor .HColumnDescriptor .MIN_VERSIONS: If the minimum number of versions (MIN_VERSIONS) is set to a non-zero value, the TTL feature will be disabled.TableName tableName = createTDSQLTableName("ht1");byte[] CF1 = Bytes.toBytes("cf1");byte[] CF2 = Bytes.toBytes("cf2");// Create table descriptorTableDescriptorBuilder tdb = TableDescriptorBuilder.newBuilder(tableName);// Configure the first column family: TTL=2 seconds, minVersions=2, maxVersions=5tdb.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(CF1).setTimeToLive(2).setMinVersions(2).setMaxVersions(5).build());// Configure the second column family: TTL=3 seconds, minVersions=4, maxVersions=10tdb.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(CF2).setTimeToLive(3).setMinVersions(4).setMaxVersions(10).build());// Build table and createtry (Admin admin = connection.getAdmin()) {admin.createTable(tdb.build());}
TableName tableName = TableName.valueOf("ht1");byte[] CF2 = Bytes.toBytes("cf2");try (Admin admin = connection.getAdmin()) {// Obtain the current column family configurationColumnFamilyDescriptor currentDesc = admin.getDescriptor(tableName).getColumnFamily(CF2);// Create a new configuration based on the existing one (retaining other settings)ColumnFamilyDescriptor newDesc = ColumnFamilyDescriptorBuilder.newBuilder(currentDesc).setTimeToLive(10) // Modifying TTL=10 seconds.setMinVersions(2) // Modify minVersions=2.setMaxVersions(5) // Modify maxVersions=5.build();// Apply the modificationsadmin.modifyColumnFamily(tableName, newDesc);System.out.println("Column family configuration updated successfully");}
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback