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

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

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

TableName.isLegalTableQualifierName介绍

[英]Qualifier names can only contain 'word' characters [\p{IsAlphabetic}\p{Digit}] or '_', '.' or '-'. The name may not start with '.' or '-'.
[中]限定符名称只能包含“word”字符[\p{IsAlphabetic}\p{Digit}]或“',”或者“-”。名称不能以“.”开头或者“-”。

代码示例

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

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, false);
  3. return qualifierName;
  4. }

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

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName, boolean isSnapshot) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, isSnapshot);
  3. return qualifierName;
  4. }

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

  1. @Override
  2. protected boolean isValidName(final String name) {
  3. if (!super.isValidName(name))
  4. return false;
  5. try {
  6. TableName.isLegalTableQualifierName(Bytes.toBytes(name));
  7. } catch (IllegalArgumentException e) {
  8. LOG.info("INVALID NAME " + name);
  9. return false;
  10. }
  11. return true;
  12. }
  13. }

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

  1. (byte) NAMESPACE_DELIM);
  2. if (namespaceDelimIndex < 0){
  3. isLegalTableQualifierName(tableName);
  4. } else {
  5. isLegalNamespaceName(tableName, 0, namespaceDelimIndex);
  6. isLegalTableQualifierName(tableName, namespaceDelimIndex + 1, tableName.length);

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

  1. public static void isLegalTableQualifierName(final byte[] qualifierName,
  2. int start,
  3. int end,
  4. boolean isSnapshot) {
  5. if(end - start < 1) {
  6. throw new IllegalArgumentException(isSnapshot ? "Snapshot" : "Table" + " qualifier must not be empty");
  7. }
  8. if (qualifierName[start] == '.' || qualifierName[start] == '-') {
  9. throw new IllegalArgumentException("Illegal first character <" + qualifierName[start] +
  10. "> at 0. " + (isSnapshot ? "Snapshot" : "User-space table") +
  11. " qualifiers can only start with 'alphanumeric " +
  12. "characters' from any language: " +
  13. Bytes.toString(qualifierName, start, end));
  14. }
  15. // Treat the bytes as UTF-8
  16. String qualifierString = new String(
  17. qualifierName, start, (end - start), StandardCharsets.UTF_8);
  18. if (qualifierString.equals(DISALLOWED_TABLE_NAME)) {
  19. // Per https://zookeeper.apache.org/doc/r3.4.10/zookeeperProgrammers.html#ch_zkDataModel
  20. // A znode named "zookeeper" is disallowed by zookeeper.
  21. throw new IllegalArgumentException("Tables may not be named '" + DISALLOWED_TABLE_NAME + "'");
  22. }
  23. for (int i = 0; i < qualifierString.length(); i++) {
  24. // Treat the string as a char-array as some characters may be multi-byte
  25. char c = qualifierString.charAt(i);
  26. // Check for letter, digit, underscore, hyphen, or period, and allowed by ZK.
  27. // ZooKeeper also has limitations, but Character.isAlphabetic omits those all
  28. // See https://zookeeper.apache.org/doc/r3.4.10/zookeeperProgrammers.html#ch_zkDataModel
  29. if (Character.isAlphabetic(c) || Character.isDigit(c) || c == '_' || c == '-' || c == '.') {
  30. continue;

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

  1. isLegalTableQualifierName(this.qualifier);

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

  1. /**
  2. * Check to make sure that the description of the snapshot requested is valid
  3. * @param snapshot description of the snapshot
  4. * @throws IllegalArgumentException if the name of the snapshot or the name of the table to
  5. * snapshot are not valid names.
  6. */
  7. public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescription snapshot)
  8. throws IllegalArgumentException {
  9. // make sure the snapshot name is valid
  10. TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
  11. if(snapshot.hasTable()) {
  12. // make sure the table name is valid, this will implicitly check validity
  13. TableName tableName = TableName.valueOf(snapshot.getTable());
  14. if (tableName.isSystemTable()) {
  15. throw new IllegalArgumentException("System table snapshots are not allowed");
  16. }
  17. }
  18. }

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

  1. /**
  2. * Check to make sure that the description of the snapshot requested is valid
  3. * @param snapshot description of the snapshot
  4. * @throws IllegalArgumentException if the name of the snapshot or the name of the table to
  5. * snapshot are not valid names.
  6. */
  7. public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescription snapshot)
  8. throws IllegalArgumentException {
  9. // make sure the snapshot name is valid
  10. TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
  11. if(snapshot.hasTable()) {
  12. // make sure the table name is valid, this will implicitly check validity
  13. TableName tableName = TableName.valueOf(snapshot.getTable());
  14. if (tableName.isSystemTable()) {
  15. throw new IllegalArgumentException("System table snapshots are not allowed");
  16. }
  17. }
  18. }

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

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName, boolean isSnapshot) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, isSnapshot);
  3. return qualifierName;
  4. }

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

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, false);
  3. return qualifierName;
  4. }

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

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, false);
  3. return qualifierName;
  4. }

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

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName, boolean isSnapshot) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, isSnapshot);
  3. return qualifierName;
  4. }

