org.apache.hadoop.hbase.client.Admin.addColumnFamily()方法的使用及代码示例

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

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

Admin.addColumnFamily介绍

[英]Add a column family to an existing table. Synchronous operation. Use #addColumnFamilyAsync(TableName,ColumnFamilyDescriptor) instead because it returns a Future from which you can learn whether success or failure.
[中]将列族添加到现有表中。同步操作。改用#addColumnFamilyAsync(TableName,ColumnFamilyDescriptor),因为它返回一个未来,您可以从中了解成功还是失败。

代码示例

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

/**
 * Add a column family to an existing table. Synchronous operation.
 * Use {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it
 * returns a {@link Future} from which you can learn whether success or failure.
 *
 * @param tableName name of the table to add column family to
 * @param columnFamily column family descriptor of column family to be added
 * @throws IOException if a remote or network exception occurs
 * @deprecated As of release 2.0.0.
 *             This will be removed in HBase 3.0.0.
 *             Use {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}.
 */
@Deprecated
default void addColumn(TableName tableName, ColumnFamilyDescriptor columnFamily)
 throws IOException {
 addColumnFamily(tableName, columnFamily);
}

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

@Override
public void addColumnFamily(TTableName tableName, TColumnFamilyDescriptor column)
  throws TIOError, TException {
 try {
  TableName table = tableNameFromThrift(tableName);
  ColumnFamilyDescriptor columnFamilyDescriptor = columnFamilyDescriptorFromThrift(column);
  connectionCache.getAdmin().addColumnFamily(table, columnFamilyDescriptor);
 } catch (IOException e) {
  throw getTIOError(e);
 }
}

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

admin.modifyColumnFamily(name, hcd);
} else {
 admin.addColumnFamily(name, hcd);

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

@Test
public void testAddSameColumnFamilyTwice() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 // Create a table with one families
 HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
 admin.createTable(baseHtd);
 admin.disableTable(TABLE_NAME);
 try {
  // Verify the table descriptor
  verifyTableDescriptor(TABLE_NAME, FAMILY_0);
  // Modify the table removing one family and verify the descriptor
  admin.addColumnFamily(TABLE_NAME, new HColumnDescriptor(FAMILY_1));
  verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
  try {
   // Add same column family again - expect failure
   admin.addColumnFamily(TABLE_NAME, new HColumnDescriptor(FAMILY_1));
   Assert.fail("Delete a non-exist column family should fail");
  } catch (InvalidFamilyOperationException e) {
   // Expected.
  }
 } finally {
  admin.deleteTable(TABLE_NAME);
 }
}

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

@Test
public void testAddColumn() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 // Create a table with two families
 HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
 admin.createTable(baseHtd);
 admin.disableTable(TABLE_NAME);
 try {
  // Verify the table descriptor
  verifyTableDescriptor(TABLE_NAME, FAMILY_0);
  // Modify the table removing one family and verify the descriptor
  admin.addColumnFamily(TABLE_NAME, new HColumnDescriptor(FAMILY_1));
  verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
 } finally {
  admin.deleteTable(TABLE_NAME);
 }
}

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

@Test
public void testEnableDisableAddColumnDeleteColumn() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
 while (!this.admin.isTableEnabled(TableName.valueOf(name.getMethodName()))) {
  Thread.sleep(10);
 }
 this.admin.disableTable(tableName);
 try {
  TEST_UTIL.getConnection().getTable(tableName);
 } catch (org.apache.hadoop.hbase.DoNotRetryIOException e) {
  //expected
 }
 this.admin.addColumnFamily(tableName, new HColumnDescriptor("col2"));
 this.admin.enableTable(tableName);
 try {
  this.admin.deleteColumnFamily(tableName, Bytes.toBytes("col2"));
 } catch (TableNotDisabledException e) {
  LOG.info(e.toString(), e);
 }
 this.admin.disableTable(tableName);
 this.admin.deleteTable(tableName);
}

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

