-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UUID version 7 implementation sorting incorrect? #69
Comments
I don't know but it does sound like there might be a problem. Thank you for reporting this. I would need a stable reproduction (in plain Java) & then time to look into this to say more. @Hellblazer WDYT? |
It's not a problem. UUID v7 only requires the first 48 bits to be continually increasing, just like the ULID specification. Some implementations use an optional counter to provide additional monotonicity for identifiers created by the same generator. But it's not required. Best regards |
Thank you @fabiolimace. If I understand this correctly, it'd be nice to guarantee such invariant. JUG does use counters to provide virtual 100 nano resolution with counter for "old" time/location based variant so it would seem reasonable to do it here, if it isn't. I'd have to double-check this aspect. But the other thing I was wondering about was whether this could be related to sortability (or lack thereof) of
Conversely it is possible the other library referenced might be using its own UUID type abstraction that would be using better comparator definition. FWTW, #13 sounds like similar report from the past. |
Ah ha. JUG provides
However! This class has NOT been updated along with addition of new variants so implementation could probably be improved. @excitement-engineer Would it be possible for you to see if use of |
arg. late top the party. will take a look and see |
@cowtowncoder Even with |
D'oh. deleted a bogus test of mine. apologies |
I'm able to reproduce this with this test:
|
okay, was able to repro that with just 2 entries in the above test - lol. |
Ok. So the issue is about making sure "random" part that was used will be changed to "random only for new 48-bit timestamp value; increment as sequence if same time part". But that sorting may work as-is, with Than kyou @Hellblazer -- I'll try to get this merged ASAP. |
Fix merged; will now publish 4.1.1 with this fix. |
I tried running the following code to ensure that the ordering of the UUID v7 is correct:
expect the equality check returns false for almost all entries. I have tried to run the same test with the library
com.github.f4b6a3:uuid-creator:5.2.0
and there the checks always return true using the following code:Is this a mistake in the implementation?
The text was updated successfully, but these errors were encountered: