hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1169914 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/KeyValue.java src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
Date Mon, 12 Sep 2011 20:41:22 GMT
Author: stack
Date: Mon Sep 12 20:41:22 2011
New Revision: 1169914

URL: http://svn.apache.org/viewvc?rev=1169914&view=rev
Log:
HBASE-4325 Improve error message when using STARTROW for meta scans

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1169914&r1=1169913&r2=1169914&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Mon Sep 12 20:41:22 2011
@@ -568,6 +568,8 @@ Release 0.90.5 - Unreleased
    HBASE-4294  HLogSplitter sleeps with 1-second granularity (todd)
    HBASE-4270  IOE ignored during flush-on-close causes dataloss
    HBASE-4180  HBase should check the isSecurityEnabled flag before login
+   HBASE-4325  Improve error message when using STARTROW for meta scans
+               (Jonathan Hsieh)
 
   IMPROVEMENT
    HBASE-4205  Enhance HTable javadoc (Eric Charles)

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java?rev=1169914&r1=1169913&r2=1169914&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java Mon Sep 12 20:41:22 2011
@@ -1311,12 +1311,16 @@ public class KeyValue implements Writabl
     return index;
   }
 
+  /**
+   * This function is only used in Meta key comparisons so its error message 
+   * is specific for meta key errors.
+   */
   static int getRequiredDelimiterInReverse(final byte [] b,
       final int offset, final int length, final int delimiter) {
     int index = getDelimiterInReverse(b, offset, length, delimiter);
     if (index < 0) {
-      throw new IllegalArgumentException("No " + delimiter + " in <" +
-        Bytes.toString(b) + ">" + ", length=" + length + ", offset=" + offset);
+      throw new IllegalArgumentException(".META. key must have two '" + (char)delimiter +
"' "
+        + "delimiters and have the following format: '<table>,<key>,<etc>'");
     }
     return index;
   }

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java?rev=1169914&r1=1169913&r2=1169914&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java Mon Sep 12 20:41:22
2011
@@ -28,6 +28,7 @@ import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.KeyValue.KVComparator;
+import org.apache.hadoop.hbase.KeyValue.MetaComparator;
 import org.apache.hadoop.hbase.KeyValue.Type;
 import org.apache.hadoop.hbase.util.Bytes;
 
@@ -149,6 +150,33 @@ public class TestKeyValue extends TestCa
     metacomparisons(new KeyValue.MetaComparator());
   }
 
+  public void testBadMetaCompareSingleDelim() {
+    MetaComparator c = new KeyValue.MetaComparator();
+    long now = System.currentTimeMillis();
+    // meta keys values are not quite right.  A users can enter illegal values 
+    // from shell when scanning meta.
+    KeyValue a = new KeyValue(Bytes.toBytes("table,a1"), now);
+    KeyValue b = new KeyValue(Bytes.toBytes("table,a2"), now);
+    try {
+      c.compare(a, b);
+    } catch (IllegalArgumentException iae) { 
+      assertEquals(".META. key must have two ',' delimiters and have the following" +
+      		" format: '<table>,<key>,<etc>'", iae.getMessage());
+      return;
+    }
+    fail("Expected IllegalArgumentException");
+  }
+
+  public void testMetaComparatorTableKeysWithCommaOk() {
+    MetaComparator c = new KeyValue.MetaComparator();
+    long now = System.currentTimeMillis();
+    // meta keys values are not quite right.  A users can enter illegal values 
+    // from shell when scanning meta.
+    KeyValue a = new KeyValue(Bytes.toBytes("table,key,with,commas1,1234"), now);
+    KeyValue b = new KeyValue(Bytes.toBytes("table,key,with,commas2,0123"), now);
+    assertTrue(c.compare(a, b) < 0);
+  }
+  
   /**
    * Tests cases where rows keys have characters below the ','.
    * See HBASE-832



Mime
View raw message