代码示例来源:origin: harbby/presto-connectors

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, false);
  3. return qualifierName;
  4. }

代码示例来源:origin: harbby/presto-connectors

  1. public static byte [] isLegalTableQualifierName(final byte[] qualifierName, boolean isSnapshot) {
  2. isLegalTableQualifierName(qualifierName, 0, qualifierName.length, isSnapshot);
  3. return qualifierName;
  4. }

代码示例来源:origin: harbby/presto-connectors

  1. protected boolean isValidName(final String name) {
  2. if (!super.isValidName(name))
  3. return false;
  4. try {
  5. TableName.isLegalTableQualifierName(Bytes.toBytes(name));
  6. } catch (IllegalArgumentException e) {
  7. LOG.info("INVALID NAME " + name);
  8. return false;
  9. }
  10. return true;
  11. }
  12. }

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

  1. (byte) NAMESPACE_DELIM);
  2. if (namespaceDelimIndex < 0){
  3. isLegalTableQualifierName(tableName);
  4. } else {
  5. isLegalNamespaceName(tableName, 0, namespaceDelimIndex);
  6. isLegalTableQualifierName(tableName, namespaceDelimIndex + 1, tableName.length);

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

  1. public static void isLegalTableQualifierName(final byte[] qualifierName,
  2. int start,
  3. int end,
  4. boolean isSnapshot) {
  5. if(end - start < 1) {
  6. throw new IllegalArgumentException(isSnapshot ? "Snapshot" : "Table" + " qualifier must not be empty");
  7. }
  8. if (qualifierName[start] == '.' || qualifierName[start] == '-') {
  9. throw new IllegalArgumentException("Illegal first character <" + qualifierName[start] +
  10. "> at 0. " + (isSnapshot ? "Snapshot" : "User-space table") +
  11. " qualifiers can only start with 'alphanumeric " +
  12. "characters' from any language: " +
  13. Bytes.toString(qualifierName, start, end));
  14. }
  15. // Treat the bytes as UTF-8
  16. String qualifierString = new String(
  17. qualifierName, start, (end - start), StandardCharsets.UTF_8);
  18. if (qualifierString.equals(DISALLOWED_TABLE_NAME)) {
  19. // Per https://zookeeper.apache.org/doc/r3.4.10/zookeeperProgrammers.html#ch_zkDataModel
  20. // A znode named "zookeeper" is disallowed by zookeeper.
  21. throw new IllegalArgumentException("Tables may not be named '" + DISALLOWED_TABLE_NAME + "'");
  22. }
  23. for (int i = 0; i < qualifierString.length(); i++) {
  24. // Treat the string as a char-array as some characters may be multi-byte
  25. char c = qualifierString.charAt(i);
  26. // Check for letter, digit, underscore, hyphen, or period, and allowed by ZK.
  27. // ZooKeeper also has limitations, but Character.isAlphabetic omits those all
  28. // See https://zookeeper.apache.org/doc/r3.4.10/zookeeperProgrammers.html#ch_zkDataModel
  29. if (Character.isAlphabetic(c) || Character.isDigit(c) || c == '_' || c == '-' || c == '.') {
  30. continue;

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

  1. (byte) NAMESPACE_DELIM);
  2. if (namespaceDelimIndex < 0){
  3. isLegalTableQualifierName(tableName);
  4. } else {
  5. isLegalNamespaceName(tableName, 0, namespaceDelimIndex);
  6. isLegalTableQualifierName(tableName, namespaceDelimIndex + 1, tableName.length);

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

  1. /**
  2. * Check to make sure that the description of the snapshot requested is valid
  3. * @param snapshot description of the snapshot
  4. * @throws IllegalArgumentException if the name of the snapshot or the name of the table to
  5. * snapshot are not valid names.
  6. */
  7. public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescription snapshot)
  8. throws IllegalArgumentException {
  9. // make sure the snapshot name is valid
  10. TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
  11. if(snapshot.hasTable()) {
  12. // make sure the table name is valid, this will implicitly check validity
  13. TableName tableName = TableName.valueOf(snapshot.getTable());
  14. if (tableName.isSystemTable()) {
  15. throw new IllegalArgumentException("System table snapshots are not allowed");
  16. }
  17. }
  18. }

代码示例来源:origin: harbby/presto-connectors

  1. /**
  2. * Check to make sure that the description of the snapshot requested is valid
  3. * @param snapshot description of the snapshot
  4. * @throws IllegalArgumentException if the name of the snapshot or the name of the table to
  5. * snapshot are not valid names.
  6. */
  7. public static void assertSnapshotRequestIsValid(HBaseProtos.SnapshotDescription snapshot)
  8. throws IllegalArgumentException {
  9. // make sure the snapshot name is valid
  10. TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
  11. if(snapshot.hasTable()) {
  12. // make sure the table name is valid, this will implicitly check validity
  13. TableName tableName = TableName.valueOf(snapshot.getTable());
  14. if (tableName.isSystemTable()) {
  15. throw new IllegalArgumentException("System table snapshots are not allowed");
  16. }
  17. }
  18. }

相关文章