Skip to content
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

add max uuid with all bits set. #120

Closed
james-lawrence opened this issue May 12, 2023 · 12 comments · Fixed by #129
Closed

add max uuid with all bits set. #120

james-lawrence opened this issue May 12, 2023 · 12 comments · Fixed by #129
Labels
enhancement New feature or request

Comments

@james-lawrence
Copy link
Contributor

james-lawrence commented May 12, 2023

the opposite of the nil, its useful constant to have around.

i'll also note both should be better served by functions as global vars are mutable.

@cameracker
Copy link
Collaborator

Hi @james-lawrence , thanks for the suggestion. Could you elaborate a little on the use cases such a constant might provide? The nil UUID is useful for modeling uninitialized uuids for certain situations, but I'm not sure intuitively what a max UUID would grant.

Thanks!

@dylan-bourque
Copy link
Member

Thinking about this a bit, a value with all bits set won't be valid for all UUID versions. One specific edge case is the 4 bits that contain the UUID version. Currently, the highest published version is 5 (with 6 and 7 in draft), which is 0101. Setting those other 2 bits would create a version 16, which doesn't exist.

@cameracker
Copy link
Collaborator

Thinking about this a little more... because there are version specific bits in the UUID, this would imply that we'd need a maximum per version, no?

@james-lawrence
Copy link
Contributor Author

james-lawrence commented Jun 3, 2023

Its useful for comparisons, ranges, etc. The utility of it has nothing to do with the method you use to generate uuids (dont need a definition per version). Its useful in the same way 0,max int/neg,pos infinity (both numerically and for timestamps). I use it a ton for signalling that a set is finished for example. (Since its the largest possible value in lexographical order)

@james-lawrence
Copy link
Contributor Author

james-lawrence commented Jun 3, 2023

You're thinking too hard about what it means per a arbitrary spec definition vs the utility it has in code ;).

@cameracker
Copy link
Collaborator

Thanks, but if we chose to ignore the upstream RFCs that define UUIDs to create random functionality, that would be deleterious to the functionality of this package.

Ill close this for now until there's additional interest. Thanks for the suggestion.

@cameracker cameracker closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2023
@dylan-bourque
Copy link
Member

Your thinking too hard about what it means per a arbitrary spec definition vs the utility it has in code ;).

@james-lawrence for me it's about correctness, not utility. A value with all bits set is not a valid UUID. Also, version 1-5 UUIDs are not sortable, so the concept of a "max" value doesn't make sense. If you want/need a sentinel value use uuid.Nil, we don't need 2.

I just don't think this provides enough value to offset these inconsistencies it introduces.

@james-lawrence
Copy link
Contributor Author

james-lawrence commented Jun 3, 2023

@dylan-bourque because you're viewing it through the lens of an arbitrary specification vs the actual values being generated. which are 128 bits and have a natural order. through this lens the max value I described is always correct no matter what uuid version you'd use. you can't generate a uuid larger than it.

@cameracker shrug your choice. thanks for listening.

@stevenaair
Copy link

stevenaair commented Jun 5, 2023

@cameracker The current rev for RFC 4122 does define, in sec 5.4. Max UUID the following:

The Max UUID is special form of UUID that is specified to have all 128 bits set to 1

@cameracker
Copy link
Collaborator

cameracker commented Jun 5, 2023

@cameracker The current rev for RFC 4122 does define, in sec 5.4. Max UUID the following:

Wow! I totally missed that. Thank you very much for identifying that.

In that case, let's reopen and see if someone contributes :) I might throw it in there in a couple of weeks if I can dig up some time.

Things to keep in mind:

  • This max UUID is an element of a draft specification, and we should clarify that it is experimental in the same way the other new UUID versions are and is subject for removal.
  • We should double check the newer drafts still have this UUID. The linked draft there has been subsumed by another set of drafts.

@cameracker cameracker reopened this Jun 5, 2023
@stevenaair
Copy link

  • We should double check the newer drafts still have this UUID. The linked draft there has been subsumed by another set of drafts.

My bad. In the latest it's called "Omni uuid" in section 5.10. Omni UUID

@james-lawrence
Copy link
Contributor Author

@cameracker contribute being like the definition of the variable that represents the max uuid?

@cameracker cameracker added the enhancement New feature or request label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants