Author: stack
Date: Fri Sep 23 19:54:25 2011
New Revision: 1174982
URL: http://svn.apache.org/viewvc?rev=1174982&view=rev
Log:
HBASE-4434 seek optimization: don't do eager HFile Scanner next() unless the
next KV is needed
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
Modified: hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1174982&r1=1174981&r2=1174982&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Fri Sep 23 19:54:25 2011
@@ -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
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java?rev=1174982&r1=1174981&r2=1174982&view=diff
==============================================================================
---
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
(original)
+++
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
Fri Sep 23 19:54:25 2011
@@ -80,11 +80,12 @@ class StoreFileScanner implements KeyVal
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 KeyVal
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 KeyVal
return false;
}
cur = hfs.getKeyValue();
- hfs.next();
return true;
} catch (IOException ioe) {
throw new IOException("Could not seek " + this, ioe);
Modified:
hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java?rev=1174982&r1=1174981&r2=1174982&view=diff
==============================================================================
---
hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
(original)
+++
hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
Fri Sep 23 19:54:25 2011
@@ -137,7 +137,7 @@ public class TestBlocksRead extends HBas
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 HBas
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 HBas
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 HBas
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 HBas
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);