org.apache.hadoop.hbase.TableName.getNamespace()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中org.apache.hadoop.hbase.TableName.getNamespace()方法的一些代码示例,展示了TableName.getNamespace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableName.getNamespace()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.TableName
类名称:TableName
方法名:getNamespace

TableName.getNamespace介绍

暂无

代码示例

代码示例来源: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

private TableName validateNames(TableName expected, Names names) {
 assertEquals(expected.getNameAsString(), names.nn);
 assertArrayEquals(expected.getName(), names.nnb);
 assertEquals(expected.getQualifierAsString(), names.tn);
 assertArrayEquals(expected.getQualifier(), names.tnb);
 assertEquals(expected.getNamespaceAsString(), names.ns);
 assertArrayEquals(expected.getNamespace(), names.nsb);
 return expected;
}

代码示例来源:origin: apache/hbase

Collections.sort(rsGroupServers);
rsGroupTables.sort((o1, o2) -> {
 int compare = Bytes.compareTo(o1.getNamespace(), o2.getNamespace());
 if (compare != 0)
   return compare;

代码示例来源:origin: apache/hbase

/**
 * 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.
 */
private static TableName createTableNameIfNecessary(ByteBuffer bns, ByteBuffer qns) {
 for (TableName tn : tableCache) {
  if (Bytes.equals(tn.getQualifier(), qns) && Bytes.equals(tn.getNamespace(), bns)) {
   return tn;
  }
 }
 TableName newTable = new TableName(bns, qns);
 if (tableCache.add(newTable)) {  // Adds the specified element if it is not already present
  return newTable;
 }
 // Someone else added it. Let's find it.
 for (TableName tn : tableCache) {
  if (Bytes.equals(tn.getQualifier(), qns) && Bytes.equals(tn.getNamespace(), bns)) {
   return tn;
  }
 }
 // this should never happen.
 throw new IllegalStateException(newTable + " was supposed to be in the cache");
}

代码示例来源:origin: org.apache.hbase/hbase-common

private TableName validateNames(TableName expected, Names names) {
 assertEquals(expected.getNameAsString(), names.nn);
 assertArrayEquals(expected.getName(), names.nnb);
 assertEquals(expected.getQualifierAsString(), names.tn);
 assertArrayEquals(expected.getQualifier(), names.tnb);
 assertEquals(expected.getNamespaceAsString(), names.ns);
 assertArrayEquals(expected.getNamespace(), names.nsb);
 return expected;
}

代码示例来源:origin: apache/hbase

@Override
public WAL getWAL(RegionInfo region) throws IOException {
 String group;
 if (META_WAL_PROVIDER_ID.equals(this.providerId)) {
  group = META_WAL_GROUP_NAME;
 } else {
  byte[] id;
  byte[] namespace;
  if (region != null) {
   id = region.getEncodedNameAsBytes();
   namespace = region.getTable().getNamespace();
  } else {
   id = HConstants.EMPTY_BYTE_ARRAY;
   namespace = null;
  }
  group = strategy.group(id, namespace);
 }
 return getWAL(group);
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

private TableName validateNames(TableName expected, Names names) {
 assertEquals(expected.getNameAsString(), names.nn);
 assertArrayEquals(expected.getName(), names.nnb);
 assertEquals(expected.getQualifierAsString(), names.tn);
 assertArrayEquals(expected.getQualifier(), names.tnb);
 assertEquals(expected.getNamespaceAsString(), names.ns);
 assertArrayEquals(expected.getNamespace(), names.nsb);
 return expected;
}

代码示例来源:origin: apache/hbase

public static TTableName tableNameFromHBase(TableName table) {
 TTableName tableName = new TTableName();
 tableName.setNs(table.getNamespace());
 tableName.setQualifier(table.getQualifier());
 return tableName;
}

代码示例来源:origin: apache/hbase

public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
 return HBaseProtos.TableName.newBuilder()
   .setNamespace(ByteString.copyFrom(tableName.getNamespace()))
   .setQualifier(ByteString.copyFrom(tableName.getQualifier())).build();
}

代码示例来源:origin: apache/hbase

public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
 return HBaseProtos.TableName.newBuilder()
   .setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace()))
   .setQualifier(UnsafeByteOperations.unsafeWrap(tableName.getQualifier())).build();
}

代码示例来源:origin: apache/hbase

public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
 return HBaseProtos.TableName.newBuilder()
   .setNamespace(ByteStringer.wrap(tableName.getNamespace()))
   .setQualifier(ByteStringer.wrap(tableName.getQualifier())).build();
}

代码示例来源:origin: apache/hbase

