HBASE-25751 - Add writable TimeToPurgeDeletes to ScanOptions (#3137)

Signed-off-by: Andrew Purtell <apurtell@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Geoffrey Jacoby 2021-04-09 13:05:47 -07:00 committed by GitHub
parent 6aab1341a1
commit 74e533d5ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 5 deletions

View File

@ -17,7 +17,6 @@
*/
package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
import org.apache.hadoop.hbase.KeepDeletedCells;
import org.apache.hadoop.hbase.client.ImmutableScan;
import org.apache.hadoop.hbase.client.Scan;
@ -39,6 +38,8 @@ public class CustomizedScanInfoBuilder implements ScanOptions {
private Integer minVersions;
private long timeToPurgeDeletes;
private final Scan scan;
public CustomizedScanInfoBuilder(ScanInfo scanInfo) {
@ -76,7 +77,8 @@ public class CustomizedScanInfoBuilder implements ScanOptions {
if (maxVersions == null && ttl == null && keepDeletedCells == null) {
return scanInfo;
}
return scanInfo.customize(getMaxVersions(), getTTL(), getKeepDeletedCells(), getMinVersions());
return scanInfo.customize(getMaxVersions(), getTTL(), getKeepDeletedCells(), getMinVersions(),
getTimeToPurgeDeletes());
}
@Override
@ -105,6 +107,16 @@ public class CustomizedScanInfoBuilder implements ScanOptions {
this.minVersions = minVersions;
}
@Override
public long getTimeToPurgeDeletes() {
return timeToPurgeDeletes;
}
@Override
public void setTimeToPurgeDeletes(long ttl) {
this.timeToPurgeDeletes = ttl;
}
@Override
public Scan getScan() {
return scan;

View File

@ -168,14 +168,18 @@ public class ScanInfo {
}
/**
* Used for CP users for customizing max versions, ttl and keepDeletedCells.
* Used by CP users for customizing max versions, ttl and keepDeletedCells.
*/
ScanInfo customize(int maxVersions, long ttl, KeepDeletedCells keepDeletedCells) {
return customize(maxVersions, ttl, keepDeletedCells, minVersions);
return customize(maxVersions, ttl, keepDeletedCells, minVersions, timeToPurgeDeletes);
}
/**
* Used by CP users for customizing max versions, ttl, keepDeletedCells, min versions,
* and time to purge deletes.
*/
ScanInfo customize(int maxVersions, long ttl, KeepDeletedCells keepDeletedCells,
int minVersions) {
int minVersions, long timeToPurgeDeletes) {
return new ScanInfo(family, minVersions, maxVersions, ttl, keepDeletedCells, timeToPurgeDeletes,
comparator, tableMaxRowSize, usePread, cellsPerTimeoutCheck, parallelSeekEnabled,
preadMaxBytes, newVersionBehavior);

View File

@ -71,6 +71,10 @@ public interface ScanOptions {
void setMinVersions(int minVersions);
long getTimeToPurgeDeletes();
void setTimeToPurgeDeletes(long ttl);
/**
* Returns a copy of the Scan object. Modifying it will have no effect.
*/

View File

@ -745,6 +745,7 @@ public class SimpleRegionObserver implements RegionCoprocessor, RegionObserver {
options.setMinVersions(TestRegionCoprocessorHost.MIN_VERSIONS);
options.setKeepDeletedCells(KeepDeletedCells.TRUE);
options.setTTL(TestRegionCoprocessorHost.TTL);
options.setTimeToPurgeDeletes(TestRegionCoprocessorHost.TIME_TO_PURGE_DELETES);
}

View File

@ -78,6 +78,7 @@ public class TestRegionCoprocessorHost {
public static final int MAX_VERSIONS = 3;
public static final int MIN_VERSIONS = 2;
public static final int TTL = 1000;
public static final int TIME_TO_PURGE_DELETES = 2000;
@Before
public void setup() throws IOException {
@ -203,6 +204,7 @@ public class TestRegionCoprocessorHost {
assertEquals(MAX_VERSIONS, newScanInfo.getMaxVersions());
assertEquals(MIN_VERSIONS, newScanInfo.getMinVersions());
assertEquals(TTL, newScanInfo.getTtl());
assertEquals(TIME_TO_PURGE_DELETES, newScanInfo.getTimeToPurgeDeletes());
}
private ScanInfo getScanInfo() {