code snippet to create maprdb table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createTable(String tableName, List<String> cfList) | |
throws IOException { | |
final String table = tableName; | |
final List<String> cfs = cfList; | |
try { | |
ugi.doAs(new PrivilegedExceptionAction<Void>() { | |
@Override | |
public Void run() throws Exception { | |
if (!admin.tableExists(table)) { | |
TableName tableName = TableName.valueOf(table); | |
HTableDescriptor tableDescriptor = new HTableDescriptor(tableName); | |
for (String cf : cfs) { | |
tableDescriptor | |
.addFamily(new HColumnDescriptor(cf)); | |
} | |
admin.createTable(tableDescriptor); | |
log.info("Created table "+table); | |
} | |
return null; | |
} | |
}); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment