B
B
becks2014-12-12 15:32:30
Database
becks, 2014-12-12 15:32:30

How to generate a unique int64 number?

I know the question sounds crooked, I'll try to explain on the fingers.
There are 2 storages, in both it is necessary to store data on some entities. Part of the data for each entity falls into one system, part into another. It is necessary to organize the ability to combine data for the required entity.
The idea is to generate a unique key and store it in both systems. Wanted to use GUID. But there was a problem - one of the systems uses only int64 as a primary key. GUID - 128 bits.
Is there any possibility to generate unique int64?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Filatov, 2014-12-12
@NYMEZIDE

Why generate a long (Int64) value?
If the long key is integer, then just add entries with MAX IDENTITY + 1

M
maaGames, 2014-12-12
@maaGames

You generate a GUID and take the remainder of division by a 64-bit prime number for it. Or you xorish the first 64 bits with the second 64 bits (but conflicts are already possible here).

A
Andrew Yazu, 2014-12-12
@yazu

If there are less than a million entities, then you can simply generate random int64 - the chances of a collision are less than 1 in 10,000,000. I would bet on the opposite ;) Read more

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question