You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Chamika Kasun <ka...@gmail.com> on 2014/04/29 20:08:23 UTC

How to Create a Column in Hbase using Hbase Client API

Hi all,

Here what i want to do is i want to firstly need to create and a column
family and then need to create a column for data to be added later. Here i
can not use PUT command as it requires a value parameter(because idea of
that application is first initiate the table and data will be added later).
Please help me out. I'm really new to hbase

Re: How to Create a Column in Hbase using Hbase Client API

Posted by Chamika Kasun <ka...@gmail.com>.
thank you for the immediate reply. (Y)


On Wed, Apr 30, 2014 at 12:44 AM, Matteo Bertozzi
<th...@gmail.com>wrote:

> HBase does not have the concept of "static" columns.
> You just have "groups" the column families
> and then each row has a set of qualifiers.
>
> so, you don't need to specify the set of columns (qualifiers) on
> "initialization"
> you just add/update rows with the specified column
>
> so you end up doing something like this pseudo code
>
> createTable(tableName, group1, group2);
> table.put(row0, column0, value)
> table.put(row1, column0, value)
>
>
> Matteo
>
>
>
> On Tue, Apr 29, 2014 at 12:09 PM, Chamika Kasun <kasun.chamika@gmail.com
> >wrote:
>
> > Yes this code is correct. Here what the code does is only create a column
> > family. What i want to do is inside the column family i want to create
> > several columns. In this documentation
> > <
> >
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html
> > >for
> > the "Class HTableDescripter" it says that addFamily(hcd); creates a
> column
> > family NOT A Column.
> >
> > *addFamily
> > <
> >
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addFamily(org.apache.hadoop.hbase.HColumnDescriptor)
> > >*
> > (HColumnDescriptor<
> >
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HColumnDescriptor.html
> > >
> >  family)
> > Adds a column family.
> >
> > In my project what i want to do is create several columns inside that
> > column family. In Hbase Documentation it termed as "qualifier". That is i
> > want to create several qualifiers inside a column family which can be
> > created from the above code snippet.
> >
> >
> > On Tue, Apr 29, 2014 at 11:49 PM, Ted Yu <yu...@gmail.com> wrote:
> >
> > > When create your table, you specify the column families in the table
> > (code
> > > snippet from TestFromClientSide3.java):
> > >
> > >     HTableDescriptor htd =
> > > newHTableDescriptor(hTable.getTableDescriptor());
> > >
> > >     HColumnDescriptor hcd = new
> HColumnDescriptor(htd.getFamily(FAMILY));
> > >
> > >     htd.addFamily(hcd);
> > >
> > >     admin.createTable(htd);
> > >
> > > When you insert data, you specify column along with data value.
> > >
> > >
> > > Cheers
> > >
> > >
> > > On Tue, Apr 29, 2014 at 11:08 AM, Chamika Kasun <
> kasun.chamika@gmail.com
> > > >wrote:
> > >
> > > > Hi all,
> > > >
> > > > Here what i want to do is i want to firstly need to create and a
> column
> > > > family and then need to create a column for data to be added later.
> > Here
> > > i
> > > > can not use PUT command as it requires a value parameter(because idea
> > of
> > > > that application is first initiate the table and data will be added
> > > later).
> > > > Please help me out. I'm really new to hbase
> > > >
> > >
> >
> >
> >
> > --
> > Chamika Kasun.
> > Undergraduate.
> > Computer Science & Engineering
> > University of Moratuwa.
> >
>



-- 
Chamika Kasun.
Undergraduate.
Computer Science & Engineering
University of Moratuwa.

Re: How to Create a Column in Hbase using Hbase Client API

Posted by Matteo Bertozzi <th...@gmail.com>.
HBase does not have the concept of "static" columns.
You just have "groups" the column families
and then each row has a set of qualifiers.

so, you don't need to specify the set of columns (qualifiers) on
"initialization"
you just add/update rows with the specified column

so you end up doing something like this pseudo code

createTable(tableName, group1, group2);
table.put(row0, column0, value)
table.put(row1, column0, value)


Matteo



On Tue, Apr 29, 2014 at 12:09 PM, Chamika Kasun <ka...@gmail.com>wrote:

