You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Cosmin Lehene <cl...@adobe.com> on 2008/09/16 13:51:44 UTC

How to add a column family from hirb?

Hi,

I've been trying to add a column family from the new shell. The
documentation doesn't really expose this. Is it still possible to do this?
It appears alter only deals with existing column families, not tables.

Any hints?

Thanks,
Cosmin


Re: How to add a column family from hirb?

Posted by Jean-Daniel Cryans <jd...@apache.org>.
Update : this issue is now https://issues.apache.org/jira/browse/HBASE-890

J-D

On Thu, Sep 18, 2008 at 12:13 PM, Dru Jensen <dr...@gmail.com> wrote:

> What about adding another modifier?
>
> alter 'tablename', {operation => 'delete', name => 'old_column'}
>
> We could default the operation to 'modify' which is the current behavior.
>
> Also this will allow for multiple operations in one call:
>
> alter 'tablename', {operation => 'delete', name => 'old_column'},
> {operation => 'add', name => 'new_column'}
>
>
>
>
> On Sep 18, 2008, at 5:36 AM, Jean-Daniel Cryans wrote:
>
>  Dingding Ye,
>>
>> Definitely this is not optimal, but we accept all good patches ;)
>>
>> J-D
>>
>> On Thu, Sep 18, 2008 at 4:13 AM, Dingding Ye <ye...@gmail.com>
>> wrote:
>>
>>  yes. we can do as following.
>>>
>>> admin.enableEnable(tablename);
>>> hcd = table.getTableDescriptor();
>>> admin.disableTable(tablename);
>>>
>>> But is this a good way to do that?
>>>
>>>
>>>
>>> On Thu, Sep 18, 2008 at 5:12 AM, stack <st...@duboce.net> wrote:
>>>
>>>> Pardon me if I do not have the full story, but can you not get the HTD
>>>>
>>> and
>>>
>>>> save it aside in a variable?  Then disable the table, etc?
>>>> St.Ack
>>>>
>>>> On Wed, Sep 17, 2008 at 11:41 AM, Dingding Ye <ye...@gmail.com>
>>>>
>>> wrote:
>>>
>>>>
>>>>  I think a problem here is that
>>>>>
>>>>> We can't alter a enabled table, so we have to disable the table at
>>>>> first.  In the other side, we can't get the table descriptor if the
>>>>> table is disabled. Deadlock here.
>>>>>
>>>>> On Wed, Sep 17, 2008 at 12:28 AM, Dru Jensen <dr...@gmail.com>
>>>>>
>>>> wrote:
>>>
>>>> Maybe check to see if the column exists; If it does, modify otherwise
>>>>>>
>>>>> add?
>>>>>
>>>>>>
>>>>>>  def alter(tableName, args)
>>>>>>    now = Time.now
>>>>>>    raise TypeError.new("Table name must be of type String") \
>>>>>>      unless tableName.instance_of? String
>>>>>>    descriptor = hcd(args)
>>>>>>    table = HTable.new(tableName)
>>>>>>    if (table.getTableDescriptor().hasFamily(descriptor.name))
>>>>>>      @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>>>>>> descriptor);
>>>>>>    else
>>>>>>      @admin.addColumn(tableName, descriptor);
>>>>>>    end
>>>>>>    @formatter.header()
>>>>>>    @formatter.footer(now)
>>>>>>  end
>>>>>>
>>>>>> Although this doesn't allow you to delete a column.
>>>>>>
>>>>>> On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:
>>>>>>
>>>>>>  Thanks,
>>>>>>>
>>>>>>> Here's the alter implementation:
>>>>>>>
>>>>>>>  def alter(tableName, args)
>>>>>>>   now = Time.now
>>>>>>>   raise TypeError.new("Table name must be of type String") \
>>>>>>>     unless tableName.instance_of? String
>>>>>>>   descriptor = hcd(args)
>>>>>>>   @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>>>>>>> descriptor);
>>>>>>>   @formatter.header()
>>>>>>>   @formatter.footer(now)
>>>>>>>  end
>>>>>>>
>>>>>>> It looks like it needs some logic to add a new column family
>>>>>>> @admin.addColumn
>>>>>>> I could implement it, however if I were to send a patch I'd need to
>>>>>>>
>>>>>> know
>>>
>>>> the syntax philosophy. Currently there's only one verb per command
>>>>>>>
>>>>>> and
>>>
>>>> for
>>>>>
>>>>>> alter... Add column we would have two verbs: alter and add. Should
>>>>>>>
>>>>>> this
>>>
>>>> be
>>>>>
>>>>>> something like alter 'table', {COLUMN => 'new_family_name'} or
>>>>>>> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an
>>>>>>> argument?
>>>>>>>
>>>>>>> Cosmin
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
>>>>>>>
>>>>>>> "alter" just do the *modification* operation.
>>>>>>>
>>>>>>> I think that you can write some functions in *HBase.rb* to implements
>>>>>>>
>>>>>> "add
>>>>>
>>>>>> families" operations:)
>>>>>>>
>>>>>>> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com>
>>>>>>>
>>>>>> wrote:
>>>>>
>>>>>>
>>>>>>>  Hi,
>>>>>>>>
>>>>>>>> I've been trying to add a column family from the new shell. The
>>>>>>>> documentation doesn't really expose this. Is it still possible to do
>>>>>>>> this?
>>>>>>>> It appears alter only deals with existing column families, not
>>>>>>>>
>>>>>>> tables.
>>>
>>>>
>>>>>>>> Any hints?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Cosmin
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>

