Package org.apache.hadoop.hbase
Class TableName
java.lang.Object
org.apache.hadoop.hbase.TableName
- All Implemented Interfaces:
- 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 SummaryFieldsModifier and TypeFieldDescriptionstatic final StringOne globally disallowed nameprivate final intstatic final TableNameThe hbase:meta table's name.private final byte[]private final Stringprivate final byte[]static final charNamespace delimiterstatic final TableNameThe Namespace table's name.private final Stringstatic final Stringstatic final TableNameTableName for old .META.static final Stringstatic final TableNameTableName for old -ROOT- table.private final byte[]private final Stringprivate final booleanstatic final Stringstatic final Stringstatic final String
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprivateThis is only for the old and meta tables.privateTableName(ByteBuffer namespace, ByteBuffer qualifier) 
- 
Method SummaryModifier and TypeMethodDescriptionintprivate static TableNamecreateTableNameIfNecessary(ByteBuffer bns, ByteBuffer qns) Check that the object does not exist already.booleanprivate static TableNamegetADummyTableName(String qualifier) It is used to create table names for old META, and ROOT table.byte[]getName()byte[]Ideally, getNameAsString should contain namespace within it, but if the namespace is default, it just returns the name.byte[]inthashCode()static byte[]isLegalFullyQualifiedTableName(byte[] tableName) Check passed byte array, "tableName", is legal user-space table name.static voidisLegalNamespaceName(byte[] namespaceName) static voidisLegalNamespaceName(byte[] namespaceName, int start, int end) Valid namespace characters are alphabetic characters, numbers, and underscores.static byte[]isLegalTableQualifierName(byte[] qualifierName) static byte[]isLegalTableQualifierName(byte[] qualifierName, boolean isSnapshot) static voidisLegalTableQualifierName(byte[] qualifierName, int start, int end) Qualifier names can only contain 'word' characters[\p{IsAlphabetic}\p{Digit}]or '_', '.' or '-'.static voidisLegalTableQualifierName(byte[] qualifierName, int start, int end, boolean isSnapshot) static booleanReturns True iftnis the hbase:meta table name.booleanbyte[]toBytes()Returns A pointer to TableName as String bytes.toString()static TableNamevalueOf(byte[] fullName) Construct a TableNamestatic TableNamevalueOf(byte[] namespace, byte[] qualifier) static TableNamevalueOf(byte[] fullName, int offset, int length) Construct a TableNamestatic TableNameConstruct a TableNamestatic TableNamestatic TableNamevalueOf(ByteBuffer fullname) Construct a TableNamestatic TableNamevalueOf(ByteBuffer namespace, ByteBuffer qualifier) 
- 
Field Details- 
tableCache
- 
NAMESPACE_DELIMNamespace delimiter- See Also:
 
- 
VALID_NAMESPACE_REGEX- See Also:
 
- 
VALID_TABLE_QUALIFIER_REGEX- See Also:
 
- 
VALID_USER_TABLE_REGEX- See Also:
 
- 
META_TABLE_NAMEThe hbase:meta table's name.
- 
NAMESPACE_TABLE_NAMEThe Namespace table's name.
- 
OLD_META_STR- See Also:
 
- 
OLD_ROOT_STR- See Also:
 
- 
DISALLOWED_TABLE_NAMEOne globally disallowed name- See Also:
 
- 
OLD_ROOT_TABLE_NAMETableName for old -ROOT- table. It is used to read/process old WALs which have ROOT edits.
- 
OLD_META_TABLE_NAMETableName for old .META. table. Used in testing.
- 
name
- 
nameAsString
- 
namespace
- 
namespaceAsString
- 
qualifier
- 
qualifierAsString
- 
systemTable
- 
hashCode
 
- 
- 
Constructor Details- 
TableName- Throws:
- IllegalArgumentException
 
- 
TableNameThis is only for the old and meta tables.
 
- 
- 
Method Details- 
isMetaTableNameReturns True iftnis the hbase:meta table name.
- 
isLegalFullyQualifiedTableNameCheck passed byte array, "tableName", is legal user-space table name.- Returns:
- Returns passed tableNameparam
- Throws:
- IllegalArgumentException- if passed a tableName is null or is made of other than 'word' characters or underscores: i.e.- [\p{IsAlphabetic}\p{Digit}.-:]. 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- [\p{IsAlphabetic}\p{Digit}]or '_' Qualifier names can only contain 'word' characters- [\p{IsAlphabetic}\p{Digit}]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
- 
isLegalTableQualifierName
- 
isLegalTableQualifierNameQualifier names can only contain 'word' characters[\p{IsAlphabetic}\p{Digit}]or '_', '.' or '-'. The name may not start with '.' or '-'.- Parameters:
- qualifierName- byte array containing the qualifier name
- start- start index
- end- end index (exclusive)
 
- 
isLegalTableQualifierNamepublic static void isLegalTableQualifierName(byte[] qualifierName, int start, int end, boolean isSnapshot) 
- 
isLegalNamespaceName
- 
isLegalNamespaceNameValid namespace characters are alphabetic characters, numbers, and underscores.
- 
getName
- 
getNameAsString
- 
getNamespace
- 
getNamespaceAsString
- 
getNameWithNamespaceInclAsStringIdeally, getNameAsString should contain namespace within it, but if the namespace is default, it just returns the name. This method takes care of this corner case.
- 
getQualifier
- 
getQualifierAsString
- 
toBytesReturns A pointer to TableName as String bytes.
- 
isSystemTable
- 
toString
- 
createTableNameIfNecessaryCheck that the object does not exist already. There are two reasons for creating the objects only once: 1) With 100K regions, the table names take ~20MB. 2) Equals becomes much faster as it's resolved with a reference and an int comparison.
- 
getADummyTableNameIt is used to create table names for old META, and ROOT table. These tables are not really legal tables. They are not added into the cache.- Returns:
- a dummy TableName instance (with no validation) for the passed qualifier
 
- 
valueOf
- 
valueOfConstruct a TableName- Parameters:
- fullName- will use the entire byte array
- 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.
 
- 
valueOfpublic static TableName valueOf(byte[] fullName, int offset, int length) throws IllegalArgumentException Construct a TableName- Parameters:
- fullName- byte array to look into
- offset- within said array
- length- within said array
- Throws:
- IllegalArgumentException- if fullName equals old root or old meta.
 
- 
valueOfConstruct a TableName- Parameters:
- fullname- of a table, possibly with a leading namespace and ':' as delimiter.
- Throws:
- IllegalArgumentException- if fullName equals old root or old meta.
 
- 
valueOfConstruct a TableName- Throws:
- IllegalArgumentException- if fullName equals old root or old meta. Some code depends on this.
 
- 
valueOf
- 
valueOf
- 
equals
- 
hashCode
- 
compareTo- Specified by:
- compareToin interface- Comparable<TableName>
 
 
-