You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2008/10/07 07:33:00 UTC
svn commit: r702349 -
/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
Author: stack
Date: Mon Oct 6 22:33:00 2008
New Revision: 702349
URL: http://svn.apache.org/viewvc?rev=702349&view=rev
Log:
HBASE-576 Investigate IPC performance; fix miscommit that made for broken build
Modified:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java?rev=702349&r1=702348&r2=702349&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java Mon Oct 6 22:33:00 2008
@@ -38,22 +38,6 @@
* column families.
*/
public class HTableDescriptor implements WritableComparable {
- /** Table descriptor for <core>-ROOT-</code> catalog table */
- public static final HTableDescriptor ROOT_TABLEDESC = new HTableDescriptor(
- HConstants.ROOT_TABLE_NAME,
- new HColumnDescriptor[] { new HColumnDescriptor(HConstants.COLUMN_FAMILY,
- 1, HColumnDescriptor.CompressionType.NONE, false, false,
- Integer.MAX_VALUE, HConstants.FOREVER, false) });
-
- /** Table descriptor for <code>.META.</code> catalog table */
- public static final HTableDescriptor META_TABLEDESC = new HTableDescriptor(
- HConstants.META_TABLE_NAME, new HColumnDescriptor[] {
- new HColumnDescriptor(HConstants.COLUMN_FAMILY, 1,
- HColumnDescriptor.CompressionType.NONE, false, false,
- Integer.MAX_VALUE, HConstants.FOREVER, false),
- new HColumnDescriptor(HConstants.COLUMN_FAMILY_HISTORIAN,
- HConstants.ALL_VERSIONS, HColumnDescriptor.CompressionType.NONE,
- false, false, Integer.MAX_VALUE, HConstants.FOREVER, false) });
// Changes prior to version 3 were not recorded here.
// Version 3 adds metadata as a map where keys and values are byte[].
@@ -68,31 +52,23 @@
public static final String FAMILIES = "FAMILIES";
public static final ImmutableBytesWritable FAMILIES_KEY =
- new ImmutableBytesWritable(Bytes.toBytes(FAMILIES));
-
+ new ImmutableBytesWritable(Bytes.toBytes(FAMILIES));;
public static final String MAX_FILESIZE = "MAX_FILESIZE";
public static final ImmutableBytesWritable MAX_FILESIZE_KEY =
- new ImmutableBytesWritable(Bytes.toBytes("MAX_FILESIZE"));
-
+ new ImmutableBytesWritable(Bytes.toBytes(MAX_FILESIZE));
public static final String READONLY = "READONLY";
public static final ImmutableBytesWritable READONLY_KEY =
- new ImmutableBytesWritable(Bytes.toBytes("READONLY"));
-
+ new ImmutableBytesWritable(Bytes.toBytes(READONLY));
public static final String MEMCACHE_FLUSHSIZE = "MEMCACHE_FLUSHSIZE";
public static final ImmutableBytesWritable MEMCACHE_FLUSHSIZE_KEY =
- new ImmutableBytesWritable(Bytes.toBytes("MEMCACHE_FLUSHSIZE"));
-
+ new ImmutableBytesWritable(Bytes.toBytes(MEMCACHE_FLUSHSIZE));
public static final String IS_ROOT = "IS_ROOT";
public static final ImmutableBytesWritable IS_ROOT_KEY =
- new ImmutableBytesWritable(Bytes.toBytes("IS_ROOT"));
-
+ new ImmutableBytesWritable(Bytes.toBytes(IS_ROOT));
public static final String IS_META = "IS_META";
public static final ImmutableBytesWritable IS_META_KEY =
- new ImmutableBytesWritable(Bytes.toBytes("IS_META"));
-
- public static final ImmutableBytesWritable IN_MEMORY_KEY =
- new ImmutableBytesWritable(Bytes.toBytes(HConstants.IN_MEMORY));
-
+ new ImmutableBytesWritable(Bytes.toBytes(IS_META));
+
// The below are ugly but better than creating them each time till we
// replace booleans being saved as Strings with plain booleans. Need a
// migration script to do this. TODO.
@@ -173,9 +149,9 @@
*/
public HTableDescriptor(final byte [] name) {
super();
+ setMetaFlags(this.name);
this.name = this.isMetaRegion() ? name: isLegalTableName(name);
this.nameAsString = Bytes.toString(this.name);
- setMetaFlags(this.name);
}
/**
@@ -230,7 +206,8 @@
}
private synchronized Boolean calculateIsMetaRegion() {
- return isSomething(IS_META_KEY, false)? Boolean.TRUE: Boolean.FALSE;
+ byte [] value = getValue(IS_META_KEY);
+ return (value != null)? new Boolean(Bytes.toString(value)): Boolean.FALSE;
}
private boolean isSomething(final ImmutableBytesWritable key,
@@ -357,7 +334,10 @@
* HRegionServer cache only
*/
public boolean isInMemory() {
- return isSomething(IN_MEMORY_KEY, DEFAULT_IN_MEMORY);
+ String value = getValue(HConstants.IN_MEMORY);
+ if (value != null)
+ return Boolean.valueOf(value);
+ return DEFAULT_IN_MEMORY;
}
/**
@@ -365,7 +345,7 @@
* the HRegionServer cache only.
*/
public void setInMemory(boolean inMemory) {
- setValue(IN_MEMORY_KEY, inMemory? TRUE: FALSE);
+ setValue(HConstants.IN_MEMORY, Boolean.toString(inMemory));
}
/**
@@ -557,28 +537,18 @@
// Comparable
public int compareTo(Object o) {
- return compareTo(this, (HTableDescriptor)o);
- }
-
- /**
- * @param left
- * @param right
- * @return 0 if equal, etc.
- */
- public static int compareTo(HTableDescriptor left, HTableDescriptor right) {
- int result = Bytes.compareTo(left.getName(), right.getName());
- Collection<HColumnDescriptor> leftFamilies = left.getFamilies();
- Collection<HColumnDescriptor> rightFamilies = right.getFamilies();
+ HTableDescriptor other = (HTableDescriptor) o;
+ int result = Bytes.compareTo(this.name, other.name);
if (result == 0) {
- result = leftFamilies.size() - rightFamilies.size();
+ result = families.size() - other.families.size();
}
- if (result == 0 && leftFamilies.size() != rightFamilies.size()) {
- result = Integer.valueOf(leftFamilies.size()).compareTo(
- Integer.valueOf(rightFamilies.size()));
+ if (result == 0 && families.size() != other.families.size()) {
+ result = Integer.valueOf(families.size()).compareTo(
+ Integer.valueOf(other.families.size()));
}
if (result == 0) {
- for (Iterator<HColumnDescriptor> it = leftFamilies.iterator(),
- it2 = rightFamilies.iterator(); it.hasNext(); ) {
+ for (Iterator<HColumnDescriptor> it = families.values().iterator(),
+ it2 = other.families.values().iterator(); it.hasNext(); ) {
result = it.next().compareTo(it2.next());
if (result != 0) {
break;
@@ -587,7 +557,7 @@
}
if (result == 0) {
// punt on comparison for ordering, just calculate difference
- result = leftFamilies.hashCode() - rightFamilies.hashCode();
+ result = this.values.hashCode() - other.values.hashCode();
if (result < 0)
result = -1;
else if (result > 0)
@@ -595,16 +565,6 @@
}
return result;
}
-
- /**
- * Comparator used in UI jsp.
- */
- public static class HTableDescriptorComparator
- implements java.util.Comparator<HTableDescriptor> {
- public int compare(HTableDescriptor o1, HTableDescriptor o2) {
- return compareTo(o1, o2);
- }
- }
/**
* @return Immutable sorted map of families.
@@ -639,4 +599,21 @@
public static Path getTableDir(Path rootdir, final byte [] tableName) {
return new Path(rootdir, Bytes.toString(tableName));
}
+
+ /** Table descriptor for <core>-ROOT-</code> catalog table */
+ public static final HTableDescriptor ROOT_TABLEDESC = new HTableDescriptor(
+ HConstants.ROOT_TABLE_NAME,
+ new HColumnDescriptor[] { new HColumnDescriptor(HConstants.COLUMN_FAMILY,
+ 1, HColumnDescriptor.CompressionType.NONE, false, false,
+ Integer.MAX_VALUE, HConstants.FOREVER, false) });
+
+ /** Table descriptor for <code>.META.</code> catalog table */
+ public static final HTableDescriptor META_TABLEDESC = new HTableDescriptor(
+ HConstants.META_TABLE_NAME, new HColumnDescriptor[] {
+ new HColumnDescriptor(HConstants.COLUMN_FAMILY, 1,
+ HColumnDescriptor.CompressionType.NONE, false, false,
+ Integer.MAX_VALUE, HConstants.FOREVER, false),
+ new HColumnDescriptor(HConstants.COLUMN_FAMILY_HISTORIAN,
+ HConstants.ALL_VERSIONS, HColumnDescriptor.CompressionType.NONE,
+ false, false, Integer.MAX_VALUE, HConstants.FOREVER, false) });
}