in java/dataproc-wordcount/src/main/java/com/example/bigtable/sample/CreateTable.java [57:85]
public static void createTable(TableName tableName, Configuration conf,
List<String> columnFamilies) throws IOException {
LOG.info("Creating Table " + tableName);
Connection connection = ConnectionFactory.createConnection(conf);
Admin admin = null;
try {
admin = connection.getAdmin();
if (tableExists(tableName, admin)) {
LOG.info("Table " + tableName + " already exists");
} else {
HTableDescriptor tableDescriptor = new HTableDescriptor(tableName);
for (String columnFamily : columnFamilies) {
tableDescriptor.addFamily(new HColumnDescriptor(columnFamily));
}
// NOTE: Anviltop createTable is synchronous while HBASE creation is not.
admin.createTable(tableDescriptor);
}
} catch (Exception e) {
LOG.error("Could not create table " + tableName, e);
} finally {
try {
admin.close();
} catch (Exception e) {
LOG.error("Could not close the admin", e);
}
connection.close();
}
}