Answer the question
In order to leave comments, you need to log in
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
Why generate a long (Int64) value?
If the long key is integer, then just add entries with MAX IDENTITY + 1
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).
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 questionAsk a Question
731 491 924 answers to any question