- Where do you get the last inserted column from? - The first result of using get_slice method of thrift, would be the super column with highest value in the name, becouse the configuration of the column family of type super says that the super columns will be decresent ordered (if Cassandra doesn't let order columns decresently -I don't really know it-, you can add the max long -8 bytes long- value first and rest 1 for the future values). The super column family would look like this: <ColumnFamily CompareWith="LongType" Name="Comments" CompareSubcolumnsWith="BytesType" ColumnType="Super"/> Does this answer your question?
Cassandra can't do the increment automaticaly, but you can do it in the logic of your software. I don't know why Jaepil wants to do this... but the important thing it's that it is posible to do it. But I think the best way to have a unique global identifier, is to use UUID time based, where the first result of get_slice is the newest value: <ColumnFamily CompareWith="TimeUUIDType" Name="Comments" CompareSubcolumnsWith="BytesType" ColumnType="Super"/> Sorry for my english. Greetings! 2010/3/24 Erik Holstad <erikhols...@gmail.com> > > > On Wed, Mar 24, 2010 at 11:00 AM, Jesus Ibanez <jesusiba...@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 <sylv...@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 >