cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shuge Lee <shuge....@gmail.com>
Subject Re: How to generate 'unique' identifiers for use in Cassandra
Date Wed, 28 Apr 2010 02:04:08 GMT
import uuid
unique_key =  uuid.uuid4()

if you using Python.

2010/4/28 Mark Robson <markxr@gmail.com>

> 2010/4/26 Roland Hänel <roland@haenel.me>:
>> > Typically, in the SQL world we use things like AUTO_INCREMENT columns
>> that
>> > let us create a unique key automatically if a row is inserted into a
>> table.
>>
>
> auto_increment is an antipattern; it adds an extra key which you don't need
> (usually). If your data has a natural candidate key, use that. If not, add
> extra parts until you have a unique key.
>
> If you are using OrderPreservingParitioner, it is really important to use
> keys which can give you a lexically sortable range to scan when you need to
> find them, so that you can use get_range_slice etc.
>
> There are other approaches however - in some cases it may be possible to
> use columns instead of rows there. But you'd still need keys for the
> columns.
>
> A straightforward way of generating unique IDs for your objects is to add
> an incrementing ID (managed locally) to the host name of the (client) node
> where they were generated. But this is probably not helpful in most cases.
>
> Mark
>



-- 
Shuge Lee | Lee Li | 李蠡

Mime
View raw message