本文整理了Java中org.apache.hadoop.hbase.TableName.createTableNameIfNecessary()
方法的一些代码示例,展示了TableName.createTableNameIfNecessary()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableName.createTableNameIfNecessary()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.TableName
类名称:TableName
方法名: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.
[中]检查对象是否不存在。只创建一次对象有两个原因:1)对于100K区域,表名需要~20MB。2) 通过引用和整数比较解析Equals时,速度会快得多。
代码示例来源:origin: apache/hbase
public static TableName valueOf(ByteBuffer namespace, ByteBuffer qualifier) {
if (namespace == null || namespace.remaining() < 1) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME), qualifier);
}
return createTableNameIfNecessary(namespace, qualifier);
}
代码示例来源:origin: apache/hbase
public static TableName valueOf(byte[] namespace, byte[] qualifier) {
if (namespace == null || namespace.length < 1) {
namespace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME;
}
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getQualifier(), qualifier) &&
Arrays.equals(tn.getNamespace(), namespace)) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(namespace), ByteBuffer.wrap(qualifier));
}
代码示例来源:origin: apache/hbase
public static TableName valueOf(String namespaceAsString, String qualifierAsString) {
if (namespaceAsString == null || namespaceAsString.length() < 1) {
namespaceAsString = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
}
for (TableName tn : tableCache) {
if (qualifierAsString.equals(tn.getQualifierAsString()) &&
namespaceAsString.equals(tn.getNamespaceAsString())) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(Bytes.toBytes(namespaceAsString)),
ByteBuffer.wrap(Bytes.toBytes(qualifierAsString)));
}
代码示例来源:origin: apache/hbase
/**
* @throws IllegalArgumentException if fullName equals old root or old meta. Some code
* depends on this.
*/
public static TableName valueOf(String name) {
for (TableName tn : tableCache) {
if (name.equals(tn.getNameAsString())) {
return tn;
}
}
final int namespaceDelimIndex = name.indexOf(NAMESPACE_DELIM);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(Bytes.toBytes(name)));
} else {
// indexOf is by character, not byte (consider multi-byte characters)
String ns = name.substring(0, namespaceDelimIndex);
String qualifier = name.substring(namespaceDelimIndex + 1);
return createTableNameIfNecessary(
ByteBuffer.wrap(Bytes.toBytes(ns)),
ByteBuffer.wrap(Bytes.toBytes(qualifier)));
}
}
代码示例来源:origin: apache/hbase
/**
* @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.
*/
public static TableName valueOf(byte[] fullName) throws IllegalArgumentException{
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getName(), fullName)) {
return tn;
}
}
int namespaceDelimIndex =
org.apache.hbase.thirdparty.com.google.common.primitives.Bytes.lastIndexOf(fullName,
(byte) NAMESPACE_DELIM);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(fullName));
} else {
return createTableNameIfNecessary(
ByteBuffer.wrap(fullName, 0, namespaceDelimIndex),
ByteBuffer.wrap(fullName, namespaceDelimIndex + 1,
fullName.length - (namespaceDelimIndex + 1)));
}
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
public static TableName valueOf(ByteBuffer namespace, ByteBuffer qualifier) {
if (namespace == null || namespace.remaining() < 1) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME), qualifier);
}
return createTableNameIfNecessary(namespace, qualifier);
}
代码示例来源:origin: org.apache.hbase/hbase-common
public static TableName valueOf(ByteBuffer namespace, ByteBuffer qualifier) {
if (namespace == null || namespace.remaining() < 1) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME), qualifier);
}
return createTableNameIfNecessary(namespace, qualifier);
}
代码示例来源:origin: harbby/presto-connectors
public static TableName valueOf(ByteBuffer namespace, ByteBuffer qualifier) {
if (namespace == null || namespace.remaining() < 1) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME), qualifier);
}
return createTableNameIfNecessary(namespace, qualifier);
}
代码示例来源:origin: org.apache.hbase/hbase-common
public static TableName valueOf(String namespaceAsString, String qualifierAsString) {
if (namespaceAsString == null || namespaceAsString.length() < 1) {
namespaceAsString = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
}
for (TableName tn : tableCache) {
if (qualifierAsString.equals(tn.getQualifierAsString()) &&
namespaceAsString.equals(tn.getNamespaceAsString())) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(Bytes.toBytes(namespaceAsString)),
ByteBuffer.wrap(Bytes.toBytes(qualifierAsString)));
}
代码示例来源:origin: org.apache.hbase/hbase-common
public static TableName valueOf(byte[] namespace, byte[] qualifier) {
if (namespace == null || namespace.length < 1) {
namespace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME;
}
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getQualifier(), qualifier) &&
Arrays.equals(tn.getNamespace(), namespace)) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(namespace), ByteBuffer.wrap(qualifier));
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
public static TableName valueOf(String namespaceAsString, String qualifierAsString) {
if (namespaceAsString == null || namespaceAsString.length() < 1) {
namespaceAsString = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
}
for (TableName tn : tableCache) {
if (qualifierAsString.equals(tn.getQualifierAsString()) &&
namespaceAsString.equals(tn.getNamespaceAsString())) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(Bytes.toBytes(namespaceAsString)),
ByteBuffer.wrap(Bytes.toBytes(qualifierAsString)));
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
public static TableName valueOf(byte[] namespace, byte[] qualifier) {
if (namespace == null || namespace.length < 1) {
namespace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME;
}
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getQualifier(), qualifier) &&
Arrays.equals(tn.getNamespace(), namespace)) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(namespace), ByteBuffer.wrap(qualifier));
}
代码示例来源:origin: org.apache.hbase/hbase-common
/**
* @throws IllegalArgumentException if fullName equals old root or old meta. Some code
* depends on this.
*/
public static TableName valueOf(String name) {
for (TableName tn : tableCache) {
if (name.equals(tn.getNameAsString())) {
return tn;
}
}
final int namespaceDelimIndex = name.indexOf(NAMESPACE_DELIM);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(Bytes.toBytes(name)));
} else {
// indexOf is by character, not byte (consider multi-byte characters)
String ns = name.substring(0, namespaceDelimIndex);
String qualifier = name.substring(namespaceDelimIndex + 1);
return createTableNameIfNecessary(
ByteBuffer.wrap(Bytes.toBytes(ns)),
ByteBuffer.wrap(Bytes.toBytes(qualifier)));
}
}
代码示例来源:origin: harbby/presto-connectors
public static TableName valueOf(String namespaceAsString, String qualifierAsString) {
if (namespaceAsString == null || namespaceAsString.length() < 1) {
namespaceAsString = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
}
for (TableName tn : tableCache) {
if (qualifierAsString.equals(tn.getQualifierAsString()) &&
namespaceAsString.equals(tn.getNameAsString())) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(Bytes.toBytes(namespaceAsString)),
ByteBuffer.wrap(Bytes.toBytes(qualifierAsString)));
}
代码示例来源:origin: harbby/presto-connectors
/**
* @throws IllegalArgumentException if fullName equals old root or old meta. Some code
* depends on this.
*/
public static TableName valueOf(String name) {
for (TableName tn : tableCache) {
if (name.equals(tn.getNameAsString())) {
return tn;
}
}
int namespaceDelimIndex = name.indexOf(NAMESPACE_DELIM);
byte[] nameB = Bytes.toBytes(name);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(nameB));
} else {
return createTableNameIfNecessary(
ByteBuffer.wrap(nameB, 0, namespaceDelimIndex),
ByteBuffer.wrap(nameB, namespaceDelimIndex + 1,
nameB.length - (namespaceDelimIndex + 1)));
}
}
代码示例来源:origin: harbby/presto-connectors
public static TableName valueOf(byte[] namespace, byte[] qualifier) {
if (namespace == null || namespace.length < 1) {
namespace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME;
}
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getQualifier(), qualifier) &&
Arrays.equals(tn.getNamespace(), namespace)) {
return tn;
}
}
return createTableNameIfNecessary(
ByteBuffer.wrap(namespace), ByteBuffer.wrap(qualifier));
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
/**
* @throws IllegalArgumentException if fullName equals old root or old meta. Some code
* depends on this.
*/
public static TableName valueOf(String name) {
for (TableName tn : tableCache) {
if (name.equals(tn.getNameAsString())) {
return tn;
}
}
final int namespaceDelimIndex = name.indexOf(NAMESPACE_DELIM);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(Bytes.toBytes(name)));
} else {
// indexOf is by character, not byte (consider multi-byte characters)
String ns = name.substring(0, namespaceDelimIndex);
String qualifier = name.substring(namespaceDelimIndex + 1);
return createTableNameIfNecessary(
ByteBuffer.wrap(Bytes.toBytes(ns)),
ByteBuffer.wrap(Bytes.toBytes(qualifier)));
}
}
代码示例来源:origin: org.apache.hbase/hbase-common
/**
* @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.
*/
public static TableName valueOf(byte[] fullName) throws IllegalArgumentException{
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getName(), fullName)) {
return tn;
}
}
int namespaceDelimIndex =
org.apache.hbase.thirdparty.com.google.common.primitives.Bytes.lastIndexOf(fullName,
(byte) NAMESPACE_DELIM);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(fullName));
} else {
return createTableNameIfNecessary(
ByteBuffer.wrap(fullName, 0, namespaceDelimIndex),
ByteBuffer.wrap(fullName, namespaceDelimIndex + 1,
fullName.length - (namespaceDelimIndex + 1)));
}
}
代码示例来源:origin: harbby/presto-connectors
/**
* @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.
*/
public static TableName valueOf(byte[] fullName) throws IllegalArgumentException{
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getName(), fullName)) {
return tn;
}
}
int namespaceDelimIndex = com.facebook.presto.hbase.$internal.com.google.common.primitives.Bytes.lastIndexOf(fullName,
(byte) NAMESPACE_DELIM);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(fullName));
} else {
return createTableNameIfNecessary(
ByteBuffer.wrap(fullName, 0, namespaceDelimIndex),
ByteBuffer.wrap(fullName, namespaceDelimIndex + 1,
fullName.length - (namespaceDelimIndex + 1)));
}
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
/**
* @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.
*/
public static TableName valueOf(byte[] fullName) throws IllegalArgumentException{
for (TableName tn : tableCache) {
if (Arrays.equals(tn.getName(), fullName)) {
return tn;
}
}
int namespaceDelimIndex =
org.apache.hbase.thirdparty.com.google.common.primitives.Bytes.lastIndexOf(fullName,
(byte) NAMESPACE_DELIM);
if (namespaceDelimIndex < 0) {
return createTableNameIfNecessary(
ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
ByteBuffer.wrap(fullName));
} else {
return createTableNameIfNecessary(
ByteBuffer.wrap(fullName, 0, namespaceDelimIndex),
ByteBuffer.wrap(fullName, namespaceDelimIndex + 1,
fullName.length - (namespaceDelimIndex + 1)));
}
}
内容来源于网络,如有侵权,请联系作者删除!