HBASE-1823 Ability for Scanners to bypass the block cache
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@814070 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e91bb84c8a
commit
69bd17fe1b
@ -41,6 +41,7 @@ Release 0.21.0 - Unreleased
|
|||||||
HBASE-1820 Update jruby from 1.2 to 1.3.1
|
HBASE-1820 Update jruby from 1.2 to 1.3.1
|
||||||
HBASE-1687 bin/hbase script doesn't allow for different memory settings for
|
HBASE-1687 bin/hbase script doesn't allow for different memory settings for
|
||||||
each daemon type
|
each daemon type
|
||||||
|
HBASE-1823 Ability for Scanners to bypass the block cache
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
|
@ -69,12 +69,16 @@ import org.apache.hadoop.io.WritableFactories;
|
|||||||
* {@link #setMaxVersions(int) setMaxVersions}.
|
* {@link #setMaxVersions(int) setMaxVersions}.
|
||||||
* <p>
|
* <p>
|
||||||
* To add a filter, execute {@link #setFilter(org.apache.hadoop.hbase.filter.Filter) setFilter}.
|
* To add a filter, execute {@link #setFilter(org.apache.hadoop.hbase.filter.Filter) setFilter}.
|
||||||
|
* <p>
|
||||||
|
* Expert: To explicitly disable server-side block caching for this scan,
|
||||||
|
* execute {@link #setCacheBlocks(boolean)}.
|
||||||
*/
|
*/
|
||||||
public class Scan implements Writable {
|
public class Scan implements Writable {
|
||||||
private byte [] startRow = HConstants.EMPTY_START_ROW;
|
private byte [] startRow = HConstants.EMPTY_START_ROW;
|
||||||
private byte [] stopRow = HConstants.EMPTY_END_ROW;
|
private byte [] stopRow = HConstants.EMPTY_END_ROW;
|
||||||
private int maxVersions = 1;
|
private int maxVersions = 1;
|
||||||
private int caching = -1;
|
private int caching = -1;
|
||||||
|
private boolean cacheBlocks = true;
|
||||||
private Filter filter = null;
|
private Filter filter = null;
|
||||||
private RowFilterInterface oldFilter = null;
|
private RowFilterInterface oldFilter = null;
|
||||||
private TimeRange tr = new TimeRange();
|
private TimeRange tr = new TimeRange();
|
||||||
@ -448,6 +452,29 @@ public class Scan implements Writable {
|
|||||||
return filter != null || oldFilter != null;
|
return filter != null || oldFilter != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether blocks should be cached for this Scan.
|
||||||
|
* <p>
|
||||||
|
* This is true by default. When true, default settings of the table and
|
||||||
|
* family are used (this will never override caching blocks if the block
|
||||||
|
* cache is disabled for that family or entirely).
|
||||||
|
*
|
||||||
|
* @param cacheBlocks if false, default settings are overridden and blocks
|
||||||
|
* will not be cached
|
||||||
|
*/
|
||||||
|
public void setCacheBlocks(boolean cacheBlocks) {
|
||||||
|
this.cacheBlocks = cacheBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether blocks should be cached for this Scan.
|
||||||
|
* @return true if default caching should be used, false if blocks should not
|
||||||
|
* be cached
|
||||||
|
*/
|
||||||
|
public boolean getCacheBlocks() {
|
||||||
|
return cacheBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
@ -518,6 +545,7 @@ public class Scan implements Writable {
|
|||||||
this.stopRow = Bytes.readByteArray(in);
|
this.stopRow = Bytes.readByteArray(in);
|
||||||
this.maxVersions = in.readInt();
|
this.maxVersions = in.readInt();
|
||||||
this.caching = in.readInt();
|
this.caching = in.readInt();
|
||||||
|
this.cacheBlocks = in.readBoolean();
|
||||||
if(in.readBoolean()) {
|
if(in.readBoolean()) {
|
||||||
this.filter = (Filter)createForName(Bytes.toString(Bytes.readByteArray(in)));
|
this.filter = (Filter)createForName(Bytes.toString(Bytes.readByteArray(in)));
|
||||||
this.filter.readFields(in);
|
this.filter.readFields(in);
|
||||||
@ -550,6 +578,7 @@ public class Scan implements Writable {
|
|||||||
Bytes.writeByteArray(out, this.stopRow);
|
Bytes.writeByteArray(out, this.stopRow);
|
||||||
out.writeInt(this.maxVersions);
|
out.writeInt(this.maxVersions);
|
||||||
out.writeInt(this.caching);
|
out.writeInt(this.caching);
|
||||||
|
out.writeBoolean(this.cacheBlocks);
|
||||||
if(this.filter == null) {
|
if(this.filter == null) {
|
||||||
out.writeBoolean(false);
|
out.writeBoolean(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,6 +43,7 @@ class StoreScanner implements KeyValueScanner, InternalScanner, ChangedReadersOb
|
|||||||
private Store store;
|
private Store store;
|
||||||
private ScanQueryMatcher matcher;
|
private ScanQueryMatcher matcher;
|
||||||
private KeyValueHeap heap;
|
private KeyValueHeap heap;
|
||||||
|
private boolean cacheBlocks;
|
||||||
|
|
||||||
// Used to indicate that the scanner has closed (see HBASE-1107)
|
// Used to indicate that the scanner has closed (see HBASE-1107)
|
||||||
private final AtomicBoolean closing = new AtomicBoolean(false);
|
private final AtomicBoolean closing = new AtomicBoolean(false);
|
||||||
@ -52,6 +53,7 @@ class StoreScanner implements KeyValueScanner, InternalScanner, ChangedReadersOb
|
|||||||
*/
|
*/
|
||||||
StoreScanner(Store store, Scan scan, final NavigableSet<byte[]> columns) {
|
StoreScanner(Store store, Scan scan, final NavigableSet<byte[]> columns) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
this.cacheBlocks = scan.getCacheBlocks();
|
||||||
matcher = new ScanQueryMatcher(scan, store.getFamily().getName(),
|
matcher = new ScanQueryMatcher(scan, store.getFamily().getName(),
|
||||||
columns, store.ttl, store.comparator.getRawComparator(),
|
columns, store.ttl, store.comparator.getRawComparator(),
|
||||||
store.versionsToReturn(scan.getMaxVersions()));
|
store.versionsToReturn(scan.getMaxVersions()));
|
||||||
@ -77,6 +79,7 @@ class StoreScanner implements KeyValueScanner, InternalScanner, ChangedReadersOb
|
|||||||
*/
|
*/
|
||||||
StoreScanner(Store store, Scan scan, KeyValueScanner [] scanners) {
|
StoreScanner(Store store, Scan scan, KeyValueScanner [] scanners) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
this.cacheBlocks = false;
|
||||||
matcher = new ScanQueryMatcher(scan, store.getFamily().getName(),
|
matcher = new ScanQueryMatcher(scan, store.getFamily().getName(),
|
||||||
null, store.ttl, store.comparator.getRawComparator(),
|
null, store.ttl, store.comparator.getRawComparator(),
|
||||||
store.versionsToReturn(scan.getMaxVersions()));
|
store.versionsToReturn(scan.getMaxVersions()));
|
||||||
@ -96,6 +99,7 @@ class StoreScanner implements KeyValueScanner, InternalScanner, ChangedReadersOb
|
|||||||
final NavigableSet<byte[]> columns,
|
final NavigableSet<byte[]> columns,
|
||||||
final KeyValueScanner [] scanners) {
|
final KeyValueScanner [] scanners) {
|
||||||
this.store = null;
|
this.store = null;
|
||||||
|
this.cacheBlocks = scan.getCacheBlocks();
|
||||||
this.matcher = new ScanQueryMatcher(scan, colFamily, columns, ttl,
|
this.matcher = new ScanQueryMatcher(scan, colFamily, columns, ttl,
|
||||||
comparator.getRawComparator(), scan.getMaxVersions());
|
comparator.getRawComparator(), scan.getMaxVersions());
|
||||||
|
|
||||||
@ -215,7 +219,7 @@ class StoreScanner implements KeyValueScanner, InternalScanner, ChangedReadersOb
|
|||||||
LOG.warn("StoreFile " + sf + " has null Reader");
|
LOG.warn("StoreFile " + sf + " has null Reader");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s.add(r.getScanner());
|
s.add(r.getScanner(cacheBlocks));
|
||||||
}
|
}
|
||||||
List<KeyValueScanner> scanners =
|
List<KeyValueScanner> scanners =
|
||||||
new ArrayList<KeyValueScanner>(s.size()+1);
|
new ArrayList<KeyValueScanner>(s.size()+1);
|
||||||
|
@ -359,6 +359,7 @@ public class TestSerialization extends HBaseTestCase {
|
|||||||
|
|
||||||
assertTrue(Bytes.equals(scan.getStartRow(), desScan.getStartRow()));
|
assertTrue(Bytes.equals(scan.getStartRow(), desScan.getStartRow()));
|
||||||
assertTrue(Bytes.equals(scan.getStopRow(), desScan.getStopRow()));
|
assertTrue(Bytes.equals(scan.getStopRow(), desScan.getStopRow()));
|
||||||
|
assertEquals(scan.getCacheBlocks(), desScan.getCacheBlocks());
|
||||||
Set<byte[]> set = null;
|
Set<byte[]> set = null;
|
||||||
Set<byte[]> desSet = null;
|
Set<byte[]> desSet = null;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user