Re: How to add a column family from hirb?

Posted by Dru Jensen <dr...@gmail.com>.
What about adding another modifier?

alter 'tablename', {operation => 'delete', name => 'old_column'}

We could default the operation to 'modify' which is the current  
behavior.

Also this will allow for multiple operations in one call:

alter 'tablename', {operation => 'delete', name => 'old_column'},  
{operation => 'add', name => 'new_column'}



On Sep 18, 2008, at 5:36 AM, Jean-Daniel Cryans wrote:

> Dingding Ye,
>
> Definitely this is not optimal, but we accept all good patches ;)
>
> J-D
>
> On Thu, Sep 18, 2008 at 4:13 AM, Dingding Ye <ye...@gmail.com>  
> wrote:
>
>> yes. we can do as following.
>>
>> admin.enableEnable(tablename);
>> hcd = table.getTableDescriptor();
>> admin.disableTable(tablename);
>>
>> But is this a good way to do that?
>>
>>
>>
>> On Thu, Sep 18, 2008 at 5:12 AM, stack <st...@duboce.net> wrote:
>>> Pardon me if I do not have the full story, but can you not get the  
>>> HTD
>> and
>>> save it aside in a variable?  Then disable the table, etc?
>>> St.Ack
>>>
>>> On Wed, Sep 17, 2008 at 11:41 AM, Dingding Ye <ye...@gmail.com>
>> wrote:
>>>
>>>> I think a problem here is that
>>>>
>>>> We can't alter a enabled table, so we have to disable the table at
>>>> first.  In the other side, we can't get the table descriptor if the
>>>> table is disabled. Deadlock here.
>>>>
>>>> On Wed, Sep 17, 2008 at 12:28 AM, Dru Jensen <dr...@gmail.com>
>> wrote:
>>>>> Maybe check to see if the column exists; If it does, modify  
>>>>> otherwise
>>>> add?
>>>>>
>>>>>   def alter(tableName, args)
>>>>>     now = Time.now
>>>>>     raise TypeError.new("Table name must be of type String") \
>>>>>       unless tableName.instance_of? String
>>>>>     descriptor = hcd(args)
>>>>>     table = HTable.new(tableName)
>>>>>     if (table.getTableDescriptor().hasFamily(descriptor.name))
>>>>>       @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>>>>> descriptor);
>>>>>     else
>>>>>       @admin.addColumn(tableName, descriptor);
>>>>>     end
>>>>>     @formatter.header()
>>>>>     @formatter.footer(now)
>>>>>   end
>>>>>
>>>>> Although this doesn't allow you to delete a column.
>>>>>
>>>>> On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:
>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Here's the alter implementation:
>>>>>>
>>>>>>  def alter(tableName, args)
>>>>>>    now = Time.now
>>>>>>    raise TypeError.new("Table name must be of type String") \
>>>>>>      unless tableName.instance_of? String
>>>>>>    descriptor = hcd(args)
>>>>>>    @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>>>>>> descriptor);
>>>>>>    @formatter.header()
>>>>>>    @formatter.footer(now)
>>>>>>  end
>>>>>>
>>>>>> It looks like it needs some logic to add a new column family
>>>>>> @admin.addColumn
>>>>>> I could implement it, however if I were to send a patch I'd  
>>>>>> need to
>> know
>>>>>> the syntax philosophy. Currently there's only one verb per  
>>>>>> command
>> and
>>>> for
>>>>>> alter... Add column we would have two verbs: alter and add.  
>>>>>> Should
>> this
>>>> be
>>>>>> something like alter 'table', {COLUMN => 'new_family_name'} or
>>>>>> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow  
>>>>>> as an
>>>>>> argument?
>>>>>>
>>>>>> Cosmin
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
>>>>>>
>>>>>> "alter" just do the *modification* operation.
>>>>>>
>>>>>> I think that you can write some functions in *HBase.rb* to  
>>>>>> implements
>>>> "add
>>>>>> families" operations:)
>>>>>>
>>>>>> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene  
>>>>>> <cl...@adobe.com>
>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I've been trying to add a column family from the new shell. The
>>>>>>> documentation doesn't really expose this. Is it still possible  
>>>>>>> to do
>>>>>>> this?
>>>>>>> It appears alter only deals with existing column families, not
>> tables.
>>>>>>>
>>>>>>> Any hints?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Cosmin
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>


