Skip to content

Commit

Permalink
PHOENIX-5881 - Port PHOENIX-5645 (MaxLookbackAge) to 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
gjacoby126 committed Aug 19, 2020
1 parent 61fb82f commit 0969403
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private boolean isTransactionalTimestamp(long ts) {
* If KeepDeletedCells.FALSE, KeepDeletedCells.TTL ,
* let delete markers age once lookback age is done.
*/
private KeepDeletedCells getKeepDeletedCells(ScanOptions options, ScanType scanType) {
public KeepDeletedCells getKeepDeletedCells(ScanOptions options, ScanType scanType) {
//if we're doing a minor compaction or flush, always set keep deleted cells
//to true. Otherwise, if keep deleted cells is false or TTL, use KeepDeletedCells TTL,
//where the value of the ttl might be overriden to the max lookback age elsewhere
Expand All @@ -132,31 +132,39 @@ private KeepDeletedCells getKeepDeletedCells(ScanOptions options, ScanType scanT
* Otherwise the data (1st version) will not be removed after the TTL. If no TTL, we want
* Math.max(maxVersions, minVersions, 1)
*/
private int getMinVersions(ScanOptions options, ColumnFamilyDescriptor cfDescriptor) {
public int getMinVersions(ScanOptions options, ColumnFamilyDescriptor cfDescriptor) {
return cfDescriptor.getTimeToLive() != HConstants.FOREVER ? options.getMinVersions()
: Math.max(Math.max(options.getMinVersions(),
cfDescriptor.getMaxVersions()),1);
}

/**
*
* @param conf HBase Configuration
* @param columnDescriptor ColumnFamilyDescriptor for the store being compacted
* @param options ScanOptions of overrides to the compaction scan
* @return Time to live in milliseconds, based on both HBase TTL and Phoenix max lookback age
*/
public long getTimeToLiveForCompactions(Configuration conf,
ColumnFamilyDescriptor columnDescriptor,
ScanOptions options) {
long ttl = columnDescriptor.getTimeToLive();
long ttlConfigured = columnDescriptor.getTimeToLive();
long ttlInMillis = ttlConfigured * 1000;
long maxLookbackTtl = getMaxLookbackInMillis(conf);
if (isMaxLookbackTimeEnabled(maxLookbackTtl)) {
if (ttl == HConstants.FOREVER
if (ttlConfigured == HConstants.FOREVER
&& columnDescriptor.getKeepDeletedCells() != KeepDeletedCells.TRUE) {
// If user configured default TTL(FOREVER) and keep deleted cells to false or
// TTL then to remove unwanted delete markers we should change ttl to max lookback age
ttl = maxLookbackTtl;
ttlInMillis = maxLookbackTtl;
} else {
//if there is a TTL, use TTL instead of max lookback age.
// Max lookback age should be more recent or equal to TTL
ttl = Math.max(ttl * 1000, maxLookbackTtl);
ttlInMillis = Math.max(ttlInMillis, maxLookbackTtl);
}
}

return ttl;
return ttlInMillis;
}

public void setScanOptionsForFlushesAndCompactions(Configuration conf,
Expand Down

0 comments on commit 0969403

Please sign in to comment.