hbase 判断列族是否存在

 1 public static boolean isExistColumnFamily(String tableName,String cf) throws IOException {
 2         if(isExistTable(tableName)) {
 3             Table table = conn.getTable(TableName.valueOf(tableName));
 4             TableDescriptor tableDescriptor = table.getDescriptor();
 5             ColumnFamilyDescriptor descriptor = tableDescriptor.getColumnFamily(Bytes.toBytes(cf));
 6             return descriptor==null?false:true;
 7         }else {
 8             return false;
 9         }
10     }
11 
12 
13     public static boolean isExistTable(String tableName) throws IOException {
14         return admin.tableExists(TableName.valueOf(tableName));
15     }

 

posted @ 2018-11-23 16:43  tele  阅读(2450)  评论(0编辑  收藏  举报