Re: How to add a column family from hirb?

Posted by Jean-Daniel Cryans <jd...@apache.org>.
Dingding Ye,

Definitely this is not optimal, but we accept all good patches ;)

J-D

On Thu, Sep 18, 2008 at 4:13 AM, Dingding Ye <ye...@gmail.com> wrote:

> yes. we can do as following.
>
> admin.enableEnable(tablename);
> hcd = table.getTableDescriptor();
> admin.disableTable(tablename);
>
> But is this a good way to do that?
>
>
>
> On Thu, Sep 18, 2008 at 5:12 AM, stack <st...@duboce.net> wrote:
> > Pardon me if I do not have the full story, but can you not get the HTD
> and
> > save it aside in a variable?  Then disable the table, etc?
> > St.Ack
> >
> > On Wed, Sep 17, 2008 at 11:41 AM, Dingding Ye <ye...@gmail.com>
> wrote:
> >
> >> I think a problem here is that
> >>
> >> We can't alter a enabled table, so we have to disable the table at
> >> first.  In the other side, we can't get the table descriptor if the
> >> table is disabled. Deadlock here.
> >>
> >> On Wed, Sep 17, 2008 at 12:28 AM, Dru Jensen <dr...@gmail.com>
> wrote:
> >> > Maybe check to see if the column exists; If it does, modify otherwise
> >> add?
> >> >
> >> >    def alter(tableName, args)
> >> >      now = Time.now
> >> >      raise TypeError.new("Table name must be of type String") \
> >> >        unless tableName.instance_of? String
> >> >      descriptor = hcd(args)
> >> >      table = HTable.new(tableName)
> >> >      if (table.getTableDescriptor().hasFamily(descriptor.name))
> >> >        @admin.modifyColumn(tableName, descriptor.getNameAsString(),
> >> > descriptor);
> >> >      else
> >> >        @admin.addColumn(tableName, descriptor);
> >> >      end
> >> >      @formatter.header()
> >> >      @formatter.footer(now)
> >> >    end
> >> >
> >> > Although this doesn't allow you to delete a column.
> >> >
> >> > On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:
> >> >
> >> >> Thanks,
> >> >>
> >> >> Here's the alter implementation:
> >> >>
> >> >>   def alter(tableName, args)
> >> >>     now = Time.now
> >> >>     raise TypeError.new("Table name must be of type String") \
> >> >>       unless tableName.instance_of? String
> >> >>     descriptor = hcd(args)
> >> >>     @admin.modifyColumn(tableName, descriptor.getNameAsString(),
> >> >> descriptor);
> >> >>     @formatter.header()
> >> >>     @formatter.footer(now)
> >> >>   end
> >> >>
> >> >> It looks like it needs some logic to add a new column family
> >> >> @admin.addColumn
> >> >> I could implement it, however if I were to send a patch I'd need to
> know
> >> >> the syntax philosophy. Currently there's only one verb per command
> and
> >> for
> >> >> alter... Add column we would have two verbs: alter and add. Should
> this
> >> be
> >> >> something like alter 'table', {COLUMN => 'new_family_name'} or
> >> >> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an
> >> >> argument?
> >> >>
> >> >> Cosmin
> >> >>
> >> >>
> >> >>
> >> >> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
> >> >>
> >> >> "alter" just do the *modification* operation.
> >> >>
> >> >> I think that you can write some functions in *HBase.rb* to implements
> >> "add
> >> >> families" operations:)
> >> >>
> >> >> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com>
> >> wrote:
> >> >>
> >> >>> Hi,
> >> >>>
> >> >>> I've been trying to add a column family from the new shell. The
> >> >>> documentation doesn't really expose this. Is it still possible to do
> >> >>> this?
> >> >>> It appears alter only deals with existing column families, not
> tables.
> >> >>>
> >> >>> Any hints?
> >> >>>
> >> >>> Thanks,
> >> >>> Cosmin
> >> >>>
> >> >>>
> >> >>
> >> >
> >> >
> >>
> >
>

Re: How to add a column family from hirb?

Posted by Dingding Ye <ye...@gmail.com>.
yes. we can do as following.

admin.enableEnable(tablename);
hcd = table.getTableDescriptor();
admin.disableTable(tablename);

But is this a good way to do that?



On Thu, Sep 18, 2008 at 5:12 AM, stack <st...@duboce.net> wrote:
> Pardon me if I do not have the full story, but can you not get the HTD and
> save it aside in a variable?  Then disable the table, etc?
> St.Ack
>
> On Wed, Sep 17, 2008 at 11:41 AM, Dingding Ye <ye...@gmail.com> wrote:
>
>> I think a problem here is that
>>
>> We can't alter a enabled table, so we have to disable the table at
>> first.  In the other side, we can't get the table descriptor if the
>> table is disabled. Deadlock here.
>>
>> On Wed, Sep 17, 2008 at 12:28 AM, Dru Jensen <dr...@gmail.com> wrote:
>> > Maybe check to see if the column exists; If it does, modify otherwise
>> add?
>> >
>> >    def alter(tableName, args)
>> >      now = Time.now
>> >      raise TypeError.new("Table name must be of type String") \
>> >        unless tableName.instance_of? String
>> >      descriptor = hcd(args)
>> >      table = HTable.new(tableName)
>> >      if (table.getTableDescriptor().hasFamily(descriptor.name))
>> >        @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>> > descriptor);
>> >      else
>> >        @admin.addColumn(tableName, descriptor);
>> >      end
>> >      @formatter.header()
>> >      @formatter.footer(now)
>> >    end
>> >
>> > Although this doesn't allow you to delete a column.
>> >
>> > On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:
>> >
>> >> Thanks,
>> >>
>> >> Here's the alter implementation:
>> >>
>> >>   def alter(tableName, args)
>> >>     now = Time.now
>> >>     raise TypeError.new("Table name must be of type String") \
>> >>       unless tableName.instance_of? String
>> >>     descriptor = hcd(args)
>> >>     @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>> >> descriptor);
>> >>     @formatter.header()
>> >>     @formatter.footer(now)
>> >>   end
>> >>
>> >> It looks like it needs some logic to add a new column family
>> >> @admin.addColumn
>> >> I could implement it, however if I were to send a patch I'd need to know
>> >> the syntax philosophy. Currently there's only one verb per command and
>> for
>> >> alter... Add column we would have two verbs: alter and add. Should this
>> be
>> >> something like alter 'table', {COLUMN => 'new_family_name'} or
>> >> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an
>> >> argument?
>> >>
>> >> Cosmin
>> >>
>> >>
>> >>
>> >> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
>> >>
>> >> "alter" just do the *modification* operation.
>> >>
>> >> I think that you can write some functions in *HBase.rb* to implements
>> "add
>> >> families" operations:)
>> >>
>> >> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com>
>> wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> I've been trying to add a column family from the new shell. The
>> >>> documentation doesn't really expose this. Is it still possible to do
>> >>> this?
>> >>> It appears alter only deals with existing column families, not tables.
>> >>>
>> >>> Any hints?
>> >>>
>> >>> Thanks,
>> >>> Cosmin
>> >>>
>> >>>
>> >>
>> >
>> >
>>
>

