org.apache.hadoop.hbase
Class HTableDescriptor

java.lang.Object
  extended by org.apache.hadoop.hbase.HTableDescriptor
All Implemented Interfaces:
Comparable, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable
Direct Known Subclasses:
UnmodifyableHTableDescriptor

public class HTableDescriptor
extends Object
implements org.apache.hadoop.io.WritableComparable

HTableDescriptor contains the name of an HTable, and its column families.


Field Summary
static boolean DEFAULT_IN_MEMORY
           
static int DEFAULT_MEMCACHE_FLUSH_SIZE
           
static boolean DEFAULT_READONLY
           
static String FAMILIES
           
static String IS_META
           
static String IS_ROOT
           
static String MAX_FILESIZE
           
static String MEMCACHE_FLUSHSIZE
           
static HTableDescriptor META_TABLEDESC
          Table descriptor for .META. catalog table
static String READONLY
           
static HTableDescriptor ROOT_TABLEDESC
          Table descriptor for -ROOT- catalog table
static byte TABLE_DESCRIPTOR_VERSION
           
protected  Map<ImmutableBytesWritable,ImmutableBytesWritable> values
           
 
Constructor Summary
  HTableDescriptor()
          Constructs an empty object.
  HTableDescriptor(byte[] name)
          Constructor.
protected HTableDescriptor(byte[] name, HColumnDescriptor[] families)
          Private constructor used internally creating table descriptors for catalog tables: e.g.
  HTableDescriptor(HTableDescriptor desc)
          Constructor.
  HTableDescriptor(String name)
          Constructor.
 
Method Summary
 void addFamily(HColumnDescriptor family)
          Adds a column family.
 int compareTo(Object o)
          
 boolean equals(Object obj)
          
 Collection<HColumnDescriptor> getFamilies()
           
 HColumnDescriptor getFamily(byte[] column)
           
 long getMaxFileSize()
           
 int getMemcacheFlushSize()
           
 byte[] getName()
           
 String getNameAsString()
           
static org.apache.hadoop.fs.Path getTableDir(org.apache.hadoop.fs.Path rootdir, byte[] tableName)
           
 byte[] getValue(byte[] key)
           
 String getValue(String key)
           
 boolean hasFamily(byte[] c)
          Checks to see if this table contains the given column family
 boolean hasFamily(byte[] c, int index)
          Checks to see if this table contains the given column family
 int hashCode()
          
 boolean isInMemory()
           
static byte[] isLegalTableName(byte[] b)
          Check passed buffer is legal user-space table name.
 boolean isMetaRegion()
           
 boolean isMetaTable()
           
 boolean isReadOnly()
           
 boolean isRootRegion()
           
 void readFields(DataInput in)
          
 HColumnDescriptor removeFamily(byte[] column)
           
 void setInMemory(boolean inMemory)
           
 void setMaxFileSize(long maxFileSize)
           
 void setMemcacheFlushSize(int memcacheFlushSize)
           
protected  void setMetaRegion(boolean isMeta)
           
 void setReadOnly(boolean readOnly)
           
protected  void setRootRegion(boolean isRoot)
           
 void setValue(byte[] key, byte[] value)
           
 void setValue(String key, String value)
           
 String toString()
           
 void write(DataOutput out)
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT_TABLEDESC

public static final HTableDescriptor ROOT_TABLEDESC
Table descriptor for -ROOT- catalog table


META_TABLEDESC

public static final HTableDescriptor META_TABLEDESC
Table descriptor for .META. catalog table


TABLE_DESCRIPTOR_VERSION

public static final byte TABLE_DESCRIPTOR_VERSION
See Also:
Constant Field Values

values

protected Map<ImmutableBytesWritable,ImmutableBytesWritable> values

FAMILIES

public static final String FAMILIES
See Also:
Constant Field Values

MAX_FILESIZE

public static final String MAX_FILESIZE
See Also:
Constant Field Values

READONLY

public static final String READONLY
See Also:
Constant Field Values

MEMCACHE_FLUSHSIZE

public static final String MEMCACHE_FLUSHSIZE
See Also:
Constant Field Values

IS_ROOT

public static final String IS_ROOT
See Also:
Constant Field Values

IS_META

public static final String IS_META
See Also:
Constant Field Values

DEFAULT_IN_MEMORY

public static final boolean DEFAULT_IN_MEMORY
See Also:
Constant Field Values

DEFAULT_READONLY

public static final boolean DEFAULT_READONLY
See Also:
Constant Field Values

DEFAULT_MEMCACHE_FLUSH_SIZE

public static final int DEFAULT_MEMCACHE_FLUSH_SIZE
See Also:
Constant Field Values
Constructor Detail

HTableDescriptor

protected HTableDescriptor(byte[] name,
                           HColumnDescriptor[] families)
Private constructor used internally creating table descriptors for catalog tables: e.g. .META. and -ROOT-.


HTableDescriptor

public HTableDescriptor()
Constructs an empty object. For deserializing an HTableDescriptor instance only.

