From 89429bc61ed951973ef4c44672a34770b3d8b57b Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 30 Jun 2009 21:05:14 +0000 Subject: [PATCH] HBASE-1594 Fix scan addcolumns after hbase-1385 commit (broken hudson build) git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@789954 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/java/org/apache/hadoop/hbase/KeyValue.java | 7 +++++-- src/java/org/apache/hadoop/hbase/client/Scan.java | 8 ++++---- .../org/apache/hadoop/hbase/TimestampTestBase.java | 4 +++- .../apache/hadoop/hbase/client/TestTimestamp.java | 2 +- .../hadoop/hbase/regionserver/TestHRegion.java | 14 ++++++-------- .../hadoop/hbase/regionserver/TestScanner.java | 5 +++-- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 90c9b0c6db5..89a4c50eb96 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -235,6 +235,7 @@ Release 0.20.0 - Unreleased HBASE-1437 broken links in hbase.org HBASE-1582 Translate ColumnValueFilter and RowFilterSet to the new Filter interface + HBASE-1594 Fix scan addcolumns after hbase-1385 commit (broken hudson build) IMPROVEMENTS HBASE-1089 Add count of regions on filesystem to master UI; add percentage diff --git a/src/java/org/apache/hadoop/hbase/KeyValue.java b/src/java/org/apache/hadoop/hbase/KeyValue.java index a1ac6d0d924..e02c7216b69 100644 --- a/src/java/org/apache/hadoop/hbase/KeyValue.java +++ b/src/java/org/apache/hadoop/hbase/KeyValue.java @@ -1183,9 +1183,12 @@ public class KeyValue implements Writable, HeapSize { */ public static byte [][] parseColumn(byte [] c) { final byte [][] result = new byte [2][]; - final int index = getFamilyDelimiterIndex(c, 0, c.length); + final int index = getDelimiter(c, 0, c.length, COLUMN_FAMILY_DELIMITER); if (index == -1) { - throw new IllegalArgumentException("Impossible column name: " + c); + // If no delimiter, return c as family and null qualifier. + result[0] = c; + result[1] = null; + return result; } result[0] = new byte [index]; System.arraycopy(c, 0, result[0], 0, index); diff --git a/src/java/org/apache/hadoop/hbase/client/Scan.java b/src/java/org/apache/hadoop/hbase/client/Scan.java index e3770403045..baa82d6d2e2 100644 --- a/src/java/org/apache/hadoop/hbase/client/Scan.java +++ b/src/java/org/apache/hadoop/hbase/client/Scan.java @@ -177,8 +177,8 @@ public class Scan implements Writable { * @throws IllegalArgumentException When the colon is missing. */ public Scan addColumn(byte[] familyAndQualifier) { - byte[][] fq = KeyValue.parseColumn(familyAndQualifier); - if (fq[1].length > 0) { + byte [][] fq = KeyValue.parseColumn(familyAndQualifier); + if (fq.length > 1 && fq[1] != null && fq[1].length > 0) { addColumn(fq[0], fq[1]); } else { addFamily(fq[0]); @@ -187,14 +187,14 @@ public class Scan implements Writable { } /** - * Adds an array of columns specified the old format, family:qualifier. + * Adds an array of columns specified using old format, family:qualifier. *

* Overrides previous calls to addFamily for any families in the input. * * @param columns array of columns, formatted as

family:qualifier
*/ public Scan addColumns(byte [][] columns) { - for(int i=0; ifirstValue. * @param r - * @param column + * @param fs * @param firstValue * @throws IOException */ - private void assertScan(final HRegion r, final byte [] column, + private void assertScan(final HRegion r, final byte [] fs, final byte [] firstValue) throws IOException { - byte [][] cols = {column}; + byte [][] families = {fs}; Scan scan = new Scan(); - scan.addColumns(cols); + for (int i = 0; i < families.length; i++) scan.addFamily(families[i]); InternalScanner s = r.getScanner(scan); try { List curVals = new ArrayList(); diff --git a/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java b/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java index f5e8b2e55de..369b504faec 100644 --- a/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java +++ b/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java @@ -285,7 +285,9 @@ public class TestScanner extends HBaseTestCase { for(int i = 0; i < scanColumns.length; i++) { try { scan = new Scan(FIRST_ROW); - scan.addColumns(scanColumns[i]); + for (int ii = 0; ii < EXPLICIT_COLS.length; ii++) { + scan.addColumn(COLS[0], EXPLICIT_COLS[ii]); + } scanner = r.getScanner(scan); while (scanner.next(results)) { assertTrue(hasColumn(results, HConstants.CATALOG_FAMILY, @@ -316,7 +318,6 @@ public class TestScanner extends HBaseTestCase { } results.clear(); } - } finally { InternalScanner s = scanner; scanner = null;