Re: How to add a column family from hirb?

Posted by stack <st...@duboce.net>.
Pardon me if I do not have the full story, but can you not get the HTD and
save it aside in a variable?  Then disable the table, etc?
St.Ack

On Wed, Sep 17, 2008 at 11:41 AM, Dingding Ye <ye...@gmail.com> wrote:

> I think a problem here is that
>
> We can't alter a enabled table, so we have to disable the table at
> first.  In the other side, we can't get the table descriptor if the
> table is disabled. Deadlock here.
>
> On Wed, Sep 17, 2008 at 12:28 AM, Dru Jensen <dr...@gmail.com> wrote:
> > Maybe check to see if the column exists; If it does, modify otherwise
> add?
> >
> >    def alter(tableName, args)
> >      now = Time.now
> >      raise TypeError.new("Table name must be of type String") \
> >        unless tableName.instance_of? String
> >      descriptor = hcd(args)
> >      table = HTable.new(tableName)
> >      if (table.getTableDescriptor().hasFamily(descriptor.name))
> >        @admin.modifyColumn(tableName, descriptor.getNameAsString(),
> > descriptor);
> >      else
> >        @admin.addColumn(tableName, descriptor);
> >      end
> >      @formatter.header()
> >      @formatter.footer(now)
> >    end
> >
> > Although this doesn't allow you to delete a column.
> >
> > On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:
> >
> >> Thanks,
> >>
> >> Here's the alter implementation:
> >>
> >>   def alter(tableName, args)
> >>     now = Time.now
> >>     raise TypeError.new("Table name must be of type String") \
> >>       unless tableName.instance_of? String
> >>     descriptor = hcd(args)
> >>     @admin.modifyColumn(tableName, descriptor.getNameAsString(),
> >> descriptor);
> >>     @formatter.header()
> >>     @formatter.footer(now)
> >>   end
> >>
> >> It looks like it needs some logic to add a new column family
> >> @admin.addColumn
> >> I could implement it, however if I were to send a patch I'd need to know
> >> the syntax philosophy. Currently there's only one verb per command and
> for
> >> alter... Add column we would have two verbs: alter and add. Should this
> be
> >> something like alter 'table', {COLUMN => 'new_family_name'} or
> >> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an
> >> argument?
> >>
> >> Cosmin
> >>
> >>
> >>
> >> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
> >>
> >> "alter" just do the *modification* operation.
> >>
> >> I think that you can write some functions in *HBase.rb* to implements
> "add
> >> families" operations:)
> >>
> >> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com>
> wrote:
> >>
> >>> Hi,
> >>>
> >>> I've been trying to add a column family from the new shell. The
> >>> documentation doesn't really expose this. Is it still possible to do
> >>> this?
> >>> It appears alter only deals with existing column families, not tables.
> >>>
> >>> Any hints?
> >>>
> >>> Thanks,
> >>> Cosmin
> >>>
> >>>
> >>
> >
> >
>

Re: How to add a column family from hirb?

Posted by Dingding Ye <ye...@gmail.com>.
I think a problem here is that

We can't alter a enabled table, so we have to disable the table at
first.  In the other side, we can't get the table descriptor if the
table is disabled. Deadlock here.

