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