HBASE-6182 TestStoreFile fails with jdk1.7

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1347389 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-06-07 04:58:53 +00:00
parent bf5cf529e4
commit 5942082548
5 changed files with 14 additions and 16 deletions

View File

@ -147,9 +147,6 @@ implements WritableComparable<HRegionInfo> {
return encodedRegionName; return encodedRegionName;
} }
/** delimiter used between portions of a region name */
public static final int DELIMITER = ',';
/** HRegionInfo for root region */ /** HRegionInfo for root region */
public static final HRegionInfo ROOT_REGIONINFO = public static final HRegionInfo ROOT_REGIONINFO =
new HRegionInfo(0L, Bytes.toBytes("-ROOT-")); new HRegionInfo(0L, Bytes.toBytes("-ROOT-"));
@ -363,12 +360,12 @@ implements WritableComparable<HRegionInfo> {
int offset = tableName.length; int offset = tableName.length;
System.arraycopy(tableName, 0, b, 0, offset); System.arraycopy(tableName, 0, b, 0, offset);
b[offset++] = DELIMITER; b[offset++] = HConstants.REGIONINFO_DELIMITER;
if (startKey != null && startKey.length > 0) { if (startKey != null && startKey.length > 0) {
System.arraycopy(startKey, 0, b, offset, startKey.length); System.arraycopy(startKey, 0, b, offset, startKey.length);
offset += startKey.length; offset += startKey.length;
} }
b[offset++] = DELIMITER; b[offset++] = HConstants.REGIONINFO_DELIMITER;
System.arraycopy(id, 0, b, offset, id.length); System.arraycopy(id, 0, b, offset, id.length);
offset += id.length; offset += id.length;
@ -406,7 +403,7 @@ implements WritableComparable<HRegionInfo> {
public static byte [] getTableName(byte [] regionName) { public static byte [] getTableName(byte [] regionName) {
int offset = -1; int offset = -1;
for (int i = 0; i < regionName.length; i++) { for (int i = 0; i < regionName.length; i++) {
if (regionName[i] == DELIMITER) { if (regionName[i] == HConstants.REGIONINFO_DELIMITER) {
offset = i; offset = i;
break; break;
} }
@ -426,7 +423,7 @@ implements WritableComparable<HRegionInfo> {
throws IOException { throws IOException {
int offset = -1; int offset = -1;
for (int i = 0; i < regionName.length; i++) { for (int i = 0; i < regionName.length; i++) {
if (regionName[i] == DELIMITER) { if (regionName[i] == HConstants.REGIONINFO_DELIMITER) {
offset = i; offset = i;
break; break;
} }
@ -436,7 +433,7 @@ implements WritableComparable<HRegionInfo> {
System.arraycopy(regionName, 0, tableName, 0, offset); System.arraycopy(regionName, 0, tableName, 0, offset);
offset = -1; offset = -1;
for (int i = regionName.length - 1; i > 0; i--) { for (int i = regionName.length - 1; i > 0; i--) {
if(regionName[i] == DELIMITER) { if(regionName[i] == HConstants.REGIONINFO_DELIMITER) {
offset = i; offset = i;
break; break;
} }

View File

@ -454,8 +454,8 @@ public class MetaReader {
static byte [] getTableStartRowForMeta(final byte [] tableName) { static byte [] getTableStartRowForMeta(final byte [] tableName) {
byte [] startRow = new byte[tableName.length + 2]; byte [] startRow = new byte[tableName.length + 2];
System.arraycopy(tableName, 0, startRow, 0, tableName.length); System.arraycopy(tableName, 0, startRow, 0, tableName.length);
startRow[startRow.length - 2] = HRegionInfo.DELIMITER; startRow[startRow.length - 2] = HConstants.REGIONINFO_DELIMITER;
startRow[startRow.length - 1] = HRegionInfo.DELIMITER; startRow[startRow.length - 1] = HConstants.REGIONINFO_DELIMITER;
return startRow; return startRow;
} }

View File

@ -25,6 +25,7 @@ import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.KVComparator; import org.apache.hadoop.hbase.KeyValue.KVComparator;
@ -70,7 +71,7 @@ class GetClosestRowBeforeTracker {
int l = -1; int l = -1;
if (metaregion) { if (metaregion) {
l = KeyValue.getDelimiter(kv.getBuffer(), rowoffset, kv.getRowLength(), l = KeyValue.getDelimiter(kv.getBuffer(), rowoffset, kv.getRowLength(),
HRegionInfo.DELIMITER) - this.rowoffset; HConstants.REGIONINFO_DELIMITER) - this.rowoffset;
} }
this.tablenamePlusDelimiterLength = metaregion? l + 1: -1; this.tablenamePlusDelimiterLength = metaregion? l + 1: -1;
this.oldestts = System.currentTimeMillis() - ttl; this.oldestts = System.currentTimeMillis() - ttl;

View File

@ -166,9 +166,9 @@ public class TestGetClosestAtOrBefore extends HBaseTestCase {
private byte [] extractRowFromMetaRow(final byte [] b) { private byte [] extractRowFromMetaRow(final byte [] b) {
int firstDelimiter = KeyValue.getDelimiter(b, 0, b.length, int firstDelimiter = KeyValue.getDelimiter(b, 0, b.length,
HRegionInfo.DELIMITER); HConstants.REGIONINFO_DELIMITER);
int lastDelimiter = KeyValue.getDelimiterInReverse(b, 0, b.length, int lastDelimiter = KeyValue.getDelimiterInReverse(b, 0, b.length,
HRegionInfo.DELIMITER); HConstants.REGIONINFO_DELIMITER);
int length = lastDelimiter - firstDelimiter - 1; int length = lastDelimiter - firstDelimiter - 1;
byte [] row = new byte[length]; byte [] row = new byte[length];
System.arraycopy(b, firstDelimiter + 1, row, 0, length); System.arraycopy(b, firstDelimiter + 1, row, 0, length);

View File

@ -369,7 +369,7 @@ public class TestStoreFile extends HBaseTestCase {
int falseNeg = 0; int falseNeg = 0;
for (int i = 0; i < 2000; i++) { for (int i = 0; i < 2000; i++) {
String row = String.format(localFormatter, i); String row = String.format(localFormatter, i);
TreeSet<byte[]> columns = new TreeSet<byte[]>(); TreeSet<byte[]> columns = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
columns.add("family:col".getBytes()); columns.add("family:col".getBytes());
Scan scan = new Scan(row.getBytes(),row.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 for (int j = 0; j < colCount*2; ++j) { // column qualifiers
String row = String.format(localFormatter, i); String row = String.format(localFormatter, i);
String col = String.format(localFormatter, j); String col = String.format(localFormatter, j);
TreeSet<byte[]> columns = new TreeSet<byte[]>(); TreeSet<byte[]> columns = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
columns.add(("col" + col).getBytes()); columns.add(("col" + col).getBytes());
Scan scan = new Scan(row.getBytes(),row.getBytes()); Scan scan = new Scan(row.getBytes(),row.getBytes());
@ -712,7 +712,7 @@ public class TestStoreFile extends HBaseTestCase {
StoreFile.BloomType.NONE, NoOpDataBlockEncoder.INSTANCE); StoreFile.BloomType.NONE, NoOpDataBlockEncoder.INSTANCE);
StoreFile.Reader reader = hsf.createReader(); StoreFile.Reader reader = hsf.createReader();
StoreFileScanner scanner = reader.getStoreFileScanner(false, false); StoreFileScanner scanner = reader.getStoreFileScanner(false, false);
TreeSet<byte[]> columns = new TreeSet<byte[]>(); TreeSet<byte[]> columns = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
columns.add(qualifier); columns.add(qualifier);
scan.setTimeRange(20, 100); scan.setTimeRange(20, 100);