admin.addColumnFamily(LABELS_TABLE_NAME, hcd);
 fail("Lables table should not get altered by user.");
} catch (Exception e) {

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

admin.addColumnFamily(tableName, cfd);

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

/**
 * Add a column family to an existing table. Synchronous operation.
 * Use {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it
 * returns a {@link Future} from which you can learn whether success or failure.
 *
 * @param tableName name of the table to add column family to
 * @param columnFamily column family descriptor of column family to be added
 * @throws IOException if a remote or network exception occurs
 * @deprecated As of release 2.0.0.
 *             This will be removed in HBase 3.0.0.
 *             Use {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}.
 */
@Deprecated
default void addColumn(TableName tableName, ColumnFamilyDescriptor columnFamily)
 throws IOException {
 addColumnFamily(tableName, columnFamily);
}

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

Exception exception = null;
try {
 this.admin.addColumnFamily(nonexistentTable, nonexistentHcd);
} catch (IOException e) {
 exception = e;

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

admin.addColumnFamily(originalTableName, hcd);
assertTrue("New column family was not added.",
 admin.getTableDescriptor(originalTableName).toString().contains(newFamilyNameAsString));

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

admin.addColumnFamily(snapshotTableName, columnFamilyDescriptor3);
admin.addColumnFamily(snapshotTableName, columnFamilyDescriptor4);
admin.deleteColumnFamily(snapshotTableName, CF2);

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

/**
 * Add metadata, and verify that this only affects one table
 */
private void runTestSnapshotMetadataChangesIndependent() throws Exception {
 // Add a new column family to the original table
 byte[] TEST_FAM_2 = Bytes.toBytes("fam2");
 HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAM_2);
 admin.disableTable(originalTableName);
 admin.addColumnFamily(originalTableName, hcd);
 // Verify that it is not in the snapshot
 admin.enableTable(originalTableName);
 UTIL.waitTableAvailable(originalTableName);
 // get a description of the cloned table
 // get a list of its families
 // assert that the family is there
 HTableDescriptor originalTableDescriptor = originalTable.getTableDescriptor();
 HTableDescriptor clonedTableDescriptor = admin.getTableDescriptor(cloneTableName);
 Assert.assertTrue("The original family was not found. There is something wrong. ",
  originalTableDescriptor.hasFamily(TEST_FAM));
 Assert.assertTrue("The original family was not found in the clone. There is something wrong. ",
  clonedTableDescriptor.hasFamily(TEST_FAM));
 Assert.assertTrue("The new family was not found. ",
  originalTableDescriptor.hasFamily(TEST_FAM_2));
 Assert.assertTrue("The new family was not found. ",
  !clonedTableDescriptor.hasFamily(TEST_FAM_2));
}

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

admin.addColumnFamily(tableName, columnDescBuilder.build());
} else {
 admin.modifyColumnFamily(tableName, columnDescBuilder.build());

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

expectedException = false;
try {
 this.admin.addColumnFamily(tableName, xtracol);
} catch (TableNotDisabledException re) {
 expectedException = true;

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

admin.addColumnFamily(tableName, getTestRestoreSchemaChangeHCD());
admin.enableTable(tableName);
assertEquals(2, table.getDescriptor().getColumnFamilyCount());

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

.newBuilder(FAMILYD);
familyDBuilder.setDataBlockEncoding(DataBlockEncoding.PREFIX);
admin.addColumnFamily(tableDescriptor.getTableName(), familyDBuilder.build());

代码示例来源:origin: org.apache.atlas/atlas-janusgraph-hbase2

@Override
public void addColumn(String tableString, ColumnFamilyDescriptor columnDescriptor) throws IOException
{
  adm.addColumnFamily(TableName.valueOf(tableString), columnDescriptor);
}

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

/**
 * Add a column family to an existing table. Synchronous operation.
 * Use {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it
 * returns a {@link Future} from which you can learn whether success or failure.
 *
 * @param tableName name of the table to add column family to
 * @param columnFamily column family descriptor of column family to be added
 * @throws IOException if a remote or network exception occurs
 * @deprecated As of release 2.0.0.
 *             This will be removed in HBase 3.0.0.
 *             Use {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}.
 */
@Deprecated
default void addColumn(TableName tableName, ColumnFamilyDescriptor columnFamily)
 throws IOException {
 addColumnFamily(tableName, columnFamily);
}

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

@Test
public void testAddColumn() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 // Create a table with two families
 HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
 admin.createTable(baseHtd);
 admin.disableTable(TABLE_NAME);
 try {
  // Verify the table descriptor
  verifyTableDescriptor(TABLE_NAME, FAMILY_0);
  // Modify the table removing one family and verify the descriptor
  admin.addColumnFamily(TABLE_NAME, new HColumnDescriptor(FAMILY_1));
  verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
 } finally {
  admin.deleteTable(TABLE_NAME);
 }
}

相关文章

Admin类方法