You need to go through HBaseAdmin.

http://hbase.apache.org/book.html#schema.creation

Disable the table, add the CF, then re-enable the table.



-----Original Message-----
From: Eranda Sooriyabandara [mailto:0704...@gmail.com] 
Sent: Friday, June 17, 2011 2:11 PM
To: user@hbase.apache.org
Subject: Add a column family to a table

Hi,
I want to add a column family to a existing table. I used the following code 
but it shows that descriptor cannot be modified.

 try {
            HTableDescriptor descriptor = new 
HTable(table.getConfiguration(),table.getTableName()).getTableDescriptor();
            descriptor.addFamily(cf);

        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File 
| Settings | File Templates.
        }

then I used the code,

try {
            HTableDescriptor descriptor = new 
HTableDescriptor(table.getTableDescriptor());
            descriptor.addFamily(cf);
            table.flushCommits();
            System.out.println(descriptor.hasFamily(groupId.getBytes()));
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File 
| Settings | File Templates.
        }
But this code does not add a column family to the table.

I need your help to figure this out.
thanks

--
Eranda Sooriyabandara
Blog: http://www.emsooriyabandara.blogspot.com/
LInkedIn: http://lk.linkedin.com/in/erandasooriyabandara

Reply via email to