> Yes this code is correct. Here what the code does is only create a column
> family. What i want to do is inside the column family i want to create
> several columns. In this documentation
> <
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html
> >for
> the "Class HTableDescripter" it says that addFamily(hcd); creates a column
> family NOT A Column.
>
> *addFamily
> <
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addFamily(org.apache.hadoop.hbase.HColumnDescriptor)
> >*
> (HColumnDescriptor<
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HColumnDescriptor.html
> >
>  family)
> Adds a column family.
>
> In my project what i want to do is create several columns inside that
> column family. In Hbase Documentation it termed as "qualifier". That is i
> want to create several qualifiers inside a column family which can be
> created from the above code snippet.
>
>
> On Tue, Apr 29, 2014 at 11:49 PM, Ted Yu <yu...@gmail.com> wrote:
>
> > When create your table, you specify the column families in the table
> (code
> > snippet from TestFromClientSide3.java):
> >
> >     HTableDescriptor htd =
> > newHTableDescriptor(hTable.getTableDescriptor());
> >
> >     HColumnDescriptor hcd = new HColumnDescriptor(htd.getFamily(FAMILY));
> >
> >     htd.addFamily(hcd);
> >
> >     admin.createTable(htd);
> >
> > When you insert data, you specify column along with data value.
> >
> >
> > Cheers
> >
> >
> > On Tue, Apr 29, 2014 at 11:08 AM, Chamika Kasun <kasun.chamika@gmail.com
> > >wrote:
> >
> > > Hi all,
> > >
> > > Here what i want to do is i want to firstly need to create and a column
> > > family and then need to create a column for data to be added later.
> Here
> > i
> > > can not use PUT command as it requires a value parameter(because idea
> of
> > > that application is first initiate the table and data will be added
> > later).
> > > Please help me out. I'm really new to hbase
> > >
> >
>
>
>
> --
> Chamika Kasun.
> Undergraduate.
> Computer Science & Engineering
> University of Moratuwa.
>

Re: How to Create a Column in Hbase using Hbase Client API

Posted by Chamika Kasun <ka...@gmail.com>.
Yes this code is correct. Here what the code does is only create a column
family. What i want to do is inside the column family i want to create
several columns. In this documentation
<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html>for
the "Class HTableDescripter" it says that addFamily(hcd); creates a column
family NOT A Column.

*addFamily
<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addFamily(org.apache.hadoop.hbase.HColumnDescriptor)>*
(HColumnDescriptor<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HColumnDescriptor.html>
 family)
Adds a column family.

In my project what i want to do is create several columns inside that
column family. In Hbase Documentation it termed as "qualifier". That is i
want to create several qualifiers inside a column family which can be
created from the above code snippet.


On Tue, Apr 29, 2014 at 11:49 PM, Ted Yu <yu...@gmail.com> wrote:

> When create your table, you specify the column families in the table (code
> snippet from TestFromClientSide3.java):
>
>     HTableDescriptor htd =
> newHTableDescriptor(hTable.getTableDescriptor());
>
>     HColumnDescriptor hcd = new HColumnDescriptor(htd.getFamily(FAMILY));
>
>     htd.addFamily(hcd);
>
>     admin.createTable(htd);
>
> When you insert data, you specify column along with data value.
>
>
> Cheers
>
>
> On Tue, Apr 29, 2014 at 11:08 AM, Chamika Kasun <kasun.chamika@gmail.com
> >wrote:
>
> > Hi all,
> >
> > Here what i want to do is i want to firstly need to create and a column
> > family and then need to create a column for data to be added later. Here
> i
> > can not use PUT command as it requires a value parameter(because idea of
> > that application is first initiate the table and data will be added
> later).
> > Please help me out. I'm really new to hbase
> >
>



-- 
Chamika Kasun.
Undergraduate.
Computer Science & Engineering
University of Moratuwa.

Re: How to Create a Column in Hbase using Hbase Client API

Posted by Ted Yu <yu...@gmail.com>.
When create your table, you specify the column families in the table (code
snippet from TestFromClientSide3.java):

    HTableDescriptor htd = newHTableDescriptor(hTable.getTableDescriptor());

    HColumnDescriptor hcd = new HColumnDescriptor(htd.getFamily(FAMILY));

    htd.addFamily(hcd);

    admin.createTable(htd);

When you insert data, you specify column along with data value.


Cheers


On Tue, Apr 29, 2014 at 11:08 AM, Chamika Kasun <ka...@gmail.com>wrote:

> Hi all,
>
> Here what i want to do is i want to firstly need to create and a column
> family and then need to create a column for data to be added later. Here i
> can not use PUT command as it requires a value parameter(because idea of
> that application is first initiate the table and data will be added later).
> Please help me out. I'm really new to hbase
>