You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by 马超 <ho...@gmail.com> on 2012/04/27 17:26:10 UTC

Can column type be changed dynamically?

Hi all,

I want to change one of my column type from IntegerType to Int32Type
dynamically. I'm sure all datas in that column are int32 type indeed. So I
want changing the column type by:

*update column family XXX with column_metadata = [{column_name : 'xxx',
validation_class : Int32Type}];*

Is there any harm to do this?

Thanks,

Chao.

Re: Can column type be changed dynamically?

Posted by aaron morton <aa...@thelastpickle.com>.
That sounds right to me. 

A
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 29/04/2012, at 5:00 AM, Paolo Bernardi wrote:

> Apparently IntegerType is based on Java's BigInteger.
> 
> http://git-wip-us.apache.org/repos/asf?p=cassandra.git;a=blob_plain;f=src/java/org/apache/cassandra/db/marshal/IntegerType.java;hb=HEAD
> 
> Given the message, I suspect that you got some values between -2^15 and 2^15-1 (the range of a short int) that have been serialized with two bytes. Any confirmation on this?
> 
> If this is true, changing the type like you tried to do might not be so straightforward.
> 
> Paolo
> 
> On Apr 27, 2012 6:55 PM, "马超" <ho...@gmail.com> wrote:
> After I update the column type:
> 
> update column family User with column_metadata = [{column_name : 77, validation_class : Int32Type}];
> 
> I can't list the data in User column family:
> 
> list User;
> 
> RowKey: 1234
> A int is exactly 4 bytes: 2
> 
> Any ideas for this?
> 
> Thanks,
> 
> 2012/4/27 马超 <ho...@gmail.com>
> Thanks a lot!
> I will go ahead~
> 
> 
> 2012/4/27 Sylvain Lebresne <sy...@datastax.com>
> On Fri, Apr 27, 2012 at 5:26 PM, 马超 <ho...@gmail.com> wrote:
> > Hi all,
> >
> > I want to change one of my column type from IntegerType to Int32Type
> > dynamically. I'm sure all datas in that column are int32 type indeed. So I
> > want changing the column type by:
> >
> > update column family XXX with column_metadata = [{column_name : 'xxx',
> > validation_class : Int32Type}];
> >
> > Is there any harm to do this?
> 
> There isn't (as long as you're right to be sure of course).
> 
> --
> Sylvain
> 
> 


Re: Can column type be changed dynamically?

Posted by Paolo Bernardi <be...@gmail.com>.
Apparently IntegerType is based on Java's BigInteger.

http://git-wip-us.apache.org/repos/asf?p=cassandra.git;a=blob_plain;f=src/java/org/apache/cassandra/db/marshal/IntegerType.java;hb=HEAD

Given the message, I suspect that you got some values between -2^15 and
2^15-1 (the range of a short int) that have been serialized with two bytes.
Any confirmation on this?

If this is true, changing the type like you tried to do might not be so
straightforward.

Paolo
On Apr 27, 2012 6:55 PM, "马超" <ho...@gmail.com> wrote:

> After I update the column type:
>
> *update column family User with column_metadata = [{column_name : 77,
> validation_class : Int32Type}];*
>
> I can't list the data in User column family:
>
> *list User;*
> *
> *
> *RowKey: 1234*
> *A int is exactly 4 bytes: 2*
>
> Any ideas for this?
>
> Thanks,
>
> 2012/4/27 马超 <ho...@gmail.com>
>
>> Thanks a lot!
>> I will go ahead~
>>
>>
>> 2012/4/27 Sylvain Lebresne <sy...@datastax.com>
>>
>>> On Fri, Apr 27, 2012 at 5:26 PM, 马超 <ho...@gmail.com> wrote:
>>> > Hi all,
>>> >
>>> > I want to change one of my column type from IntegerType to Int32Type
>>> > dynamically. I'm sure all datas in that column are int32 type indeed.
>>> So I
>>> > want changing the column type by:
>>> >
>>> > update column family XXX with column_metadata = [{column_name : 'xxx',
>>> > validation_class : Int32Type}];
>>> >
>>> > Is there any harm to do this?
>>>
>>> There isn't (as long as you're right to be sure of course).
>>>
>>> --
>>> Sylvain
>>>
>>
>>
>

Re: Can column type be changed dynamically?

Posted by 马超 <ho...@gmail.com>.
After I update the column type:

*update column family User with column_metadata = [{column_name : 77,
validation_class : Int32Type}];*

I can't list the data in User column family:

*list User;*
*
*
*RowKey: 1234*
*A int is exactly 4 bytes: 2*

Any ideas for this?

Thanks,

2012/4/27 马超 <ho...@gmail.com>

> Thanks a lot!
> I will go ahead~
>
>
> 2012/4/27 Sylvain Lebresne <sy...@datastax.com>
>
>> On Fri, Apr 27, 2012 at 5:26 PM, 马超 <ho...@gmail.com> wrote:
>> > Hi all,
>> >
>> > I want to change one of my column type from IntegerType to Int32Type
>> > dynamically. I'm sure all datas in that column are int32 type indeed.
>> So I
>> > want changing the column type by:
>> >
>> > update column family XXX with column_metadata = [{column_name : 'xxx',
>> > validation_class : Int32Type}];
>> >
>> > Is there any harm to do this?
>>
>> There isn't (as long as you're right to be sure of course).
>>
>> --
>> Sylvain
>>
>
>

Re: Can column type be changed dynamically?

Posted by 马超 <ho...@gmail.com>.
Thanks a lot!
I will go ahead~

2012/4/27 Sylvain Lebresne <sy...@datastax.com>

> On Fri, Apr 27, 2012 at 5:26 PM, 马超 <ho...@gmail.com> wrote:
> > Hi all,
> >
> > I want to change one of my column type from IntegerType to Int32Type
> > dynamically. I'm sure all datas in that column are int32 type indeed. So
> I
> > want changing the column type by:
> >
> > update column family XXX with column_metadata = [{column_name : 'xxx',
> > validation_class : Int32Type}];
> >
> > Is there any harm to do this?
>
> There isn't (as long as you're right to be sure of course).
>
> --
> Sylvain
>

Re: Can column type be changed dynamically?

Posted by Sylvain Lebresne <sy...@datastax.com>.
On Fri, Apr 27, 2012 at 5:26 PM, 马超 <ho...@gmail.com> wrote:
> Hi all,
>
> I want to change one of my column type from IntegerType to Int32Type
> dynamically. I'm sure all datas in that column are int32 type indeed. So I
> want changing the column type by:
>
> update column family XXX with column_metadata = [{column_name : 'xxx',
> validation_class : Int32Type}];
>
> Is there any harm to do this?

There isn't (as long as you're right to be sure of course).

--
Sylvain