You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Mehdi Ben Haj Abbes <me...@gmail.com> on 2015/12/04 11:09:15 UTC

HTableDescriptor.hasFamily not working as expected

Hi folks,

I'm new to HBase client java API and using 0.98.4-hadoop2 version.

I need to check if a column family does exit even if it does not have any
rows in it.
The problem is that HTableDescriptor.hasFamily returns false for an empty
column family so if I try to create it I will have an exception stating
that the CF is already existing.

Any help will be more than appreciated.

Regard,


-- 
Mehdi BEN HAJ ABBES

Re: HTableDescriptor.hasFamily not working as expected

Posted by Mehdi Ben Haj Abbes <me...@gmail.com>.
Hi,

Every day I'm adding bunchs of data to a newly created CF (I keep the CFs
number limited : no more than 3).
For a new day, for the first data I'm adding, I create a new CF with
"yyMMdd" as the CF name. and I need to do this with the java client not the
shell client.

For altering the table, I did not find a way to do it with the java client
; son any help will be more than appreciated.

Regards,

On Fri, Dec 4, 2015 at 5:57 PM, Ted Yu <yu...@gmail.com> wrote:

> A column family is supposed to receive (some) writes.
> Maybe you can give us more context on why the check for column family is
> needed.
>
> Do you try to alter table (and adding column family) when a particular
> column
> family doesn't exist ?
>
> Cheers
>
> On Fri, Dec 4, 2015 at 7:51 AM, Mehdi Ben Haj Abbes <mehdi.abbes@gmail.com
> >
> wrote:
>
> > Thanks Ted for your answer.
> >
> > This what I'm doing : catching the exception, but before I'm setting
> > hbase.client.retries.number to 3 rather than the default value of 35
> > otherwise my job will hang for few minutes.
> >
> > Is there no other way to make the check.
> >
> > Best regards,
> >
> > On Fri, Dec 4, 2015 at 4:35 PM, Ted Yu <yu...@gmail.com> wrote:
> >
> > > hasFamily() just checks the in-memory Map:
> > >
> > >   public boolean hasFamily(final byte [] familyName) {
> > >
> > >     return families.containsKey(familyName);
> > >
> > > bq. try to create it I will have an exception stating that the CF is
> > > already existing.
> > >
> > > In this case you can catch the exception and proceed, right ?
> > >
> > > Cheers
> > >
> > > On Fri, Dec 4, 2015 at 2:09 AM, Mehdi Ben Haj Abbes <
> > mehdi.abbes@gmail.com
> > > >
> > > wrote:
> > >
> > > > Hi folks,
> > > >
> > > > I'm new to HBase client java API and using 0.98.4-hadoop2 version.
> > > >
> > > > I need to check if a column family does exit even if it does not have
> > any
> > > > rows in it.
> > > > The problem is that HTableDescriptor.hasFamily returns false for an
> > empty
> > > > column family so if I try to create it I will have an exception
> stating
> > > > that the CF is already existing.
> > > >
> > > > Any help will be more than appreciated.
> > > >
> > > > Regard,
> > > >
> > > >
> > > > --
> > > > Mehdi BEN HAJ ABBES
> > > >
> > >
> >
> >
> >
> > --
> > Mehdi BEN HAJ ABBES
> >
>



-- 
Mehdi BEN HAJ ABBES

Re: HTableDescriptor.hasFamily not working as expected

Posted by Ted Yu <yu...@gmail.com>.
A column family is supposed to receive (some) writes.
Maybe you can give us more context on why the check for column family is
needed.

Do you try to alter table (and adding column family) when a particular column
family doesn't exist ?

Cheers

On Fri, Dec 4, 2015 at 7:51 AM, Mehdi Ben Haj Abbes <me...@gmail.com>
wrote:

> Thanks Ted for your answer.
>
> This what I'm doing : catching the exception, but before I'm setting
> hbase.client.retries.number to 3 rather than the default value of 35
> otherwise my job will hang for few minutes.
>
> Is there no other way to make the check.
>
> Best regards,
>
> On Fri, Dec 4, 2015 at 4:35 PM, Ted Yu <yu...@gmail.com> wrote:
>
> > hasFamily() just checks the in-memory Map:
> >
> >   public boolean hasFamily(final byte [] familyName) {
> >
> >     return families.containsKey(familyName);
> >
> > bq. try to create it I will have an exception stating that the CF is
> > already existing.
> >
> > In this case you can catch the exception and proceed, right ?
> >
> > Cheers
> >
> > On Fri, Dec 4, 2015 at 2:09 AM, Mehdi Ben Haj Abbes <
> mehdi.abbes@gmail.com
> > >
> > wrote:
> >
> > > Hi folks,
> > >
> > > I'm new to HBase client java API and using 0.98.4-hadoop2 version.
> > >
> > > I need to check if a column family does exit even if it does not have
> any
> > > rows in it.
> > > The problem is that HTableDescriptor.hasFamily returns false for an
> empty
> > > column family so if I try to create it I will have an exception stating
> > > that the CF is already existing.
> > >
> > > Any help will be more than appreciated.
> > >
> > > Regard,
> > >
> > >
> > > --
> > > Mehdi BEN HAJ ABBES
> > >
> >
>
>
>
> --
> Mehdi BEN HAJ ABBES
>

Re: HTableDescriptor.hasFamily not working as expected

Posted by Mehdi Ben Haj Abbes <me...@gmail.com>.
Thanks Ted for your answer.

This what I'm doing : catching the exception, but before I'm setting
hbase.client.retries.number to 3 rather than the default value of 35
otherwise my job will hang for few minutes.

Is there no other way to make the check.

Best regards,

On Fri, Dec 4, 2015 at 4:35 PM, Ted Yu <yu...@gmail.com> wrote:

> hasFamily() just checks the in-memory Map:
>
>   public boolean hasFamily(final byte [] familyName) {
>
>     return families.containsKey(familyName);
>
> bq. try to create it I will have an exception stating that the CF is
> already existing.
>
> In this case you can catch the exception and proceed, right ?
>
> Cheers
>
> On Fri, Dec 4, 2015 at 2:09 AM, Mehdi Ben Haj Abbes <mehdi.abbes@gmail.com
> >
> wrote:
>
> > Hi folks,
> >
> > I'm new to HBase client java API and using 0.98.4-hadoop2 version.
> >
> > I need to check if a column family does exit even if it does not have any
> > rows in it.
> > The problem is that HTableDescriptor.hasFamily returns false for an empty
> > column family so if I try to create it I will have an exception stating
> > that the CF is already existing.
> >
> > Any help will be more than appreciated.
> >
> > Regard,
> >
> >
> > --
> > Mehdi BEN HAJ ABBES
> >
>



-- 
Mehdi BEN HAJ ABBES

Re: HTableDescriptor.hasFamily not working as expected

Posted by Ted Yu <yu...@gmail.com>.
hasFamily() just checks the in-memory Map:

  public boolean hasFamily(final byte [] familyName) {

    return families.containsKey(familyName);

bq. try to create it I will have an exception stating that the CF is
already existing.

In this case you can catch the exception and proceed, right ?

Cheers

On Fri, Dec 4, 2015 at 2:09 AM, Mehdi Ben Haj Abbes <me...@gmail.com>
wrote:

> Hi folks,
>
> I'm new to HBase client java API and using 0.98.4-hadoop2 version.
>
> I need to check if a column family does exit even if it does not have any
> rows in it.
> The problem is that HTableDescriptor.hasFamily returns false for an empty
> column family so if I try to create it I will have an exception stating
> that the CF is already existing.
>
> Any help will be more than appreciated.
>
> Regard,
>
>
> --
> Mehdi BEN HAJ ABBES
>