Author: stack
Date: Fri Sep 23 20:05:20 2011
New Revision: 1174987

URL: http://svn.apache.org/viewvc?rev=1174987&view=rev
Log:
HBASE-4434: Don't do HFile Scanner next() unless the next KV is needed

Modified:
    hbase/branches/0.92/CHANGES.txt
    
hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
    
hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1174987&r1=1174986&r2=1174987&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Fri Sep 23 20:05:20 2011
@@ -2164,6 +2164,8 @@ Release 0.90.0 - January 19th, 2011
    HBASE-3372  HRS shouldn't print a full stack for ServerNotRunningException
    HBASE-3392  Update backport of InputSampler to reflect MAPREDUCE-1820
    HBASE-3405  Allow HBaseRpcMetrics to register custom interface methods
+   HBASE-4423  Don't do HFile Scanner next() unless the next KV is needed
+               (Kannan  Muthukkaruppan)
 
 
   NEW FEATURES

Modified: 
hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
URL: 
http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java?rev=1174987&r1=1174986&r2=1174987&view=diff
==============================================================================
--- 
hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
 (original)
+++ 
hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
 Fri Sep 23 20:05:20 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/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
URL: 
http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java?rev=1174987&r1=1174986&r2=1174987&view=diff
==============================================================================
--- 
hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
 (original)
+++ 
hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
 Fri Sep 23 20:05:20 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);
 


Reply via email to