private void addColumnFamilyToTable(String tableName, String columnFamilyName) throws IOException
    {
        HColumnDescriptor cfDesciptor = new HColumnDescriptor(columnFamilyName);

        try
        {
            if (admin.tableExists(tableName))
            {

                // Before any modification to table schema, it's necessary to
                // disable it
                if (!admin.isTableEnabled(tableName))
                {
                    admin.enableTable(tableName);
                }
                HTableDescriptor descriptor = admin.getTableDescriptor(tableName.getBytes());
                boolean found = false;
                for (HColumnDescriptor hColumnDescriptor : descriptor.getColumnFamilies())
                {
                    if (hColumnDescriptor.getNameAsString().equalsIgnoreCase(columnFamilyName))
                        found = true;
                }
                if (!found)
                {

                    if (admin.isTableEnabled(tableName))
                    {
                        admin.disableTable(tableName);
                    }

                    admin.addColumn(tableName, cfDesciptor);

                    // Enable table once done
                    admin.enableTable(tableName);
                }
            }
            else
            {
                log.warn("Table {} doesn't exist, so no question of adding column family {} to it!", tableName,
                        columnFamilyName);
            }
        }
        catch (IOException e)
        {
            log.error("Error while adding column family {}, to table{} . ", columnFamilyName, tableName);
            throw e;
        }
    }
private void addColumnFamilyToTable ( String tableName , String columnFamilyName ) throws IOException { HColumnDescriptor cfDesciptor = new HColumnDescriptor ( columnFamilyName ) ; try { if ( admin . tableExists ( tableName ) ) { if ( ! admin . isTableEnabled ( tableName ) ) { admin . enableTable ( tableName ) ; } HTableDescriptor descriptor = admin . getTableDescriptor ( tableName . getBytes ( ) ) ; boolean found = false ; for ( HColumnDescriptor hColumnDescriptor : descriptor . getColumnFamilies ( ) ) { if ( hColumnDescriptor . getNameAsString ( ) . equalsIgnoreCase ( columnFamilyName ) ) found = true ; } if ( ! found ) { if ( admin . isTableEnabled ( tableName ) ) { admin . disableTable ( tableName ) ; } admin . addColumn ( tableName , cfDesciptor ) ; admin . enableTable ( tableName ) ; } } else { log . warn ( "Table {} doesn't exist, so no question of adding column family {} to it!" , tableName , columnFamilyName ) ; } } catch ( IOException e ) { log . error ( "Error while adding column family {}, to table{} . " , columnFamilyName , tableName ) ; throw e ; } }
Adds the column family to table.

@param tableName
the table name
@param columnFamilyName
the column family name
@throws IOException
Signals that an I/O exception has occurred.