You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Aji Janis <aj...@gmail.com> on 2013/06/20 17:42:06 UTC

Issues adding column families

I have the following function for adding column family but its not working
for some reason. I am able to get proper configuration and establish the
right connection. Can anyone explain whats wrong?

Hbase version: http://archive.cloudera.com/cdh/3/*hbase-0.90.6-cdh3u5*
/apidocs/ <http://archive.cloudera.com/cdh/3/hbase-0.90.6-cdh3u5/apidocs/>
Thanks in advance.


public void addFamily(String tableName, ArrayList<String> families) throws
IOException{
admin = new HBaseAdmin(getConfiguration());
if (!admin.tableExists(tableName)){
if (families !=null){
admin.disableTable(tableName);
for (String fam: families) {
System.out.println("family to add: "+ fam);
admin.addColumn(tableName, new

    HColumnDescriptor(fam));
}
admin.enableTable(tableName);
}
admin.close();
}
}

Re: Issues adding column families

Posted by Aji Janis <aj...@gmail.com>.
Haa.. this is what happens when you stare at the code for too long. Thank
you!


On Thu, Jun 20, 2013 at 2:12 PM, Asaf Mesika <as...@gmail.com> wrote:

> if (!admin.tableExists(tableName)){
>
> Shouldn't it be:
> if (admin.tableExists(tableName)){
>
> ?
>
>
> On Thu, Jun 20, 2013 at 6:42 PM, Aji Janis <aj...@gmail.com> wrote:
>
> > I have the following function for adding column family but its not
> working
> > for some reason. I am able to get proper configuration and establish the
> > right connection. Can anyone explain whats wrong?
> >
> > Hbase version: http://archive.cloudera.com/cdh/3/*hbase-0.90.6-cdh3u5*
> > /apidocs/ <
> http://archive.cloudera.com/cdh/3/hbase-0.90.6-cdh3u5/apidocs/>
> > Thanks in advance.
> >
> >
> > public void addFamily(String tableName, ArrayList<String> families)
> throws
> > IOException{
> > admin = new HBaseAdmin(getConfiguration());
> > if (!admin.tableExists(tableName)){
> > if (families !=null){
> > admin.disableTable(tableName);
> > for (String fam: families) {
> > System.out.println("family to add: "+ fam);
> > admin.addColumn(tableName, new
> >
> >     HColumnDescriptor(fam));
> > }
> > admin.enableTable(tableName);
> > }
> > admin.close();
> > }
> > }
> >
>

Re: Issues adding column families

Posted by Asaf Mesika <as...@gmail.com>.
if (!admin.tableExists(tableName)){

Shouldn't it be:
if (admin.tableExists(tableName)){

?


On Thu, Jun 20, 2013 at 6:42 PM, Aji Janis <aj...@gmail.com> wrote:

> I have the following function for adding column family but its not working
> for some reason. I am able to get proper configuration and establish the
> right connection. Can anyone explain whats wrong?
>
> Hbase version: http://archive.cloudera.com/cdh/3/*hbase-0.90.6-cdh3u5*
> /apidocs/ <http://archive.cloudera.com/cdh/3/hbase-0.90.6-cdh3u5/apidocs/>
> Thanks in advance.
>
>
> public void addFamily(String tableName, ArrayList<String> families) throws
> IOException{
> admin = new HBaseAdmin(getConfiguration());
> if (!admin.tableExists(tableName)){
> if (families !=null){
> admin.disableTable(tableName);
> for (String fam: families) {
> System.out.println("family to add: "+ fam);
> admin.addColumn(tableName, new
>
>     HColumnDescriptor(fam));
> }
> admin.enableTable(tableName);
> }
> admin.close();
> }
> }
>