HBASE-6583 Enhance Hbase load test tool to automatically create column families if not present (Sergey Shelukhin)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1400196 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-10-19 17:58:27 +00:00
parent b6ca623286
commit 7e02b67d30
1 changed files with 9 additions and 1 deletions

View File

@ -155,6 +155,10 @@ public class LoadTestTool extends AbstractHBaseTool {
admin.disableTable(tableName);
for (byte[] cf : columnFamilies) {
HColumnDescriptor columnDesc = tableDesc.getFamily(cf);
boolean isNewCf = columnDesc == null;
if (isNewCf) {
columnDesc = new HColumnDescriptor(cf);
}
if (bloomType != null) {
columnDesc.setBloomFilterType(bloomType);
}
@ -165,7 +169,11 @@ public class LoadTestTool extends AbstractHBaseTool {
columnDesc.setDataBlockEncoding(dataBlockEncodingAlgo);
columnDesc.setEncodeOnDisk(!encodeInCacheOnly);
}
admin.modifyColumn(tableName, columnDesc);
if (isNewCf) {
admin.addColumn(tableName, columnDesc);
} else {
admin.modifyColumn(tableName, columnDesc);
}
}
LOG.info("Enabling table " + Bytes.toString(tableName));
admin.enableTable(tableName);