On Wed, Sep 17, 2008 at 12:28 AM, Dru Jensen <dr...@gmail.com> wrote:
> Maybe check to see if the column exists; If it does, modify otherwise add?
>
>    def alter(tableName, args)
>      now = Time.now
>      raise TypeError.new("Table name must be of type String") \
>        unless tableName.instance_of? String
>      descriptor = hcd(args)
>      table = HTable.new(tableName)
>      if (table.getTableDescriptor().hasFamily(descriptor.name))
>        @admin.modifyColumn(tableName, descriptor.getNameAsString(),
> descriptor);
>      else
>        @admin.addColumn(tableName, descriptor);
>      end
>      @formatter.header()
>      @formatter.footer(now)
>    end
>
> Although this doesn't allow you to delete a column.
>
> On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:
>
>> Thanks,
>>
>> Here's the alter implementation:
>>
>>   def alter(tableName, args)
>>     now = Time.now
>>     raise TypeError.new("Table name must be of type String") \
>>       unless tableName.instance_of? String
>>     descriptor = hcd(args)
>>     @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>> descriptor);
>>     @formatter.header()
>>     @formatter.footer(now)
>>   end
>>
>> It looks like it needs some logic to add a new column family
>> @admin.addColumn
>> I could implement it, however if I were to send a patch I'd need to know
>> the syntax philosophy. Currently there's only one verb per command and for
>> alter... Add column we would have two verbs: alter and add. Should this be
>> something like alter 'table', {COLUMN => 'new_family_name'} or
>> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an
>> argument?
>>
>> Cosmin
>>
>>
>>
>> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
>>
>> "alter" just do the *modification* operation.
>>
>> I think that you can write some functions in *HBase.rb* to implements "add
>> families" operations:)
>>
>> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com> wrote:
>>
>>> Hi,
>>>
>>> I've been trying to add a column family from the new shell. The
>>> documentation doesn't really expose this. Is it still possible to do
>>> this?
>>> It appears alter only deals with existing column families, not tables.
>>>
>>> Any hints?
>>>
>>> Thanks,
>>> Cosmin
>>>
>>>
>>
>
>

Re: How to add a column family from hirb?

Posted by stack <st...@duboce.net>.
alter lacks finesse.  It needs improvement.   After Dru's comment, adding a
qualifier seems like the only alternative.

Currently, to add a new column family, run alter supplying a list of column
descriptors that includes all previous column families plus the new one.

Thanks
St.Ack

On Tue, Sep 16, 2008 at 9:28 AM, Dru Jensen <dr...@gmail.com> wrote:

> Maybe check to see if the column exists; If it does, modify otherwise add?
>
>    def alter(tableName, args)
>      now = Time.now
>      raise TypeError.new("Table name must be of type String") \
>        unless tableName.instance_of? String
>      descriptor = hcd(args)
>      table = HTable.new(tableName)
>      if (table.getTableDescriptor().hasFamily(descriptor.name))
>        @admin.modifyColumn(tableName, descriptor.getNameAsString(),
> descriptor);
>      else
>        @admin.addColumn(tableName, descriptor);
>      end
>      @formatter.header()
>      @formatter.footer(now)
>    end
>
> Although this doesn't allow you to delete a column.
>
>
> On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:
>
>  Thanks,
>>
>> Here's the alter implementation:
>>
>>   def alter(tableName, args)
>>     now = Time.now
>>     raise TypeError.new("Table name must be of type String") \
>>       unless tableName.instance_of? String
>>     descriptor = hcd(args)
>>     @admin.modifyColumn(tableName, descriptor.getNameAsString(),
>> descriptor);
>>     @formatter.header()
>>     @formatter.footer(now)
>>   end
>>
>> It looks like it needs some logic to add a new column family
>> @admin.addColumn
>> I could implement it, however if I were to send a patch I'd need to know
>> the syntax philosophy. Currently there's only one verb per command and for
>> alter... Add column we would have two verbs: alter and add. Should this be
>> something like alter 'table', {COLUMN => 'new_family_name'} or
>> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an
>> argument?
>>
>> Cosmin
>>
>>
>>
>> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
>>
>> "alter" just do the *modification* operation.
>>
>> I think that you can write some functions in *HBase.rb* to implements "add
>> families" operations:)
>>
>> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com> wrote:
>>
>>  Hi,
>>>
>>> I've been trying to add a column family from the new shell. The
>>> documentation doesn't really expose this. Is it still possible to do
>>> this?
>>> It appears alter only deals with existing column families, not tables.
>>>
>>> Any hints?
>>>
>>> Thanks,
>>> Cosmin
>>>
>>>
>>>
>>
>

