Snowflake IDs
I have been researching Snowflake IDs and how Snowflake IDs work:
Snowflake IDs, or snowflakes, are a form of unique identifier used in distributed computing. The format was created by Twitter and is used for the IDs of tweets.
Snowflakes are 64 bits in binary. The first 41 bits are a timestamp, representing milliseconds since the chosen epoch. The next 10 bits represent a machine ID, preventing clashes. Twelve more bits represent a per-machine sequence number, to allow creation of multiple snowflakes in the same millisecond. The final number is generally serialized in decimal.
A key characteristic, as with KSUID, is that they are sortable:
Snowflakes are sortable by time, because they are based on the time they were created.[2] Additionally, the time a snowflake was created can be calculated from the snowflake. This can be used to get snowflakes (and their associated objects) that were created before or after a particular date.
Java Libraries
I found several Java implementations:
phxql/snowflake-id
, which is licensed under LGPL (GNU Lesser General Public License 3.0). It seems active.
I also found this java implementation, which unfortunately it does not specify a license.
I found an implementation and test in Apache Marmotta which is licensed with Apache 2.0 License.
It seems Discord4J contains also a Snowflake ID implementation.
Tags: #uid #snowflake