Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A07667EE6 for ; Mon, 12 Sep 2011 20:41:44 +0000 (UTC) Received: (qmail 21611 invoked by uid 500); 12 Sep 2011 20:41:44 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 21582 invoked by uid 500); 12 Sep 2011 20:41:44 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 21575 invoked by uid 99); 12 Sep 2011 20:41:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Sep 2011 20:41:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Sep 2011 20:41:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1747C238897D for ; Mon, 12 Sep 2011 20:41:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110912204123.1747C238897D@eris.apache.org> 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: ',,'"); } 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: '
,,'", 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