private void modifyTable ( String tableName , HTableDescriptor newDescriptor ) { LOG . info ( "Modifying table " + tableName ) ; HColumnDescriptor [ ] newFamilies = newDescriptor . getColumnFamilies ( ) ; try { List < HColumnDescriptor > columnsToAdd = Lists . newArrayList ( ) ; HTableDescriptor currentFamilies = hbaseAdmin . getTableDescriptor ( Bytes . toBytes ( tableName ) ) ; for ( HColumnDescriptor newFamily : newFamilies ) { if ( ! currentFamilies . hasFamily ( newFamily . getName ( ) ) ) { columnsToAdd . add ( new HColumnDescriptor ( newFamily . getName ( ) ) ) ; } } // Add all the necessary column families if ( ! columnsToAdd . isEmpty ( ) ) { hbaseAdmin . disableTable ( tableName ) ; try { for ( HColumnDescriptor columnToAdd : columnsToAdd ) { hbaseAdmin . addColumn ( tableName , columnToAdd ) ; } } finally { hbaseAdmin . enableTable ( tableName ) ; } } } catch ( IOException e ) { throw new DatasetException ( e ) ; } }
add the column families which are not already present to the given table