Skip to content

Instantly share code, notes, and snippets.

@rajkrrsingh
Created August 9, 2015 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajkrrsingh/3f3960bc9247a91d48f6 to your computer and use it in GitHub Desktop.
Save rajkrrsingh/3f3960bc9247a91d48f6 to your computer and use it in GitHub Desktop.
code snippet to create maprdb table
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