HBASE-23678 : Builder API for version management - setVersionsWithTimeToLive
Signed-off-by: Xu Cang <xucang@apache.org>
This commit is contained in:
parent
f94c19494b
commit
96ae39b01b
|
@ -921,6 +921,23 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
|
|||
return setValue(MIN_VERSIONS, Integer.toString(minVersions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retain all versions for a given TTL(retentionInterval), and then only a specific number
|
||||
* of versions(versionAfterInterval) after that interval elapses.
|
||||
*
|
||||
* @param retentionInterval Retain all versions for this interval
|
||||
* @param versionAfterInterval Retain no of versions to retain after retentionInterval
|
||||
* @return this (for chained invocation)
|
||||
*/
|
||||
public HColumnDescriptor setVersionsWithTimeToLive(final int retentionInterval,
|
||||
final int versionAfterInterval) {
|
||||
HColumnDescriptor hColumnDescriptor =
|
||||
setVersions(versionAfterInterval, Integer.MAX_VALUE);
|
||||
hColumnDescriptor.setTimeToLive(retentionInterval);
|
||||
hColumnDescriptor.setKeepDeletedCells(KeepDeletedCells.TTL);
|
||||
return hColumnDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if hfile DATA type blocks should be cached (You cannot disable caching of INDEX
|
||||
* and BLOOM type blocks).
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
package org.apache.hadoop.hbase.regionserver;
|
||||
|
||||
import static org.apache.hadoop.hbase.HBaseTestingUtility.COLUMNS;
|
||||
import static org.apache.hadoop.hbase.HBaseTestingUtility.fam1;
|
||||
import static org.apache.hadoop.hbase.HBaseTestingUtility.fam2;
|
||||
import static org.apache.hadoop.hbase.HBaseTestingUtility.fam3;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -28,8 +31,10 @@ import java.util.List;
|
|||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CellUtil;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.KeepDeletedCells;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
import org.apache.hadoop.hbase.client.Get;
|
||||
|
@ -470,8 +475,11 @@ public class TestMinVersions {
|
|||
@Test
|
||||
public void testMinVersionsWithKeepDeletedCellsTTL() throws Exception {
|
||||
int ttl = 4;
|
||||
HTableDescriptor htd = hbu.createTableDescriptor(name.getMethodName(),
|
||||
2, Integer.MAX_VALUE, ttl, KeepDeletedCells.TTL);
|
||||
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
|
||||
for (byte[] cfName : new byte[][]{fam1, fam2, fam3}) {
|
||||
htd.addFamily(new HColumnDescriptor(cfName)
|
||||
.setVersionsWithTimeToLive(ttl, 2));
|
||||
}
|
||||
|
||||
HRegion region = hbu.createLocalHRegion(htd, null, null);
|
||||
|
||||
|
|
Loading…
Reference in New Issue