@Test
public void testConvert() {
 final TableName tableName = TableName.valueOf("ns1:" + name.getMethodName());
 byte[] startKey = Bytes.toBytes("startKey");
 byte[] endKey = Bytes.toBytes("endKey");
 boolean split = false;
 long regionId = System.currentTimeMillis();
 int replicaId = 42;
 HRegionInfo hri = new HRegionInfo(tableName, startKey, endKey, split,
  regionId, replicaId);
 // convert two times, compare
 HRegionInfo convertedHri = HRegionInfo.convert(HRegionInfo.convert(hri));
 assertEquals(hri, convertedHri);
 // test convert RegionInfo without replicaId
 RegionInfo info = RegionInfo.newBuilder()
  .setTableName(HBaseProtos.TableName.newBuilder()
   .setQualifier(UnsafeByteOperations.unsafeWrap(tableName.getQualifier()))
   .setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace()))
   .build())
  .setStartKey(UnsafeByteOperations.unsafeWrap(startKey))
  .setEndKey(UnsafeByteOperations.unsafeWrap(endKey))
  .setSplit(split)
  .setRegionId(regionId)
  .build();
 convertedHri = HRegionInfo.convert(info);
 HRegionInfo expectedHri = new HRegionInfo(tableName, startKey, endKey, split,
  regionId, 0); // expecting default replicaId
 assertEquals(expectedHri, convertedHri);
}
@Test

代码示例来源:origin: apache/hbase

.setTableName(HBaseProtos.TableName.newBuilder()
 .setQualifier(UnsafeByteOperations.unsafeWrap(tableName.getQualifier()))
 .setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace()))
 .build())
.setStartKey(UnsafeByteOperations.unsafeWrap(startKey))

代码示例来源:origin: org.apache.hbase/hbase-client

public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
 return HBaseProtos.TableName.newBuilder()
   .setNamespace(UnsafeByteOperations.unsafeWrap(tableName.getNamespace()))
   .setQualifier(UnsafeByteOperations.unsafeWrap(tableName.getQualifier())).build();
}

代码示例来源:origin: org.apache.hbase/hbase-client

public static TableProtos.TableName toProtoTableName(TableName tableName) {
 return TableProtos.TableName.newBuilder()
   .setNamespace(ByteStringer.wrap(tableName.getNamespace()))
   .setQualifier(ByteStringer.wrap(tableName.getQualifier())).build();
}

代码示例来源:origin: org.apache.hbase/hbase-client

public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
 return HBaseProtos.TableName.newBuilder()
   .setNamespace(ByteString.copyFrom(tableName.getNamespace()))
   .setQualifier(ByteString.copyFrom(tableName.getQualifier())).build();
}

代码示例来源:origin: apache/phoenix

private void getUserPermsFromUserDefinedAccessController(final List<UserPermission> userPermissions, Connection connection, AccessControlService.Interface service) {
  RpcController controller = (RpcController) ((ClusterConnection)connection)
      .getRpcControllerFactory().newController();
  AccessControlProtos.GetUserPermissionsRequest.Builder builderTablePerms = AccessControlProtos.GetUserPermissionsRequest
      .newBuilder();
  builderTablePerms.setTableName(ProtobufUtil.toProtoTableName(tableName));
  builderTablePerms.setType(AccessControlProtos.Permission.Type.Table);
  AccessControlProtos.GetUserPermissionsRequest requestTablePerms = builderTablePerms.build();
  callGetUserPermissionsRequest(userPermissions, service, requestTablePerms, controller);
  AccessControlProtos.GetUserPermissionsRequest.Builder builderNamespacePerms = AccessControlProtos.GetUserPermissionsRequest
      .newBuilder();
  builderNamespacePerms.setNamespaceName(ByteString.copyFrom(tableName.getNamespace()));
  builderNamespacePerms.setType(AccessControlProtos.Permission.Type.Namespace);
  AccessControlProtos.GetUserPermissionsRequest requestNamespacePerms = builderNamespacePerms.build();
  callGetUserPermissionsRequest(userPermissions, service, requestNamespacePerms, controller);
}

代码示例来源: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-client

public static TableProtos.TableName toProtoTableName(TableName tableName) {
 return TableProtos.TableName.newBuilder()
   .setNamespace(ByteStringer.wrap(tableName.getNamespace()))
   .setQualifier(ByteStringer.wrap(tableName.getQualifier())).build();
}

代码示例来源:origin: com.aliyun.hbase/alihbase-client

public static HBaseProtos.TableName toProtoTableName(TableName tableName) {
 return HBaseProtos.TableName.newBuilder()
   .setNamespace(ByteString.copyFrom(tableName.getNamespace()))
   .setQualifier(ByteString.copyFrom(tableName.getQualifier())).build();
}

相关文章