hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1498953 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
Date Tue, 02 Jul 2013 14:21:36 GMT
Author: larsh
Date: Tue Jul  2 14:21:35 2013
New Revision: 1498953

URL: http://svn.apache.org/r1498953
Log:
HBASE-8767 Backport hbase-8001 and hbase-8012, avoid lazy seek (original patches by Raymond
Liu)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java?rev=1498953&r1=1498952&r2=1498953&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
Tue Jul  2 14:21:35 2013
@@ -314,7 +314,8 @@ public class KeyValueHeap extends NonLaz
       }
 
       boolean seekResult;
-      if (isLazy) {
+      if (isLazy && heap.size() > 0) {
+        // If there is only one scanner left, we don't do lazy seek.
         seekResult = scanner.requestSeek(seekKey, forward, useBloom);
       } else {
         seekResult = NonLazyKeyValueScanner.doRealSeek(

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java?rev=1498953&r1=1498952&r2=1498953&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileScanner.java
Tue Jul  2 14:21:35 2013
@@ -52,11 +52,6 @@ public class StoreFileScanner implements
 
   private boolean enforceMVCC = false;
 
-  //The variable, realSeekDone, may cheat on store file scanner for the
-  // multi-column bloom-filter optimization.
-  // So this flag shows whether this storeFileScanner could do a reseek.
-  private boolean isReseekable = false;
-
   private static final AtomicLong seekCount = new AtomicLong();
 
   private ScanQueryMatcher matcher;
@@ -147,7 +142,6 @@ public class StoreFileScanner implements
           return false;
         }
 
-        this.isReseekable = true;
         cur = hfs.getKeyValue();
 
         return skipKVsNewerThanReadpoint();
@@ -241,6 +235,12 @@ public class StoreFileScanner implements
     //This function is similar to seekAtOrAfter function
     int result = s.reseekTo(k.getBuffer(), k.getKeyOffset(), k.getKeyLength());
     if (result <= 0) {
+      // If up to now scanner is not seeked yet, this means passed KV is smaller
+      // than first KV in file, and it is the first time we seek on this file.
+      // So we also need to work from the start of file.
+      if (!s.isSeeked()) {
+        return  s.seekTo();
+      }
       return true;
     } else {
       // passed KV is larger than current KV in file, if there is a next
@@ -345,7 +345,7 @@ public class StoreFileScanner implements
     if (realSeekDone)
       return;
 
-    if (delayedReseek && this.isReseekable) {
+    if (delayedReseek) {
       reseek(delayedSeekKV);
     } else {
       seek(delayedSeekKV);

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java?rev=1498953&r1=1498952&r2=1498953&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
Tue Jul  2 14:21:35 2013
@@ -37,6 +37,7 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseTestCase;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.SmallTests;
@@ -608,6 +609,33 @@ public class TestStoreFile extends HBase
         + ", expected no more than " + maxFalsePos, falsePos <= maxFalsePos);
   }
 
+  /**
+   * Test for HBASE-8012
+   */
+  public void testReseek() throws Exception {
+    // write the file
+    Path f = new Path(ROOT_DIR, getName());
+
+    // Make a store file and write data to it.
+    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf,
+         this.fs, 8 * 1024)
+            .withFilePath(f)
+            .build();
+
+    writeStoreFile(writer);
+    writer.close();
+
+    StoreFile.Reader reader = new StoreFile.Reader(fs, f, cacheConf, DataBlockEncoding.NONE);
+
+    // Now do reseek with empty KV to position to the beginning of the file
+
+    KeyValue k = KeyValue.createFirstOnRow(HConstants.EMPTY_BYTE_ARRAY);
+    StoreFileScanner s = reader.getStoreFileScanner(false, false);
+    s.reseek(k);
+
+    assertNotNull("Intial reseek should position at the beginning of the file", s.peek());
+  }
+
   public void testBloomTypes() throws Exception {
     float err = (float) 0.01;
     FileSystem fs = FileSystem.getLocal(conf);



Mime
View raw message