0

I have an usecase where I need to have a DS something like below

EmpName | SN
-------------
Alex    | 1

Chris   | 2

I just want to insert an Employee name here, SN should be auto generated serially.

How can I do this in cassandra?

Draken
  • 3,134
  • 13
  • 34
  • 54
rao
  • 1
  • 1
  • 1
    Possible duplicate of [How to create auto increment IDs in Cassandra](http://stackoverflow.com/questions/3935915/how-to-create-auto-increment-ids-in-cassandra) – OrangeDog Oct 06 '16 at 12:45
  • @OrangeDog I did not get anything here [http://stackoverflow.com/questions/3935915/how-to-create-auto-increment-ids-in-cassandra] which solves my problem. – rao Oct 06 '16 at 12:59
  • 1
    Then your problem isn't what you think it is. – OrangeDog Oct 06 '16 at 13:01
  • What you described exactly is not possible with Cassandra. The only thing that comes close is the counters feature, as talked about in the question mentioned by @OrangeDog – Jan Dörrenhaus Oct 06 '16 at 13:54
  • @OrangeDog I got what you are saying, But didn't want to do that way was looking for auto increment which is not possible in cassandra as per Jan Doerrenhaus – rao Oct 06 '16 at 14:52
  • @rao the answers to the duplicate also explain that what you're asking for is impossible. – OrangeDog Oct 06 '16 at 14:53
  • @OrangeDog Thanks – rao Oct 06 '16 at 19:56

1 Answers1

0

In general you don't want to do this in a distributed environment as it requires a read before writing.

UUID's are the best way of solving this problem. Have the client create one and insert it as the serial.

Nom de plume
  • 461
  • 3
  • 5
  • UUID at app level? I should generate there and pass on? thats what you mean? – rao Oct 08 '16 at 06:57
  • Yes, exactly. It should ensure you don't get conflicts. – Nom de plume Oct 08 '16 at 08:25
  • I find this method little dicey because in distributed computing systems for ex: storm topologies may not aware of the IDs across all the workers. How can I do it there? No right? – rao Oct 08 '16 at 09:49