incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Holstad <erikhols...@gmail.com>
Subject Re: Auto Increament
Date Wed, 24 Mar 2010 18:11:48 GMT
On Wed, Mar 24, 2010 at 11:00 AM, Jesus Ibanez <jesusibasim@gmail.com>wrote:

> You can generate UUIDs based on time with http://jug.safehaus.org/ if you
> use Java. And its easy to use, just have to insert one line:
> UUID uuid = UUIDGenerator.getInstance().generateTimeBasedUUID();
>
> Maybe a solution to your cuestion:
>
> To "replace" the autoincrement of MySQL, you can create a column family of
> type Super ordering super columns by decreasing order and naming the super
> columns with a numeric value. So then, if you want to insert a new value,
> first read the last inserted column name and add 1 to the returned value.
> Then insert a new super column wich it name will be the new value.
>
> I'm a little bit confused about this. Where do you get the last inserted
column from? Why is this better than having a fix counter row where you
increment the columnValue, non of them are threadsafe?


> Be careful with super columns, becouse I think that if you want to read
> just a column of a super column, all columns will be deserialized.
>
> So you will have this:
>
> Super_Columns_Family_Name = { // this is a ColumnFamily name of type Super
>     one_key: {    // this is the key to this row inside the Super CF
>
>         n: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
>
>         n-1: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
>
>         ...
>
> 2: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
> 1: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
> },
>
>      another_key: {    // this is the key to this row inside the Super CF
>
>
>         n: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
>
>         n-1: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
>
>         ...
>
> 2: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
> 1: {column1: "value 1", column2: "value 2", ... , columnN: "value n"},
> },
>
> }
>
> The super columns that represent the autoincrement value are the ones named
> as: n, n-1, ... , 2, 1.
>
> Hope it helps!
>
> Jesus.
>
>
>
> 2010/3/24 Sylvain Lebresne <sylvain@yakaz.com>
>
> > How can I replace the "auto increament" attribute in MySQL
>> > with Cassandra?
>>
>> You can't. Not easily at least.
>>
>> > If I can't, how can I generate an ID which is globally
>> > unique for each of columns?
>>
>> Check UUIDs:
>> http://en.wikipedia.org/wiki/Universally_Unique_Identifier
>>
>> >
>> > Thanks,
>> >
>> > Sent from my iPhone
>> >
>>
>
>


-- 
Regards Erik

Mime
View raw message