HBASE-682 Regularize toString

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@667295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-06-12 23:53:56 +00:00
parent d2c38ff650
commit 4a04330d7f
5 changed files with 28 additions and 39 deletions

View File

@ -83,6 +83,7 @@ Hbase Change Log
HBASE-672 Sort regions in the regionserver UI
HBASE-677 Make HTable, HRegion, HRegionServer, HStore, and HColumnDescriptor
subclassable (Clint Morgan via Stack)
HBASE-682 Regularize toString
NEW FEATURES
HBASE-47 Option to set TTL for columns in hbase

View File

@ -93,6 +93,17 @@ public class HColumnDescriptor implements WritableComparable {
public static final BloomFilterDescriptor DEFAULT_BLOOM_FILTER_DESCRIPTOR =
null;
// Defines for jruby/shell
public static final String NAME = "NAME";
public static final String MAX_VERSIONS = "MAX_VERSIONS";
public static final String COMPRESSION = "COMPRESSION";
public static final String IN_MEMORY = "IN_MEMORY";
public static final String BLOCKCACHE = "BLOCKCACHE";
public static final String MAX_LENGTH = "MAX_LENGTH";
public static final String TTL = "TTL";
public static final String BLOOMFILTER = "BLOOMFILTER";
public static final String FOREVER = "FOREVER";
// Column family name
private byte [] name;
// Number of versions to keep
@ -289,16 +300,17 @@ public class HColumnDescriptor implements WritableComparable {
/** {@inheritDoc} */
@Override
public String toString() {
return "{name: " + Bytes.toString(name) +
", max versions: " + maxVersions +
", compression: " + this.compressionType + ", in memory: " + inMemory +
", block cache enabled: " + blockCacheEnabled +
", max length: " + maxValueLength +
", time to live: " +
return "{" + NAME + " => '" + Bytes.toString(name) +
"', " + MAX_VERSIONS + " => " + maxVersions +
", " + COMPRESSION + " => " + this.compressionType +
", " + IN_MEMORY + " => " + inMemory +
", " + BLOCKCACHE + " => " + blockCacheEnabled +
", " + MAX_LENGTH + " => " + maxValueLength +
", " + TTL + " => " +
(timeToLive == HConstants.FOREVER ? "FOREVER" :
Integer.toString(timeToLive)) +
", bloom filter: " +
(bloomFilterSpecified ? bloomFilter.toString() : "none") +
", " + BLOOMFILTER + " => " +
(bloomFilterSpecified ? bloomFilter.toString() : CompressionType.NONE) +
"}";
}

View File

@ -59,6 +59,8 @@ public class HTableDescriptor implements WritableComparable {
private byte [] name = HConstants.EMPTY_BYTE_ARRAY;
private String nameAsString = "";
public static final String FAMILIES = "FAMILIES";
// Key is hash of the family name.
private final Map<Integer, HColumnDescriptor> families =
new HashMap<Integer, HColumnDescriptor>();
@ -189,8 +191,8 @@ public class HTableDescriptor implements WritableComparable {
*/
@Override
public String toString() {
return "name: " + Bytes.toString(this.name) + ", families: " +
this.families.values();
return HColumnDescriptor.NAME + " => '" + Bytes.toString(this.name) +
"', " + FAMILIES + " => " + this.families.values();
}
/** {@inheritDoc} */

View File

@ -172,9 +172,9 @@ abstract class BaseScanner extends Chore implements HConstants {
String serverName = Writables.cellToString(values.get(COL_SERVER));
long startCode = Writables.cellToLong(values.get(COL_STARTCODE));
if (LOG.isDebugEnabled()) {
LOG.debug(Thread.currentThread().getName() + " regioninfo: {" +
info.toString() + "}, server: " + serverName + ", startCode: " +
startCode);
LOG.debug(Thread.currentThread().getName() + " {" +
info.toString() + "}, SERVER => '" + serverName +
"', STARTCODE => " + startCode);
}
// Note Region has been assigned.

View File

@ -36,30 +36,4 @@ public class TestToString extends TestCase {
assertEquals("HServerInfo", "address: " + hostport + ", startcode: -1" +
", load: (requests: 0 regions: 0)", info.toString());
}
/**
* Test HTableDescriptor.toString();
*/
public void testHTableDescriptor() {
HTableDescriptor htd = HTableDescriptor.ROOT_TABLEDESC;
System. out.println(htd.toString());
assertEquals("Table descriptor", "name: -ROOT-, families: [{name: " +
"info, max versions: 1, compression: NONE, in memory: false, " +
"block cache enabled: false, max length: 2147483647, " +
"time to live: FOREVER, bloom filter: none}]", htd.toString());
}
/**
* Tests HRegionInfo.toString()
*/
public void testHRegionInfo() {
HRegionInfo hri = HRegionInfo.ROOT_REGIONINFO;
System.out.println(hri.toString());
assertEquals("HRegionInfo",
"regionname: -ROOT-,,0, startKey: <>, endKey: <>, encodedName: 70236052, tableDesc: " +
"{name: -ROOT-, families: [{name: info, max versions: 1, " +
"compression: NONE, in memory: false, block cache enabled: false, " +
"max length: 2147483647, time to live: FOREVER, bloom filter: none}]}",
hri.toString());
}
}