javasnowflake
javasnowflake copied to clipboard
Negative ids
Hello,
Using the latest version, i still get negative Ids from some hosts. I use Amazon-deployed hosts; is this a problem for the algorithm?
For example, for 2 hosts, and for generating Ids within 10 secs, i get: 1225682100845207552 from the one and -7277113995538210816 from the other
This issue occurs cause datacenterId resides in the most significant part of generated Id. Java long type stores sign in the most significant bit.
So if dataCenterId will be > 512 we will have negative values in Java.
Fixed in https://github.com/Predictor/javasnowflake/pull/2