org.apache.hadoop.hbase
Class HTableDescriptor

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

public class HTableDescriptor
extends Object
implements org.apache.hadoop.io.WritableComparable<HTableDescriptor>, ISerializable

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


Field Summary
static int DEFAULT_MAX_FILESIZE
           
static int DEFAULT_MEMSTORE_FLUSH_SIZE
           
static boolean DEFAULT_READONLY
           
 Map<byte[],HColumnDescriptor> families
           
static String FAMILIES
           
static ImmutableBytesWritable FAMILIES_KEY
           
static String IS_META
           
static ImmutableBytesWritable IS_META_KEY
           
static String IS_ROOT
           
static ImmutableBytesWritable IS_ROOT_KEY
           
static String MAX_FILESIZE
           
static ImmutableBytesWritable MAX_FILESIZE_KEY
           
static String MEMSTORE_FLUSHSIZE
           
static ImmutableBytesWritable MEMSTORE_FLUSHSIZE_KEY
           
static HTableDescriptor META_TABLEDESC
          Table descriptor for .META. catalog table
static String READONLY
           
static ImmutableBytesWritable READONLY_KEY
           
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.
protected HTableDescriptor(byte[] name, HColumnDescriptor[] families, Map<ImmutableBytesWritable,ImmutableBytesWritable> values)
          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(HTableDescriptor other)
           
 boolean equals(Object obj)
           
 HColumnDescriptor[] getColumnFamilies()
           
 Collection<HColumnDescriptor> getFamilies()
           
 Set<byte[]> getFamiliesKeys()
           
 HColumnDescriptor getFamily(byte[] column)
           
 long getMaxFileSize()
           
 int getMemStoreFlushSize()
           
 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)
           
 Map<ImmutableBytesWritable,ImmutableBytesWritable> getValues()
           
 boolean hasFamily(byte[] c)
          Checks to see if this table contains the given column family
 int hashCode()
           
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)
           
 void remove(byte[] key)
           
 HColumnDescriptor removeFamily(byte[] column)
           
 void restSerialize(IRestSerializer serializer)
          visitor pattern method where the object implementing this interface will call back on the IRestSerializer with the correct method to run to serialize the output of the object to the stream.
 void setMaxFileSize(long maxFileSize)
           
 void setMemStoreFlushSize(int memstoreFlushSize)
           
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

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

FAMILIES_KEY

public static final ImmutableBytesWritable FAMILIES_KEY

MAX_FILESIZE

public static final String MAX_FILESIZE
See Also:
Constant Field Values

MAX_FILESIZE_KEY

public static final ImmutableBytesWritable MAX_FILESIZE_KEY

READONLY

public static final String READONLY
See Also:
Constant Field Values

READONLY_KEY

public static final ImmutableBytesWritable READONLY_KEY

MEMSTORE_FLUSHSIZE

public static final String MEMSTORE_FLUSHSIZE
See Also:
Constant Field Values

MEMSTORE_FLUSHSIZE_KEY

public static final ImmutableBytesWritable MEMSTORE_FLUSHSIZE_KEY

IS_ROOT

public static final String IS_ROOT
See Also:
Constant Field Values

IS_ROOT_KEY

public static final ImmutableBytesWritable IS_ROOT_KEY

IS_META

public static final String IS_META
See Also:
Constant Field Values

IS_META_KEY

public static final ImmutableBytesWritable IS_META_KEY

DEFAULT_READONLY

public static final boolean DEFAULT_READONLY
See Also:
Constant Field Values

DEFAULT_MEMSTORE_FLUSH_SIZE

public static final int DEFAULT_MEMSTORE_FLUSH_SIZE
See Also:
Constant Field Values

DEFAULT_MAX_FILESIZE

public static final int DEFAULT_MAX_FILESIZE
See Also:
Constant Field Values

families

public final Map<byte[],HColumnDescriptor> families

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

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

protected HTableDescriptor(byte[] name,
                           HColumnDescriptor[] families,
                           Map<ImmutableBytesWritable,ImmutableBytesWritable> values)
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.

getValues

public Map<ImmutableBytesWritable,ImmutableBytesWritable> getValues()
Returns:
All values.

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.

remove

public void remove(byte[] key)
Parameters:
key - Key whose key and value we're to remove from HTD parameters.

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.

getMemStoreFlushSize

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

setMemStoreFlushSize

public void setMemStoreFlushSize(int memstoreFlushSize)
Parameters:
memstoreFlushSize - 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

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
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

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(HTableDescriptor other)
Specified by:
compareTo in interface Comparable<HTableDescriptor>

getFamilies

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

getFamiliesKeys

public Set<byte[]> getFamiliesKeys()
Returns:
Immutable sorted set of the keys of the families.

getColumnFamilies

public HColumnDescriptor[] getColumnFamilies()

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

restSerialize

public void restSerialize(IRestSerializer serializer)
                   throws HBaseRestException
Description copied from interface: ISerializable
visitor pattern method where the object implementing this interface will call back on the IRestSerializer with the correct method to run to serialize the output of the object to the stream.

Specified by:
restSerialize in interface ISerializable
Throws:
HBaseRestException


Copyright © 2009 The Apache Software Foundation