Permalink
Browse files

HBASE-6162 Move KeyValue to hbase-common module

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1350378 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
saintstack committed Jun 14, 2012
1 parent 7769176 commit 001c4839959d31463329a37bb1749df02a18db48
@@ -667,6 +667,8 @@
* The actual value is irrelevant because this is always compared by reference.
*/
public static final byte [] NO_NEXT_INDEXED_KEY = Bytes.toBytes("NO_NEXT_INDEXED_KEY");
+ /** delimiter used between portions of a region name */
+ public static final int DELIMITER = ',';
private HConstants() {
// Can't be instantiated with this ctor.
@@ -1,5 +1,5 @@
/**
- * Copyright 2009 The Apache Software Foundation
+ * Copyright The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -33,7 +33,6 @@
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.io.HeapSize;
-import org.apache.hadoop.hbase.io.hfile.HFile;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.ClassSize;
import org.apache.hadoop.io.RawComparator;
@@ -127,10 +126,10 @@
* @return The comparator.
*/
public static KeyComparator getRowComparator(byte [] tableName) {
- if(Bytes.equals(HTableDescriptor.ROOT_TABLEDESC.getName(),tableName)) {
+ if(Bytes.equals(HConstants.ROOT_TABLE_NAME,tableName)) {
return ROOT_COMPARATOR.getRawComparator();
}
- if(Bytes.equals(HTableDescriptor.META_TABLEDESC.getName(), tableName)) {
+ if(Bytes.equals(HConstants.META_TABLE_NAME, tableName)) {
return META_COMPARATOR.getRawComparator();
}
return COMPARATOR.getRawComparator();
@@ -2232,11 +2231,11 @@ public int compareRows(byte [] left, int loffset, int llength,
int lmetaOffsetPlusDelimiter = loffset + metalength;
int leftFarDelimiter = getDelimiterInReverse(left,
lmetaOffsetPlusDelimiter,
- llength - metalength, HRegionInfo.DELIMITER);
+ llength - metalength, HConstants.DELIMITER);
int rmetaOffsetPlusDelimiter = roffset + metalength;
int rightFarDelimiter = getDelimiterInReverse(right,
rmetaOffsetPlusDelimiter, rlength - metalength,
- HRegionInfo.DELIMITER);
+ HConstants.DELIMITER);
if (leftFarDelimiter < 0 && rightFarDelimiter >= 0) {
// Nothing between .META. and regionid. Its first key.
return -1;
@@ -2287,9 +2286,9 @@ public int compareRows(byte [] left, int loffset, int llength,
// LOG.info("META " + Bytes.toString(left, loffset, llength) +
// "---" + Bytes.toString(right, roffset, rlength));
int leftDelimiter = getDelimiter(left, loffset, llength,
- HRegionInfo.DELIMITER);
+ HConstants.DELIMITER);
int rightDelimiter = getDelimiter(right, roffset, rlength,
- HRegionInfo.DELIMITER);
+ HConstants.DELIMITER);
if (leftDelimiter < 0 && rightDelimiter >= 0) {
// Nothing between .META. and regionid. Its first key.
return -1;
@@ -2309,10 +2308,10 @@ public int compareRows(byte [] left, int loffset, int llength,
leftDelimiter++;
rightDelimiter++;
int leftFarDelimiter = getRequiredDelimiterInReverse(left, leftDelimiter,
- llength - (leftDelimiter - loffset), HRegionInfo.DELIMITER);
+ llength - (leftDelimiter - loffset), HConstants.DELIMITER);
int rightFarDelimiter = getRequiredDelimiterInReverse(right,
rightDelimiter, rlength - (rightDelimiter - roffset),
- HRegionInfo.DELIMITER);
+ HConstants.DELIMITER);
// Now compare middlesection of row.
result = super.compareRows(left, leftDelimiter,
leftFarDelimiter - leftDelimiter, right, rightDelimiter,
@@ -1,5 +1,5 @@
/**
- * Copyright 2009 The Apache Software Foundation
+ * Copyright The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1,5 +1,5 @@
/**
- * Copyright 2010 The Apache Software Foundation
+ * Copyright The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -147,9 +147,6 @@ public static String prettyPrint(final String encodedRegionName) {
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 @@ public HRegionInfo(HRegionInfo other) {
int offset = tableName.length;
System.arraycopy(tableName, 0, b, 0, offset);
- b[offset++] = DELIMITER;
+ b[offset++] = HConstants.DELIMITER;
if (startKey != null && startKey.length > 0) {
System.arraycopy(startKey, 0, b, offset, startKey.length);
offset += startKey.length;
}
- b[offset++] = DELIMITER;
+ b[offset++] = HConstants.DELIMITER;
System.arraycopy(id, 0, b, offset, id.length);
offset += id.length;
@@ -406,7 +403,7 @@ public HRegionInfo(HRegionInfo other) {
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.DELIMITER) {
offset = i;
break;
}
@@ -426,7 +423,7 @@ public HRegionInfo(HRegionInfo other) {
throws IOException {
int offset = -1;
for (int i = 0; i < regionName.length; i++) {
- if (regionName[i] == DELIMITER) {
+ if (regionName[i] == HConstants.DELIMITER) {
offset = i;
break;
}
@@ -436,7 +433,7 @@ public HRegionInfo(HRegionInfo other) {
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.DELIMITER) {
offset = i;
break;
}
@@ -454,8 +454,8 @@ static boolean isInsideTable(final HRegionInfo current, final byte [] tableName)
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.DELIMITER;
+ startRow[startRow.length - 1] = HConstants.DELIMITER;
return startRow;
}
@@ -25,7 +25,7 @@
import java.util.TreeSet;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.KVComparator;
import org.apache.hadoop.hbase.util.Bytes;
@@ -70,7 +70,7 @@
int l = -1;
if (metaregion) {
l = KeyValue.getDelimiter(kv.getBuffer(), rowoffset, kv.getRowLength(),
- HRegionInfo.DELIMITER) - this.rowoffset;
+ HConstants.DELIMITER) - this.rowoffset;
}
this.tablenamePlusDelimiterLength = metaregion? l + 1: -1;
this.oldestts = System.currentTimeMillis() - ttl;
@@ -166,9 +166,9 @@ public void testUsingMetaAndBinary() throws IOException {
private byte [] extractRowFromMetaRow(final byte [] b) {
int firstDelimiter = KeyValue.getDelimiter(b, 0, b.length,
- HRegionInfo.DELIMITER);
+ HConstants.DELIMITER);
int lastDelimiter = KeyValue.getDelimiterInReverse(b, 0, b.length,
- HRegionInfo.DELIMITER);
+ HConstants.DELIMITER);
int length = lastDelimiter - firstDelimiter - 1;
byte [] row = new byte[length];
System.arraycopy(b, firstDelimiter + 1, row, 0, length);

0 comments on commit 001c483

Please sign in to comment.