Skip to content

Commit 843e136

Browse files
gjacoby126apurtell
authored andcommitted
HBASE-25751 - Add writable TimeToPurgeDeletes to ScanOptions (#3137)
Signed-off-by: Andrew Purtell <[email protected]> Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Viraj Jasani <[email protected]>
1 parent da6b1df commit 843e136

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CustomizedScanInfoBuilder.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package org.apache.hadoop.hbase.regionserver;
1919

20-
import java.io.IOException;
2120
import org.apache.hadoop.hbase.KeepDeletedCells;
2221
import org.apache.hadoop.hbase.client.ImmutableScan;
2322
import org.apache.hadoop.hbase.client.Scan;
@@ -39,6 +38,8 @@ public class CustomizedScanInfoBuilder implements ScanOptions {
3938

4039
private Integer minVersions;
4140

41+
private long timeToPurgeDeletes;
42+
4243
private final Scan scan;
4344

4445
public CustomizedScanInfoBuilder(ScanInfo scanInfo) {
@@ -76,7 +77,8 @@ public ScanInfo build() {
7677
if (maxVersions == null && ttl == null && keepDeletedCells == null) {
7778
return scanInfo;
7879
}
79-
return scanInfo.customize(getMaxVersions(), getTTL(), getKeepDeletedCells(), getMinVersions());
80+
return scanInfo.customize(getMaxVersions(), getTTL(), getKeepDeletedCells(), getMinVersions(),
81+
getTimeToPurgeDeletes());
8082
}
8183

8284
@Override
@@ -105,6 +107,16 @@ public void setMinVersions(int minVersions) {
105107
this.minVersions = minVersions;
106108
}
107109

110+
@Override
111+
public long getTimeToPurgeDeletes() {
112+
return timeToPurgeDeletes;
113+
}
114+
115+
@Override
116+
public void setTimeToPurgeDeletes(long ttl) {
117+
this.timeToPurgeDeletes = ttl;
118+
}
119+
108120
@Override
109121
public Scan getScan() {
110122
return scan;

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanInfo.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,18 @@ public boolean isNewVersionBehavior() {
168168
}
169169

170170
/**
171-
* Used for CP users for customizing max versions, ttl and keepDeletedCells.
171+
* Used by CP users for customizing max versions, ttl and keepDeletedCells.
172172
*/
173173
ScanInfo customize(int maxVersions, long ttl, KeepDeletedCells keepDeletedCells) {
174-
return customize(maxVersions, ttl, keepDeletedCells, minVersions);
174+
return customize(maxVersions, ttl, keepDeletedCells, minVersions, timeToPurgeDeletes);
175175
}
176176

177+
/**
178+
* Used by CP users for customizing max versions, ttl, keepDeletedCells, min versions,
179+
* and time to purge deletes.
180+
*/
177181
ScanInfo customize(int maxVersions, long ttl, KeepDeletedCells keepDeletedCells,
178-
int minVersions) {
182+
int minVersions, long timeToPurgeDeletes) {
179183
return new ScanInfo(family, minVersions, maxVersions, ttl, keepDeletedCells, timeToPurgeDeletes,
180184
comparator, tableMaxRowSize, usePread, cellsPerTimeoutCheck, parallelSeekEnabled,
181185
preadMaxBytes, newVersionBehavior);

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ default void readAllVersions() {
7171

7272
void setMinVersions(int minVersions);
7373

74+
long getTimeToPurgeDeletes();
75+
76+
void setTimeToPurgeDeletes(long ttl);
77+
7478
/**
7579
* Returns a copy of the Scan object. Modifying it will have no effect.
7680
*/

hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SimpleRegionObserver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ private void setScanOptions(ScanOptions options) {
745745
options.setMinVersions(TestRegionCoprocessorHost.MIN_VERSIONS);
746746
options.setKeepDeletedCells(KeepDeletedCells.TRUE);
747747
options.setTTL(TestRegionCoprocessorHost.TTL);
748+
options.setTimeToPurgeDeletes(TestRegionCoprocessorHost.TIME_TO_PURGE_DELETES);
748749
}
749750

750751

hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionCoprocessorHost.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class TestRegionCoprocessorHost {
7878
public static final int MAX_VERSIONS = 3;
7979
public static final int MIN_VERSIONS = 2;
8080
public static final int TTL = 1000;
81+
public static final int TIME_TO_PURGE_DELETES = 2000;
8182

8283
@Before
8384
public void setup() throws IOException {
@@ -203,6 +204,7 @@ private void verifyScanInfo(ScanInfo newScanInfo) {
203204
assertEquals(MAX_VERSIONS, newScanInfo.getMaxVersions());
204205
assertEquals(MIN_VERSIONS, newScanInfo.getMinVersions());
205206
assertEquals(TTL, newScanInfo.getTtl());
207+
assertEquals(TIME_TO_PURGE_DELETES, newScanInfo.getTimeToPurgeDeletes());
206208
}
207209

208210
private ScanInfo getScanInfo() {

0 commit comments

Comments
 (0)