HBASE-18749 Apply the CF specific TimeRange from Scan to filter the segment scanner

This commit is contained in:
Chia-Ping Tsai 2017-09-06 20:01:10 +08:00
parent cd1b964bb7
commit f0c1cd50c2
5 changed files with 13 additions and 13 deletions

View File

@ -18,12 +18,12 @@
*/ */
package org.apache.hadoop.hbase.regionserver; package org.apache.hadoop.hbase.regionserver;
import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator; import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -122,7 +122,7 @@ public class CompositeImmutableSegment extends ImmutableSegment {
} }
@Override @Override
public boolean shouldSeek(Scan scan, long oldestUnexpiredTS){ public boolean shouldSeek(TimeRange tr, long oldestUnexpiredTS){
throw new IllegalStateException("Not supported by CompositeImmutableScanner"); throw new IllegalStateException("Not supported by CompositeImmutableScanner");
} }

View File

@ -24,7 +24,6 @@ import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.util.ClassSize; import org.apache.hadoop.hbase.util.ClassSize;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.TimeRange; import org.apache.hadoop.hbase.io.TimeRange;
import java.io.IOException; import java.io.IOException;
@ -130,8 +129,8 @@ public class ImmutableSegment extends Segment {
///////////////////// PUBLIC METHODS ///////////////////// ///////////////////// PUBLIC METHODS /////////////////////
@Override @Override
public boolean shouldSeek(Scan scan, long oldestUnexpiredTS) { public boolean shouldSeek(TimeRange tr, long oldestUnexpiredTS) {
return this.timeRange.includesTimeRange(scan.getTimeRange()) && return this.timeRange.includesTimeRange(tr) &&
this.timeRange.getMax() >= oldestUnexpiredTS; this.timeRange.getMax() >= oldestUnexpiredTS;
} }

View File

@ -27,7 +27,7 @@ import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.util.ClassSize; import org.apache.hadoop.hbase.util.ClassSize;
import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;
@ -112,8 +112,8 @@ public class MutableSegment extends Segment {
} }
@Override @Override
public boolean shouldSeek(Scan scan, long oldestUnexpiredTS) { public boolean shouldSeek(TimeRange tr, long oldestUnexpiredTS) {
return (this.timeRangeTracker.includesTimeRange(scan.getTimeRange()) return (this.timeRangeTracker.includesTimeRange(tr)
&& (this.timeRangeTracker.getMax() >= oldestUnexpiredTS)); && (this.timeRangeTracker.getMax() >= oldestUnexpiredTS));
} }

View File

@ -32,7 +32,7 @@ import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil; import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.ClassSize; import org.apache.hadoop.hbase.util.ClassSize;
@ -177,7 +177,7 @@ public abstract class Segment {
return KeyValueUtil.length(cell); return KeyValueUtil.length(cell);
} }
public abstract boolean shouldSeek(Scan scan, long oldestUnexpiredTS); public abstract boolean shouldSeek(TimeRange tr, long oldestUnexpiredTS);
public abstract long getMinTimestamp(); public abstract long getMinTimestamp();

View File

@ -280,7 +280,8 @@ public class SegmentScanner implements KeyValueScanner {
*/ */
@Override @Override
public boolean shouldUseScanner(Scan scan, Store store, long oldestUnexpiredTS) { public boolean shouldUseScanner(Scan scan, Store store, long oldestUnexpiredTS) {
return getSegment().shouldSeek(scan,oldestUnexpiredTS); return getSegment().shouldSeek(scan.getColumnFamilyTimeRange()
.getOrDefault(store.getColumnFamilyDescriptor().getName(), scan.getTimeRange()), oldestUnexpiredTS);
} }
@Override @Override