hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dru Jensen <drujen...@gmail.com>
Subject Re: How to add a column family from hirb?
Date Tue, 16 Sep 2008 16:28:00 GMT
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" <guosijie@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 <clehene@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
>>
>>
>


Mime
View raw message