I have a super simple piece of code which tries to create a test table if it 
does not exist

calling admin.tableExists(TableName.valueOf(table)) returns false causing the 
control to be passed to the line that creates it 
admin.createTable(tableDescriptor). Then i get an exception that the table 
exists!

Exception in thread "main" org.apache.hadoop.hbase.TableExistsException: 
LoadTest


String table = config.tableName;
...
Connection conn = ConnectionFactory.createConnection(hbaseconf);
Admin admin = conn.getAdmin();
if(!admin.tableExists(TableName.valueOf(table))) {
    Log.info("table " + table + " does not exist. Creating it...");
    HTableDescriptor tableDescriptor = new 
HTableDescriptor(TableName.valueOf(table));
    tableDescriptor.addFamily(new HColumnDescriptor(config.FAMILY));
    admin.createTable(tableDescriptor);
}

Jeff

Reply via email to