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 Summary
Modifier and TypeFieldDescriptionstatic final String
One globally disallowed nameprivate final int
static final TableName
The hbase:meta table's name.private final byte[]
private final String
private final byte[]
static final char
Namespace delimiterstatic final TableName
Deprecated.since 3.0.0 and will be removed in 4.0.0.private final String
static final String
static final TableName
TableName for old .META.static final String
static final TableName
TableName for old -ROOT- table.private final byte[]
private final String
private final boolean
static final String
static final String
static final String
-
Constructor Summary
ModifierConstructorDescriptionprivate
This is only for the old and meta tables.private
TableName
(ByteBuffer namespace, ByteBuffer qualifier) -
Method Summary
Modifier and TypeMethodDescriptionint
private static TableName
createTableNameIfNecessary
(ByteBuffer bns, ByteBuffer qns) Check that the object does not exist already.boolean
private static TableName
getADummyTableName
(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[]
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 alphabetic characters, numbers, and underscores.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[\p{IsAlphabetic}\p{Digit}]
or '_', '.' or '-'.static void
isLegalTableQualifierName
(byte[] qualifierName, int start, int end, boolean isSnapshot) static boolean
Returns True iftn
is the hbase:meta table name.boolean
byte[]
toBytes()
Returns A pointer to TableName as String bytes.toString()
static TableName
valueOf
(byte[] fullName) Construct a TableNamestatic TableName
valueOf
(byte[] namespace, byte[] qualifier) static TableName
valueOf
(byte[] fullName, int offset, int length) Construct a TableNamestatic TableName
Construct a TableNamestatic TableName
static TableName
valueOf
(ByteBuffer fullname) Construct a TableNamestatic TableName
valueOf
(ByteBuffer namespace, ByteBuffer qualifier)
-
Field Details
-
tableCache
-
NAMESPACE_DELIM
Namespace delimiter- See Also:
-
VALID_NAMESPACE_REGEX
- See Also:
-
VALID_TABLE_QUALIFIER_REGEX
- See Also:
-
VALID_USER_TABLE_REGEX
- See Also:
-
META_TABLE_NAME
The hbase:meta table's name. -
NAMESPACE_TABLE_NAME
Deprecated.since 3.0.0 and will be removed in 4.0.0. We have folded the data in namespace table into meta table, so do not use it any more.The Namespace table's name.- See Also:
-
OLD_META_STR
- See Also:
-
OLD_ROOT_STR
- See Also:
-
DISALLOWED_TABLE_NAME
One globally disallowed name- See Also:
-
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
TableName for old .META. table. Used in testing. -
name
-
nameAsString
-
namespace
-
namespaceAsString
-
qualifier
-
qualifierAsString
-
systemTable
-
hashCode
-
-
Constructor Details
-
TableName
- Throws:
IllegalArgumentException
-
TableName
This is only for the old and meta tables.
-
-
Method Details
-
isMetaTableName
Returns True iftn
is the hbase:meta table name. -
isLegalFullyQualifiedTableName
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.[\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
-
isLegalTableQualifierName
Qualifier 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 namestart
- start indexend
- end index (exclusive)
-
isLegalTableQualifierName
public static void isLegalTableQualifierName(byte[] qualifierName, int start, int end, boolean isSnapshot) -
isLegalNamespaceName
-
isLegalNamespaceName
Valid namespace characters are alphabetic characters, numbers, and underscores. -
getName
-
getNameAsString
-
getNamespace
-
getNamespaceAsString
-
getNameWithNamespaceInclAsString
Ideally, 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
-
toBytes
Returns A pointer to TableName as String bytes. -
isSystemTable
-
toString
-
createTableNameIfNecessary
Check 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. -
getADummyTableName
It 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
-
valueOf
Construct 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.
-
valueOf
public static TableName valueOf(byte[] fullName, int offset, int length) throws IllegalArgumentException Construct a TableName- Parameters:
fullName
- byte array to look intooffset
- within said arraylength
- within said array- Throws:
IllegalArgumentException
- if fullName equals old root or old meta.
-
valueOf
Construct 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.
-
valueOf
Construct a TableName- Throws:
IllegalArgumentException
- if fullName equals old root or old meta. Some code depends on this.
-
valueOf
-
valueOf
-
equals
-
hashCode
-
compareTo
- Specified by:
compareTo
in interfaceComparable<TableName>
-