org.apache.hadoop.hbase
Class TableName

java.lang.Object
  extended by org.apache.hadoop.hbase.TableName
All Implemented Interfaces:
Comparable<TableName>

@InterfaceAudience.Public
@InterfaceStability.Evolving
public final class TableName
extends Object
implements Comparable<TableName>

Immutable POJO class for representing a table name. Which is of the form: <table namespace>:<table qualifier> Two special namespaces: 1. hbase - system namespace, used to contain hbase internal tables 2. default - tables with no explicit specified namespace will automatically fall into this namespace. ie a) foo:bar, means namespace=foo and qualifier=bar b) bar, means namespace=default and qualifier=bar c) default:bar, means namespace=default and qualifier=bar

Internally, in this class, we cache the instances to limit the number of objects and make the "equals" faster. We try to minimize the number of objects created of the number of array copy to check if we already have an instance of this TableName. The code is not optimize for a new instance creation but is optimized to check for existence.


Field Summary
static TableName META_TABLE_NAME
          The hbase:meta table's name.
static char NAMESPACE_DELIM
          Namespace delimiter
static TableName NAMESPACE_TABLE_NAME
          The Namespace table's name.
static String OLD_META_STR
           
static TableName OLD_META_TABLE_NAME
          TableName for old .META.
static String OLD_ROOT_STR
           
static TableName OLD_ROOT_TABLE_NAME
          TableName for old -ROOT- table.
static String VALID_NAMESPACE_REGEX
           
static String VALID_TABLE_QUALIFIER_REGEX
           
static String VALID_USER_TABLE_REGEX
           
 
Method Summary
 int compareTo(TableName tableName)
          For performance reasons, the ordering is not lexicographic.
 boolean equals(Object o)
           
 byte[] getName()
           
 String getNameAsString()
           
 byte[] getNamespace()
           
 String getNamespaceAsString()
           
 byte[] getQualifier()
           
 String getQualifierAsString()
           
 KeyValue.KVComparator getRowComparator()
          Get the appropriate row comparator for this table.
 int hashCode()
           
static byte[] isLegalFullyQualifiedTableName(byte[] tableName)
          Check passed byte array, "tableName", is legal user-space table name.
static void isLegalNamespaceName(byte[] namespaceName)
           
static void isLegalNamespaceName(byte[] namespaceName, int start, int end)
          Valid namespace characters are [a-zA-Z_0-9]
static byte[] isLegalTableQualifierName(byte[] qualifierName)
           
static byte[] isLegalTableQualifierName(byte[] qualifierName, boolean isSnapshot)
           
static void isLegalTableQualifierName(byte[] qualifierName, int start, int end)
          Qualifier names can only contain 'word' characters [a-zA-Z_0-9] or '_', '.' or '-'.
static void isLegalTableQualifierName(byte[] qualifierName, int start, int end, boolean isSnapshot)
           
 boolean isSystemTable()
           
 byte[] toBytes()
           
 String toString()
           
static TableName valueOf(byte[] fullName)
           
static TableName valueOf(byte[] namespace, byte[] qualifier)
           
static TableName valueOf(ByteBuffer namespace, ByteBuffer qualifier)
           
static TableName valueOf(String name)
           
static TableName valueOf(String namespaceAsString, String qualifierAsString)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NAMESPACE_DELIM

public static final char NAMESPACE_DELIM
Namespace delimiter

See Also:
Constant Field Values

VALID_NAMESPACE_REGEX

public static final String VALID_NAMESPACE_REGEX
See Also:
Constant Field Values

VALID_TABLE_QUALIFIER_REGEX

public static final String VALID_TABLE_QUALIFIER_REGEX
See Also:
Constant Field Values

VALID_USER_TABLE_REGEX

public static final String VALID_USER_TABLE_REGEX
See Also:
Constant Field Values

META_TABLE_NAME

public static final TableName META_TABLE_NAME
The hbase:meta table's name.


