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
This commit is contained in:
Michael Stack 2009-06-30 21:05:14 +00:00
parent 54cdde2cf4
commit 89429bc61e
7 changed files with 23 additions and 18 deletions

View File

@ -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

View File

@ -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 <code>c</code> 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);

View File

@ -178,7 +178,7 @@ public class Scan implements Writable {
*/
public Scan addColumn(byte[] familyAndQualifier) {
byte [][] fq = KeyValue.parseColumn(familyAndQualifier);
if (fq[1].length > 0) {
if (fq.length > 1 && fq[1] != null && fq[1].length > 0) {
addColumn(fq[0], fq[1]);
} else {
addFamily(fq[0]);
@ -187,7 +187,7 @@ 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.
* <p>
* Overrides previous calls to addFamily for any families in the input.
*

View File

@ -39,9 +39,11 @@ public class TimestampTestBase extends HBaseTestCase {
private static final long T1 = 100L;
private static final long T2 = 200L;
private static final String COLUMN_NAME = "contents:contents";
private static final String COLUMN_NAME = "colfamily1:contents";
private static final byte [] COLUMN = Bytes.toBytes(COLUMN_NAME);
private static final byte [][] COLUMNS =
new byte [][] {Bytes.toBytes("colfamily1")};
private static final byte [] ROW = Bytes.toBytes("row");
/*

View File

@ -31,7 +31,7 @@ import org.apache.hadoop.hbase.TimestampTestBase;
* run against an HRegion and against an HTable: i.e. both local and remote.
*/
public class TestTimestamp extends HBaseClusterTestCase {
public static String COLUMN_NAME = "contents";
public static String COLUMN_NAME = "colfamily1";
/** constructor */
public TestTimestamp() {

View File

@ -1480,21 +1480,19 @@ public class TestHRegion extends HBaseTestCase {
*/
public void testScanSplitOnRegion() throws Exception {
byte [] tableName = Bytes.toBytes("testtable");
byte [][] families = {fam3};
HBaseConfiguration hc = initSplit();
//Setting up region
String method = this.getName();
initHRegion(tableName, method, hc, families);
initHRegion(tableName, method, hc, new byte [][] {fam3});
try {
addContent(region, fam3);
region.flushcache();
final byte [] midkey = region.compactStores();
assertNotNull(midkey);
byte [][] cols = {fam3};
Scan scan = new Scan();
scan.addColumns(cols);
scan.addFamily(fam3);
final InternalScanner s = region.getScanner(scan);
final HRegion regionForThread = region;
@ -1544,16 +1542,16 @@ public class TestHRegion extends HBaseTestCase {
/*
* Assert first value in the passed region is <code>firstValue</code>.
* @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<KeyValue> curVals = new ArrayList<KeyValue>();

View File

@ -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;