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-1437 broken links in hbase.org
HBASE-1582 Translate ColumnValueFilter and RowFilterSet to the new Filter HBASE-1582 Translate ColumnValueFilter and RowFilterSet to the new Filter
interface interface
HBASE-1594 Fix scan addcolumns after hbase-1385 commit (broken hudson build)
IMPROVEMENTS IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage 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) { public static byte [][] parseColumn(byte [] c) {
final byte [][] result = new byte [2][]; 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) { 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]; result[0] = new byte [index];
System.arraycopy(c, 0, result[0], 0, index); System.arraycopy(c, 0, result[0], 0, index);

View File

@ -177,8 +177,8 @@ public class Scan implements Writable {
* @throws IllegalArgumentException When the colon is missing. * @throws IllegalArgumentException When the colon is missing.
*/ */
public Scan addColumn(byte[] familyAndQualifier) { public Scan addColumn(byte[] familyAndQualifier) {
byte[][] fq = KeyValue.parseColumn(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]); addColumn(fq[0], fq[1]);
} else { } else {
addFamily(fq[0]); 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.
* <p> * <p>
* Overrides previous calls to addFamily for any families in the input. * Overrides previous calls to addFamily for any families in the input.
* *
* @param columns array of columns, formatted as <pre>family:qualifier</pre> * @param columns array of columns, formatted as <pre>family:qualifier</pre>
*/ */
public Scan addColumns(byte [][] columns) { public Scan addColumns(byte [][] columns) {
for(int i=0; i<columns.length; i++) { for (int i = 0; i < columns.length; i++) {
addColumn(columns[i]); addColumn(columns[i]);
} }
return this; return this;

View File

@ -39,9 +39,11 @@ public class TimestampTestBase extends HBaseTestCase {
private static final long T1 = 100L; private static final long T1 = 100L;
private static final long T2 = 200L; 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 [] COLUMN = Bytes.toBytes(COLUMN_NAME);
private static final byte [][] COLUMNS =
new byte [][] {Bytes.toBytes("colfamily1")};
private static final byte [] ROW = Bytes.toBytes("row"); 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. * run against an HRegion and against an HTable: i.e. both local and remote.
*/ */
public class TestTimestamp extends HBaseClusterTestCase { public class TestTimestamp extends HBaseClusterTestCase {
public static String COLUMN_NAME = "contents"; public static String COLUMN_NAME = "colfamily1";
/** constructor */ /** constructor */
public TestTimestamp() { public TestTimestamp() {

View File

@ -1480,21 +1480,19 @@ public class TestHRegion extends HBaseTestCase {
*/ */
public void testScanSplitOnRegion() throws Exception { public void testScanSplitOnRegion() throws Exception {
byte [] tableName = Bytes.toBytes("testtable"); byte [] tableName = Bytes.toBytes("testtable");
byte [][] families = {fam3};
HBaseConfiguration hc = initSplit(); HBaseConfiguration hc = initSplit();
//Setting up region //Setting up region
String method = this.getName(); String method = this.getName();
initHRegion(tableName, method, hc, families); initHRegion(tableName, method, hc, new byte [][] {fam3});
try { try {
addContent(region, fam3); addContent(region, fam3);
region.flushcache(); region.flushcache();
final byte [] midkey = region.compactStores(); final byte [] midkey = region.compactStores();
assertNotNull(midkey); assertNotNull(midkey);
byte [][] cols = {fam3};
Scan scan = new Scan(); Scan scan = new Scan();
scan.addColumns(cols); scan.addFamily(fam3);
final InternalScanner s = region.getScanner(scan); final InternalScanner s = region.getScanner(scan);
final HRegion regionForThread = region; final HRegion regionForThread = region;
@ -1544,16 +1542,16 @@ public class TestHRegion extends HBaseTestCase {
/* /*
* Assert first value in the passed region is <code>firstValue</code>. * Assert first value in the passed region is <code>firstValue</code>.
* @param r * @param r
* @param column * @param fs
* @param firstValue * @param firstValue
* @throws IOException * @throws IOException
*/ */
private void assertScan(final HRegion r, final byte [] column, private void assertScan(final HRegion r, final byte [] fs,
final byte [] firstValue) final byte [] firstValue)
throws IOException { throws IOException {
byte [][] cols = {column}; byte [][] families = {fs};
Scan scan = new Scan(); Scan scan = new Scan();
scan.addColumns(cols); for (int i = 0; i < families.length; i++) scan.addFamily(families[i]);
InternalScanner s = r.getScanner(scan); InternalScanner s = r.getScanner(scan);
try { try {
List<KeyValue> curVals = new ArrayList<KeyValue>(); 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++) { for(int i = 0; i < scanColumns.length; i++) {
try { try {
scan = new Scan(FIRST_ROW); 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); scanner = r.getScanner(scan);
while (scanner.next(results)) { while (scanner.next(results)) {
assertTrue(hasColumn(results, HConstants.CATALOG_FAMILY, assertTrue(hasColumn(results, HConstants.CATALOG_FAMILY,
@ -316,7 +318,6 @@ public class TestScanner extends HBaseTestCase {
} }
results.clear(); results.clear();
} }
} finally { } finally {
InternalScanner s = scanner; InternalScanner s = scanner;
scanner = null; scanner = null;