From 5942082548e3a6b5d063fc8f7911db2c530f74ba Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 7 Jun 2012 04:58:53 +0000 Subject: [PATCH] HBASE-6182 TestStoreFile fails with jdk1.7 git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1347389 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/hadoop/hbase/HRegionInfo.java | 13 +++++-------- .../org/apache/hadoop/hbase/catalog/MetaReader.java | 4 ++-- .../regionserver/GetClosestRowBeforeTracker.java | 3 ++- .../regionserver/TestGetClosestAtOrBefore.java | 4 ++-- .../hadoop/hbase/regionserver/TestStoreFile.java | 6 +++--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java index 2bb375e800e..1c1ad999416 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java @@ -147,9 +147,6 @@ implements WritableComparable { return encodedRegionName; } - /** delimiter used between portions of a region name */ - public static final int DELIMITER = ','; - /** HRegionInfo for root region */ public static final HRegionInfo ROOT_REGIONINFO = new HRegionInfo(0L, Bytes.toBytes("-ROOT-")); @@ -363,12 +360,12 @@ implements WritableComparable { int offset = tableName.length; System.arraycopy(tableName, 0, b, 0, offset); - b[offset++] = DELIMITER; + b[offset++] = HConstants.REGIONINFO_DELIMITER; if (startKey != null && startKey.length > 0) { System.arraycopy(startKey, 0, b, offset, startKey.length); offset += startKey.length; } - b[offset++] = DELIMITER; + b[offset++] = HConstants.REGIONINFO_DELIMITER; System.arraycopy(id, 0, b, offset, id.length); offset += id.length; @@ -406,7 +403,7 @@ implements WritableComparable { public static byte [] getTableName(byte [] regionName) { int offset = -1; for (int i = 0; i < regionName.length; i++) { - if (regionName[i] == DELIMITER) { + if (regionName[i] == HConstants.REGIONINFO_DELIMITER) { offset = i; break; } @@ -426,7 +423,7 @@ implements WritableComparable { throws IOException { int offset = -1; for (int i = 0; i < regionName.length; i++) { - if (regionName[i] == DELIMITER) { + if (regionName[i] == HConstants.REGIONINFO_DELIMITER) { offset = i; break; } @@ -436,7 +433,7 @@ implements WritableComparable { System.arraycopy(regionName, 0, tableName, 0, offset); offset = -1; for (int i = regionName.length - 1; i > 0; i--) { - if(regionName[i] == DELIMITER) { + if(regionName[i] == HConstants.REGIONINFO_DELIMITER) { offset = i; break; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java index c3c7de8c2ee..8decd66622e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java @@ -454,8 +454,8 @@ public class MetaReader { static byte [] getTableStartRowForMeta(final byte [] tableName) { byte [] startRow = new byte[tableName.length + 2]; System.arraycopy(tableName, 0, startRow, 0, tableName.length); - startRow[startRow.length - 2] = HRegionInfo.DELIMITER; - startRow[startRow.length - 1] = HRegionInfo.DELIMITER; + startRow[startRow.length - 2] = HConstants.REGIONINFO_DELIMITER; + startRow[startRow.length - 1] = HConstants.REGIONINFO_DELIMITER; return startRow; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/GetClosestRowBeforeTracker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/GetClosestRowBeforeTracker.java index 8174cf5e0cb..83b14239b8c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/GetClosestRowBeforeTracker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/GetClosestRowBeforeTracker.java @@ -25,6 +25,7 @@ import java.util.TreeMap; import java.util.TreeSet; import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.KVComparator; @@ -70,7 +71,7 @@ class GetClosestRowBeforeTracker { int l = -1; if (metaregion) { l = KeyValue.getDelimiter(kv.getBuffer(), rowoffset, kv.getRowLength(), - HRegionInfo.DELIMITER) - this.rowoffset; + HConstants.REGIONINFO_DELIMITER) - this.rowoffset; } this.tablenamePlusDelimiterLength = metaregion? l + 1: -1; this.oldestts = System.currentTimeMillis() - ttl; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java index 99e2197cd73..84d96527a54 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java @@ -166,9 +166,9 @@ public class TestGetClosestAtOrBefore extends HBaseTestCase { private byte [] extractRowFromMetaRow(final byte [] b) { int firstDelimiter = KeyValue.getDelimiter(b, 0, b.length, - HRegionInfo.DELIMITER); + HConstants.REGIONINFO_DELIMITER); int lastDelimiter = KeyValue.getDelimiterInReverse(b, 0, b.length, - HRegionInfo.DELIMITER); + HConstants.REGIONINFO_DELIMITER); int length = lastDelimiter - firstDelimiter - 1; byte [] row = new byte[length]; System.arraycopy(b, firstDelimiter + 1, row, 0, length); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java index 2669cdbc86f..e8232282f55 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java @@ -369,7 +369,7 @@ public class TestStoreFile extends HBaseTestCase { int falseNeg = 0; for (int i = 0; i < 2000; i++) { String row = String.format(localFormatter, i); - TreeSet columns = new TreeSet(); + TreeSet columns = new TreeSet(Bytes.BYTES_COMPARATOR); columns.add("family:col".getBytes()); Scan scan = new Scan(row.getBytes(),row.getBytes()); @@ -528,7 +528,7 @@ public class TestStoreFile extends HBaseTestCase { for (int j = 0; j < colCount*2; ++j) { // column qualifiers String row = String.format(localFormatter, i); String col = String.format(localFormatter, j); - TreeSet columns = new TreeSet(); + TreeSet columns = new TreeSet(Bytes.BYTES_COMPARATOR); columns.add(("col" + col).getBytes()); Scan scan = new Scan(row.getBytes(),row.getBytes()); @@ -712,7 +712,7 @@ public class TestStoreFile extends HBaseTestCase { StoreFile.BloomType.NONE, NoOpDataBlockEncoder.INSTANCE); StoreFile.Reader reader = hsf.createReader(); StoreFileScanner scanner = reader.getStoreFileScanner(false, false); - TreeSet columns = new TreeSet(); + TreeSet columns = new TreeSet(Bytes.BYTES_COMPARATOR); columns.add(qualifier); scan.setTimeRange(20, 100);