HBASE-4434 seek optimization: don't do eager HFile Scanner next() unless the next KV is needed
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1174982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f38c6df8a
commit
2345d9298e
|
@ -534,6 +534,9 @@ Release 0.92.0 - Unreleased
|
|||
HBASE-4424 Provide coprocessors access to createTable() via
|
||||
MasterServices
|
||||
HBASE-4432 Enable/Disable off heap cache with config (Li Pi)
|
||||
HBASE-4434 seek optimization: don't do eager HFile Scanner
|
||||
next() unless the next KV is needed
|
||||
(Kannan Muthukkaruppan)
|
||||
|
||||
TASKS
|
||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||
|
|
|
@ -80,11 +80,12 @@ class StoreFileScanner implements KeyValueScanner {
|
|||
|
||||
public KeyValue next() throws IOException {
|
||||
KeyValue retKey = cur;
|
||||
cur = hfs.getKeyValue();
|
||||
try {
|
||||
// only seek if we arent at the end. cur == null implies 'end'.
|
||||
if (cur != null)
|
||||
// only seek if we aren't at the end. cur == null implies 'end'.
|
||||
if (cur != null) {
|
||||
hfs.next();
|
||||
cur = hfs.getKeyValue();
|
||||
}
|
||||
} catch(IOException e) {
|
||||
throw new IOException("Could not iterate " + this, e);
|
||||
}
|
||||
|
@ -98,7 +99,6 @@ class StoreFileScanner implements KeyValueScanner {
|
|||
return false;
|
||||
}
|
||||
cur = hfs.getKeyValue();
|
||||
hfs.next();
|
||||
return true;
|
||||
} catch(IOException ioe) {
|
||||
throw new IOException("Could not seek " + this, ioe);
|
||||
|
@ -112,7 +112,6 @@ class StoreFileScanner implements KeyValueScanner {
|
|||
return false;
|
||||
}
|
||||
cur = hfs.getKeyValue();
|
||||
hfs.next();
|
||||
return true;
|
||||
} catch (IOException ioe) {
|
||||
throw new IOException("Could not seek " + this, ioe);
|
||||
|
|
|
@ -137,7 +137,7 @@ public class TestBlocksRead extends HBaseTestCase {
|
|||
KeyValue[] kvs = region.get(get, null).raw();
|
||||
long blocksEnd = getBlkAccessCount(cf);
|
||||
if (expBlocks != -1) {
|
||||
assertEquals("Blocks Read Check", expBlocks, blocksEnd - blocksStart);
|
||||
assertEquals("Blocks Read Check", expBlocks, blocksEnd - blocksStart);
|
||||
}
|
||||
System.out.println("Blocks Read = " + (blocksEnd - blocksStart) +
|
||||
"Expected = " + expBlocks);
|
||||
|
@ -201,13 +201,13 @@ public class TestBlocksRead extends HBaseTestCase {
|
|||
putData(FAMILY, "row", "col7", 7);
|
||||
region.flushcache();
|
||||
|
||||
// Expected block reads: 3
|
||||
kvs = getData(FAMILY, "row", "col1", 3);
|
||||
// Expected block reads: 2
|
||||
kvs = getData(FAMILY, "row", "col1", 2);
|
||||
assertEquals(1, kvs.length);
|
||||
verifyData(kvs[0], "row", "col1", 1);
|
||||
|
||||
// Expected block reads: 4
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1", "col2"), 4);
|
||||
// Expected block reads: 3
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1", "col2"), 3);
|
||||
assertEquals(2, kvs.length);
|
||||
verifyData(kvs[0], "row", "col1", 1);
|
||||
verifyData(kvs[1], "row", "col2", 2);
|
||||
|
@ -218,8 +218,8 @@ public class TestBlocksRead extends HBaseTestCase {
|
|||
verifyData(kvs[0], "row", "col2", 2);
|
||||
verifyData(kvs[1], "row", "col3", 3);
|
||||
|
||||
// Expected block reads: 6
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col5"), 6);
|
||||
// Expected block reads: 4
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col5"), 4);
|
||||
assertEquals(1, kvs.length);
|
||||
verifyData(kvs[0], "row", "col5", 5);
|
||||
}
|
||||
|
@ -248,13 +248,15 @@ public class TestBlocksRead extends HBaseTestCase {
|
|||
putData(FAMILY, "row", "col2", 4);
|
||||
region.flushcache();
|
||||
|
||||
// Baseline expected blocks read: 4
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1"), 4);
|
||||
// Baseline expected blocks read: 3
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1"), 3);
|
||||
assertEquals(1, kvs.length);
|
||||
verifyData(kvs[0], "row", "col1", 3);
|
||||
|
||||
// Baseline expected blocks read: 4
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1", "col2"), 4);
|
||||
// Baseline expected blocks read: 5
|
||||
// This increase is a minor glitch due to: HBASE-4466. Once that
|
||||
// is fixed this will drop back. The extra access will be a cache hit.
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1", "col2"), 5);
|
||||
assertEquals(2, kvs.length);
|
||||
verifyData(kvs[0], "row", "col1", 3);
|
||||
verifyData(kvs[1], "row", "col2", 4);
|
||||
|
@ -263,14 +265,14 @@ public class TestBlocksRead extends HBaseTestCase {
|
|||
putData(FAMILY, "row", "col3", 5);
|
||||
region.flushcache();
|
||||
|
||||
// Baseline expected blocks read: 7
|
||||
kvs = getData(FAMILY, "row", "col3", 7);
|
||||
// Baseline expected blocks read: 5
|
||||
kvs = getData(FAMILY, "row", "col3", 5);
|
||||
assertEquals(1, kvs.length);
|
||||
verifyData(kvs[0], "row", "col3", 5);
|
||||
|
||||
// Get a column from older file.
|
||||
// Baseline expected blocks read: 5
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1"), 5);
|
||||
// Baseline expected blocks read: 4
|
||||
kvs = getData(FAMILY, "row", Arrays.asList("col1"), 4);
|
||||
assertEquals(1, kvs.length);
|
||||
verifyData(kvs[0], "row", "col1", 3);
|
||||
|
||||
|
|
Loading…
Reference in New Issue