NAMESPACE_TABLE_NAME

public static final TableName NAMESPACE_TABLE_NAME
The Namespace table's name.


OLD_META_STR

public static final String OLD_META_STR
See Also:
Constant Field Values

OLD_ROOT_STR

public static final String OLD_ROOT_STR
See Also:
Constant Field Values

OLD_ROOT_TABLE_NAME

public static final TableName OLD_ROOT_TABLE_NAME
TableName for old -ROOT- table. It is used to read/process old WALs which have ROOT edits.


OLD_META_TABLE_NAME

public static final TableName OLD_META_TABLE_NAME
TableName for old .META. table. Used in testing.

Method Detail

isLegalFullyQualifiedTableName

public static byte[] isLegalFullyQualifiedTableName(byte[] tableName)
Check passed byte array, "tableName", is legal user-space table name.

Returns:
Returns passed tableName param
Throws:
IllegalArgumentException - if passed a tableName is null or is made of other than 'word' characters or underscores: i.e. [a-zA-Z_0-9.-:]. The ':' is used to delimit the namespace from the table name and can be used for nothing else. Namespace names can only contain 'word' characters [a-zA-Z_0-9] or '_' Qualifier names can only contain 'word' characters [a-zA-Z_0-9] or '_', '.' or '-'. The name may not start with '.' or '-'. Valid fully qualified table names: foo:bar, namespace=>foo, table=>bar org:foo.bar, namespace=org, table=>foo.bar

isLegalTableQualifierName

public static byte[] isLegalTableQualifierName(byte[] qualifierName)

isLegalTableQualifierName

public static byte[] isLegalTableQualifierName(byte[] qualifierName,
                                               boolean isSnapshot)

isLegalTableQualifierName

public static void isLegalTableQualifierName(byte[] qualifierName,
                                             int start,
                                             int end)
Qualifier names can only contain 'word' characters [a-zA-Z_0-9] or '_', '.' or '-'. The name may not start with '.' or '-'.

Parameters:
qualifierName - byte array containing the qualifier name
start - start index
end - end index (exclusive)

isLegalTableQualifierName

public static void isLegalTableQualifierName(byte[] qualifierName,
                                             int start,
                                             int end,
                                             boolean isSnapshot)

isLegalNamespaceName

public static void isLegalNamespaceName(byte[] namespaceName)

isLegalNamespaceName

public static void isLegalNamespaceName(byte[] namespaceName,
                                        int start,
                                        int end)
Valid namespace characters are [a-zA-Z_0-9]


getName

public byte[] getName()

getNameAsString

public String getNameAsString()

getNamespace

public byte[] getNamespace()

getNamespaceAsString

public String getNamespaceAsString()

getQualifier

public byte[] getQualifier()

getQualifierAsString

public String getQualifierAsString()

toBytes

public byte[] toBytes()

isSystemTable

public boolean isSystemTable()

toString

public String toString()
Overrides:
toString in class Object

valueOf

public static TableName valueOf(String namespaceAsString,
                                String qualifierAsString)

valueOf

public static TableName valueOf(byte[] fullName)
                         throws IllegalArgumentException
Throws:
IllegalArgumentException - if fullName equals old root or old meta. Some code depends on this. The test is buried in the table creation to save on array comparison when we're creating a standard table object that will be in the cache.

valueOf

public static TableName valueOf(String name)
Throws:
IllegalArgumentException - if fullName equals old root or old meta. Some code depends on this.

valueOf

public static TableName valueOf(byte[] namespace,
                                byte[] qualifier)

valueOf

public static TableName valueOf(ByteBuffer namespace,
                                ByteBuffer qualifier)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(TableName tableName)
For performance reasons, the ordering is not lexicographic.

Specified by:
compareTo in interface Comparable<TableName>

getRowComparator

public KeyValue.KVComparator getRowComparator()
Get the appropriate row comparator for this table.

Returns:
The comparator.


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.