See Also:
HTableDescriptor(byte[])

HTableDescriptor

public HTableDescriptor(String name)
Constructor.

Parameters:
name - Table name.
Throws:
IllegalArgumentException - if passed a table name that is made of other than 'word' characters, underscore or period: i.e. [a-zA-Z_0-9.].
See Also:
HADOOP-1581 HBASE: Un-openable tablename bug

HTableDescriptor

public HTableDescriptor(byte[] name)
Constructor.

Parameters:
name - Table name.
Throws:
IllegalArgumentException - if passed a table name that is made of other than 'word' characters, underscore or period: i.e. [a-zA-Z_0-9-.].
See Also:
HADOOP-1581 HBASE: Un-openable tablename bug

HTableDescriptor

public HTableDescriptor(HTableDescriptor desc)
Constructor.

Makes a deep copy of the supplied descriptor. Can make a modifiable descriptor from an UnmodifyableHTableDescriptor.

Parameters:
desc - The descriptor.
Method Detail

isRootRegion

public boolean isRootRegion()
Returns:
true if this is the root region

setRootRegion

protected void setRootRegion(boolean isRoot)
Parameters:
isRoot - true if this is the root region

isMetaRegion

public boolean isMetaRegion()
Returns:
true if this is a meta region (part of the root or meta tables)

setMetaRegion

protected void setMetaRegion(boolean isMeta)
Parameters:
isMeta - true if this is a meta region (part of the root or meta tables)

isMetaTable

public boolean isMetaTable()
Returns:
true if table is the meta table

isLegalTableName

public static byte[] isLegalTableName(byte[] b)
Check passed buffer is legal user-space table name.

Parameters:
b - Table name.
Returns:
Returns passed b param
Throws:
NullPointerException - If passed b is null
IllegalArgumentException - if passed a table name that is made of other than 'word' characters or underscores: i.e. [a-zA-Z_0-9].

getValue

public byte[] getValue(byte[] key)
Parameters:
key - The key.
Returns:
The value.

getValue

public String getValue(String key)
Parameters:
key - The key.
Returns:
The value as a string.

setValue

public void setValue(byte[] key,
                     byte[] value)
Parameters:
key - The key.
value - The value.

setValue

public void setValue(String key,
                     String value)
Parameters:
key - The key.
value - The value.

isInMemory

public boolean isInMemory()
Returns:
true if all columns in the table should be kept in the HRegionServer cache only

setInMemory

public void setInMemory(boolean inMemory)
Parameters:
inMemory - True if all of the columns in the table should be kept in the HRegionServer cache only.

isReadOnly

public boolean isReadOnly()
Returns:
true if all columns in the table should be read only

setReadOnly

public void setReadOnly(boolean readOnly)
Parameters:
readOnly - True if all of the columns in the table should be read only.

getName

public byte[] getName()
Returns:
name of table

getNameAsString

public String getNameAsString()
Returns:
name of table

getMaxFileSize

public long getMaxFileSize()
Returns:
max hregion size for table

setMaxFileSize

public void setMaxFileSize(long maxFileSize)
Parameters:
maxFileSize - The maximum file size that a store file can grow to before a split is triggered.

getMemcacheFlushSize

public int getMemcacheFlushSize()
Returns:
memory cache flush size for each hregion

setMemcacheFlushSize

public void setMemcacheFlushSize(int memcacheFlushSize)
Parameters:
memcacheFlushSize - memory cache flush size for each hregion

addFamily

public void addFamily(HColumnDescriptor family)
Adds a column family.

Parameters:
family - HColumnDescriptor of familyto add.

hasFamily

public boolean hasFamily(byte[] c)
Checks to see if this table contains the given column family

Parameters:
c - Family name or column name.
Returns:
true if the table contains the specified family name

hasFamily

public boolean hasFamily(byte[] c,
                         int index)
Checks to see if this table contains the given column family

Parameters:
c - Family name or column name.
index - Index to column family delimiter
Returns:
true if the table contains the specified family name

toString

public String toString()
Overrides:
toString in class Object
Returns:
Name of this table and then a map of all of the column family descriptors.
See Also:
getNameAsString()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

readFields

public void readFields(DataInput in)
                throws IOException

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

compareTo

public int compareTo(Object o)

Specified by:
compareTo in interface Comparable

getFamilies

public Collection<HColumnDescriptor> getFamilies()
Returns:
Immutable sorted map of families.

getFamily

public HColumnDescriptor getFamily(byte[] column)
Parameters:
column -
Returns:
Column descriptor for the passed family name or the family on passed in column.

removeFamily

public HColumnDescriptor removeFamily(byte[] column)
Parameters:
column -
Returns:
Column descriptor for the passed family name or the family on passed in column.

getTableDir

public static org.apache.hadoop.fs.Path getTableDir(org.apache.hadoop.fs.Path rootdir,
                                                    byte[] tableName)
Parameters:
rootdir - qualified path of HBase root directory
tableName - name of table
Returns:
path for table


Copyright © 2008 The Apache Software Foundation