hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r747967 - in /hadoop/hbase/branches/0.19: CHANGES.txt src/java/org/apache/hadoop/hbase/io/HalfMapFileReader.java src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java
Date Wed, 25 Feb 2009 23:34:51 GMT
Author: stack
Date: Wed Feb 25 23:34:51 2009
New Revision: 747967

URL: http://svn.apache.org/viewvc?rev=747967&view=rev
Log:
HBASE-1224 Scanner returns values from before startrow

Modified:
    hadoop/hbase/branches/0.19/CHANGES.txt
    hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/io/HalfMapFileReader.java
    hadoop/hbase/branches/0.19/src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java

Modified: hadoop/hbase/branches/0.19/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/CHANGES.txt?rev=747967&r1=747966&r2=747967&view=diff
==============================================================================
--- hadoop/hbase/branches/0.19/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.19/CHANGES.txt Wed Feb 25 23:34:51 2009
@@ -10,6 +10,8 @@
    HBASE-1190  TableInputFormatBase with row filters scan too far (Dave
                Latham via Andrew Purtell)
    HBASE-1198  OOME in IPC server does not trigger abort behavior
+   HBASE-1224  Scanner returns values from before startrow
+               (Ben Maurer via Stack)
 
   IMPROVEMENTS
    HBASE-845   HCM.isTableEnabled doesn't really tell if it is, or not

Modified: hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/io/HalfMapFileReader.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/io/HalfMapFileReader.java?rev=747967&r1=747966&r2=747967&view=diff
==============================================================================
--- hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/io/HalfMapFileReader.java
(original)
+++ hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/io/HalfMapFileReader.java
Wed Feb 25 23:34:51 2009
@@ -21,6 +21,9 @@
 
 import java.io.IOException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -45,6 +48,8 @@
  */
 //TODO should be fixed generic warnings from MapFile methods
 public class HalfMapFileReader extends BloomFilterMapFile.Reader {
+  private static final Log LOG = LogFactory.getLog(HalfMapFileReader.class);
+
   private final boolean top;
   private final HStoreKey midkey;
   private boolean firstNextCall = true;
@@ -146,6 +151,8 @@
       // greater.
       closest = (key.compareTo(this.midkey) < 0)?
         this.midkey: super.getClosest(key, val);
+      // we know that we just went past the midkey
+      firstNextCall = false;
     } else {
       // We're serving bottom of the file.
       if (key.compareTo(this.midkey) < 0) {
@@ -190,7 +197,12 @@
       }
     }
     boolean result = super.next(key, val);
-    if (!top && key.compareTo(midkey) >= 0) {
+    int cmpresult = key.compareTo(midkey);
+
+    if (top && cmpresult < 0) {
+      LOG.error("BUG BUG BUG. HalfMapFileReader wanted to return key out of range. DANGER");
+      throw new IOException("BUG BUG BUG. HalfMapFileReader wanted to return key out of range.
DANGER");
+    } else if (!top && cmpresult >= 0) {
       result = false;
     }
     return result;

Modified: hadoop/hbase/branches/0.19/src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java?rev=747967&r1=747966&r2=747967&view=diff
==============================================================================
--- hadoop/hbase/branches/0.19/src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java
(original)
+++ hadoop/hbase/branches/0.19/src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java
Wed Feb 25 23:34:51 2009
@@ -66,7 +66,34 @@
     // ReflectionUtils.printThreadInfo(new PrintWriter(System.out),
     //  "Temporary end-of-test thread dump debugging HADOOP-2040: " + getName());
   }
-  
+
+  /**
+   * Assert we can go to an offset in top file and then start nexting from there.
+   * See hbase-1224.
+   * @throws Exception
+   */
+  @SuppressWarnings("unchecked")
+  public void testNextingAtOffsetinHalfMapFile() throws Exception {
+    Path p = writeMapFile(getName());
+    WritableComparable midkey = getMidkey(p);
+    // Now test reading from the top.
+    HalfMapFileReader top = new HalfMapFileReader(this.fs, p.toString(),
+      this.conf, Reference.Range.top, midkey, null);
+    ImmutableBytesWritable val = new ImmutableBytesWritable();
+    final String startRowPrefix = "zy";
+    HStoreKey key = new HStoreKey(startRowPrefix);
+    WritableComparable closest = top.getClosest(key, val);
+    assertTrue(closest.toString().startsWith(startRowPrefix));
+    int count = 0;
+    for (boolean first = true; top.next(key, val); count++) {
+      if (first) {
+        assertTrue(key.toString().compareTo(startRowPrefix) > 0);
+      }
+      LOG.info(key.toString());
+    }
+    assertTrue(count > 0);
+  }
+
   private Path writeMapFile(final String name)
   throws IOException {
     Path path = new Path(DIR, name);



Mime
View raw message