Re: How to add a column family from hirb?

Posted by Dru Jensen <dr...@gmail.com>.
Maybe check to see if the column exists; If it does, modify otherwise  
add?

     def alter(tableName, args)
       now = Time.now
       raise TypeError.new("Table name must be of type String") \
         unless tableName.instance_of? String
       descriptor = hcd(args)
       table = HTable.new(tableName)
       if (table.getTableDescriptor().hasFamily(descriptor.name))
         @admin.modifyColumn(tableName, descriptor.getNameAsString(),  
descriptor);
       else
         @admin.addColumn(tableName, descriptor);
       end
       @formatter.header()
       @formatter.footer(now)
     end

Although this doesn't allow you to delete a column.

On Sep 16, 2008, at 6:05 AM, Cosmin Lehene wrote:

> Thanks,
>
> Here's the alter implementation:
>
>    def alter(tableName, args)
>      now = Time.now
>      raise TypeError.new("Table name must be of type String") \
>        unless tableName.instance_of? String
>      descriptor = hcd(args)
>      @admin.modifyColumn(tableName, descriptor.getNameAsString(),  
> descriptor);
>      @formatter.header()
>      @formatter.footer(now)
>    end
>
> It looks like it needs some logic to add a new column family  
> @admin.addColumn
> I could implement it, however if I were to send a patch I'd need to  
> know the syntax philosophy. Currently there's only one verb per  
> command and for alter... Add column we would have two verbs: alter  
> and add. Should this be something like alter 'table', {COLUMN =>  
> 'new_family_name'} or
> {NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an  
> argument?
>
> Cosmin
>
>
>
> On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:
>
> "alter" just do the *modification* operation.
>
> I think that you can write some functions in *HBase.rb* to  
> implements "add
> families" operations:)
>
> On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com>  
> wrote:
>
>> Hi,
>>
>> I've been trying to add a column family from the new shell. The
>> documentation doesn't really expose this. Is it still possible to  
>> do this?
>> It appears alter only deals with existing column families, not  
>> tables.
>>
>> Any hints?
>>
>> Thanks,
>> Cosmin
>>
>>
>


Re: How to add a column family from hirb?

Posted by Cosmin Lehene <cl...@adobe.com>.
Thanks,

Here's the alter implementation:

    def alter(tableName, args)
      now = Time.now
      raise TypeError.new("Table name must be of type String") \
        unless tableName.instance_of? String
      descriptor = hcd(args)
      @admin.modifyColumn(tableName, descriptor.getNameAsString(), descriptor);
      @formatter.header()
      @formatter.footer(now)
    end

It looks like it needs some logic to add a new column family @admin.addColumn
I could implement it, however if I were to send a patch I'd need to know the syntax philosophy. Currently there's only one verb per command and for alter... Add column we would have two verbs: alter and add. Should this be something like alter 'table', {COLUMN => 'new_family_name'} or
{NEW_COLUMN => ..} etc, or should we pass the add verb somehow as an argument?

Cosmin



On 9/16/08 3:35 PM, "Samuel Guo" <gu...@gmail.com> wrote:

"alter" just do the *modification* operation.

I think that you can write some functions in *HBase.rb* to implements "add
families" operations:)

On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com> wrote:

> Hi,
>
> I've been trying to add a column family from the new shell. The
> documentation doesn't really expose this. Is it still possible to do this?
> It appears alter only deals with existing column families, not tables.
>
> Any hints?
>
> Thanks,
> Cosmin
>
>


Re: How to add a column family from hirb?

Posted by Samuel Guo <gu...@gmail.com>.
"alter" just do the *modification* operation.

I think that you can write some functions in *HBase.rb* to implements "add
families" operations:)

On Tue, Sep 16, 2008 at 7:51 PM, Cosmin Lehene <cl...@adobe.com> wrote:

> Hi,
>
> I've been trying to add a column family from the new shell. The
> documentation doesn't really expose this. Is it still possible to do this?
> It appears alter only deals with existing column families, not tables.
>
> Any hints?
>
> Thanks,
> Cosmin
>
>